summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/TrackingFlags/lib/Admin.pm6
-rw-r--r--extensions/TrackingFlags/lib/Flag.pm13
-rw-r--r--extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl7
-rw-r--r--extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl14
4 files changed, 29 insertions, 11 deletions
diff --git a/extensions/TrackingFlags/lib/Admin.pm b/extensions/TrackingFlags/lib/Admin.pm
index 3529d30a7..2796a102d 100644
--- a/extensions/TrackingFlags/lib/Admin.pm
+++ b/extensions/TrackingFlags/lib/Admin.pm
@@ -37,7 +37,7 @@ our @EXPORT = qw(
sub admin_list {
my ($vars) = @_;
-
+ $vars->{show_bug_counts} = Bugzilla->input_params->{show_bug_counts};
$vars->{flags} = [ Bugzilla::Extension::TrackingFlags::Flag->get_all() ];
}
@@ -75,7 +75,7 @@ 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->has_bug_values;
+ $vars->{can_delete} = !$flag_obj->bug_count;
if ($vars->{mode} eq 'new') {
$vars->{message} = 'tracking_flag_created';
@@ -93,7 +93,7 @@ sub admin_edit {
$vars->{flag} = $flag;
$vars->{values} = _flag_values_to_json($flag->values);
$vars->{visibility} = _flag_visibility_to_json($flag->visibility);
- $vars->{can_delete} = !$flag->has_bug_values;
+ $vars->{can_delete} = !$flag->bug_count;
} elsif ($vars->{mode} eq 'copy') {
# copy - load the source flag
diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm
index f35b661eb..26780a2b1 100644
--- a/extensions/TrackingFlags/lib/Flag.pm
+++ b/extensions/TrackingFlags/lib/Flag.pm
@@ -223,7 +223,7 @@ sub remove_from_db {
}
# Check to see if tracking_flags_bugs table has records
- if ($self->has_bug_values) {
+ if ($self->bug_count) {
ThrowUserError('tracking_flag_has_contents', { flag => $self });
}
@@ -396,15 +396,14 @@ sub bug_flag {
return $self->{'bug_flag'} = Bugzilla::Extension::TrackingFlags::Flag::Bug->new($params);
}
-sub has_bug_values {
+sub bug_count {
my ($self) = @_;
- return $self->{'has_bug_values'} if defined $self->{'has_bug_values'};
+ return $self->{'bug_count'} if defined $self->{'bug_count'};
my $dbh = Bugzilla->dbh;
- return $self->{'has_bug_values'} = scalar $dbh->selectrow_array("
- SELECT 1
+ return $self->{'bug_count'} = scalar $dbh->selectrow_array("
+ SELECT COUNT(bug_id)
FROM tracking_flags_bugs
- WHERE tracking_flag_id = ? " .
- $dbh->sql_limit(1),
+ WHERE tracking_flag_id = ?",
undef, $self->flag_id);
}
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 0c4a443f9..97a9e5a02 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
@@ -102,6 +102,13 @@ var selected_components = [
<td><input type="checkbox" name="flag_active" id="flag_active" value="1" [% "checked" IF flag.is_active %]></td>
</tr>
+[% IF mode == 'edit' %]
+ <tr>
+ <th>[% terms.Bug %] Count</th>
+ <td>[% flag.bug_count FILTER html %]</td>
+ </tr>
+[% END %]
+
</table>
[%# values %]
diff --git a/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl b/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl
index e310bcee5..5ea68dd98 100644
--- a/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl
@@ -20,6 +20,9 @@
<th>Type</th>
<th>Sort Key</th>
<th>Active</th>
+ [% IF show_bug_counts %]
+ <th>[% terms.Bugs %]</th>
+ [% END %]
<th>&nbsp;</th>
</tr>
@@ -44,8 +47,13 @@
<td>
[% flag.is_active ? "Yes" : "No" %]
</td>
+ [% IF show_bug_counts %]
+ <td>
+ [% flag.bug_count FILTER html %]
+ </td>
+ [% END %]
<td>
- <a href="page.cgi?id=tracking_flags_admin_edit.html&amp;mode=copy&amp;copy_from=[% flag.flag_id FILTER uri %]">Copy</a>
+ <a href="page.cgi?id=tracking_flags_admin_edit.html&amp;mode=copy&amp;copy_from=[% flag.flag_id FILTER uri %]">Copy</a>
</td>
</tr>
[% END %]
@@ -54,6 +62,10 @@
<div id="new_flag">
<a href="page.cgi?id=tracking_flags_admin_edit.html">Add Flag</a> |
+ [% IF !show_bug_counts %]
+ <a href="page.cgi?id=tracking_flags_admin_list.html&amp;show_bug_counts=1">
+ Show [% terms.bug %] counts (slower)</a> |
+ [% END %]
<input type="checkbox" onclick="filter_flag_list(this.checked)" id="filter">
<label for="filter">Show disabled flags</label>
</div>