summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-09-06 18:43:59 +0200
committerDave Lawrence <dlawrence@mozilla.com>2013-09-06 18:43:59 +0200
commit9451fe4f8c5662127d53c23b6976ec5f203d0f0e (patch)
treed0c57ee5cc6190a678219a44e30b3994bc1fc799 /extensions/TrackingFlags
parent1b6f172daa92499f2a2bd7a9341f6617abc5e0e2 (diff)
downloadbugzilla-9451fe4f8c5662127d53c23b6976ec5f203d0f0e.tar.gz
bugzilla-9451fe4f8c5662127d53c23b6976ec5f203d0f0e.tar.xz
Bug 913208 - Allow deleting of tracking flags that do not have bug values set but have activity entries in bugs_activity
r=glob
Diffstat (limited to 'extensions/TrackingFlags')
-rw-r--r--extensions/TrackingFlags/lib/Admin.pm1
-rw-r--r--extensions/TrackingFlags/lib/Flag.pm19
-rw-r--r--extensions/TrackingFlags/template/en/default/hook/global/user-error-errors.html.tmpl5
-rw-r--r--extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl4
4 files changed, 14 insertions, 15 deletions
diff --git a/extensions/TrackingFlags/lib/Admin.pm b/extensions/TrackingFlags/lib/Admin.pm
index 2796a102d..719b4f248 100644
--- a/extensions/TrackingFlags/lib/Admin.pm
+++ b/extensions/TrackingFlags/lib/Admin.pm
@@ -75,7 +75,6 @@ sub admin_edit {
$vars->{flag} = $flag_obj;
$vars->{values} = _flag_values_to_json($values);
$vars->{visibility} = _flag_visibility_to_json($visibilities);
- $vars->{can_delete} = !$flag_obj->bug_count;
if ($vars->{mode} eq 'new') {
$vars->{message} = 'tracking_flag_created';
diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm
index 26780a2b1..29f81669d 100644
--- a/extensions/TrackingFlags/lib/Flag.pm
+++ b/extensions/TrackingFlags/lib/Flag.pm
@@ -215,13 +215,6 @@ sub remove_from_db {
my $self = shift;
my $dbh = Bugzilla->dbh;
- # Check to see if bug activity table has records
- my $has_activity = $dbh->selectrow_array("SELECT COUNT(*) FROM bugs_activity
- WHERE fieldid = ?", undef, $self->id);
- if ($has_activity) {
- ThrowUserError('tracking_flag_has_activity', { flag => $self });
- }
-
# Check to see if tracking_flags_bugs table has records
if ($self->bug_count) {
ThrowUserError('tracking_flag_has_contents', { flag => $self });
@@ -234,6 +227,7 @@ sub remove_from_db {
eval {
$dbh->bz_start_transaction();
+ $dbh->do('DELETE FROM bugs_activity WHERE fieldid = ?', undef, $self->id);
$dbh->do('DELETE FROM fielddefs WHERE name = ?', undef, $self->name);
$dbh->bz_commit_transaction();
@@ -407,6 +401,17 @@ sub bug_count {
undef, $self->flag_id);
}
+sub activity_count {
+ my ($self) = @_;
+ return $self->{'activity_count'} if defined $self->{'activity_count'};
+ my $dbh = Bugzilla->dbh;
+ return $self->{'activity_count'} = scalar $dbh->selectrow_array("
+ SELECT COUNT(bug_id)
+ FROM bugs_activity
+ WHERE fieldid = ?",
+ undef, $self->id);
+}
+
######################################
# Compatibility with Bugzilla::Field #
######################################
diff --git a/extensions/TrackingFlags/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/TrackingFlags/template/en/default/hook/global/user-error-errors.html.tmpl
index 13f9980dc..7987c7d8d 100644
--- a/extensions/TrackingFlags/template/en/default/hook/global/user-error-errors.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/hook/global/user-error-errors.html.tmpl
@@ -54,11 +54,6 @@
[% title = "Invalid flag type" %]
The flag type '[% type FILTER html %]' is invalid.
-[% ELSIF error == "tracking_flag_has_activity" %]
- [% title = "Tracking Flag Has Activity" %]
- The tracking flag '[% flag.name FILTER html %]' cannot be deleted because
- it has recorded activity.
-
[% ELSIF error == "tracking_flag_has_contents" %]
[% title = "Tracking Flag Has Contents" %]
The tracking flag '[% flag.name FILTER html %]' cannot be deleted because
diff --git a/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl b/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl
index 97a9e5a02..85915dbde 100644
--- a/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl
@@ -174,9 +174,9 @@ var selected_components = [
<div>
<input type="submit" name="submit" id="submit" value="[% mode == 'edit' ? 'Save Changes' : 'Add' %]">
- [% IF can_delete %]
+ [% IF !flag.bug_count %]
<input type="hidden" name="delete" id="delete" value="">
- <input type="submit" value="Delete"
+ <input type="submit" value="Delete Flag [% IF flag.activity_count %] and Activity[% END %]"
onclick="return delete_confirm('[% flag.name FILTER js FILTER html %]')">
[% END %]
</div>