summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/TrackingFlags')
-rw-r--r--extensions/TrackingFlags/Extension.pm17
-rw-r--r--extensions/TrackingFlags/lib/Admin.pm5
-rw-r--r--extensions/TrackingFlags/lib/Flag.pm8
-rw-r--r--extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_edit.html.tmpl6
-rw-r--r--extensions/TrackingFlags/template/en/default/pages/tracking_flags_admin_list.html.tmpl11
-rw-r--r--extensions/TrackingFlags/web/js/admin.js570
6 files changed, 338 insertions, 279 deletions
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm
index e3b8bb4e7..42b3b9f03 100644
--- a/extensions/TrackingFlags/Extension.pm
+++ b/extensions/TrackingFlags/Extension.pm
@@ -59,6 +59,7 @@ sub template_before_process {
{
$vars->{'tracking_flags'} = Bugzilla::Extension::TrackingFlags::Flag->match({
product => $vars->{'product'}->name,
+ enter_bug => 1,
is_active => 1,
});
@@ -169,6 +170,11 @@ sub db_schema_abstract_schema {
NOTNULL => 1,
DEFAULT => '0',
},
+ enter_bug => {
+ TYPE => 'BOOLEAN',
+ NOTNULL => 1,
+ DEFAULT => 'TRUE',
+ },
is_active => {
TYPE => 'BOOLEAN',
NOTNULL => 1,
@@ -265,11 +271,22 @@ sub db_schema_abstract_schema {
sub install_update_db {
my $dbh = Bugzilla->dbh;
+
my $fk = $dbh->bz_fk_info('tracking_flags', 'field_id');
if ($fk and !defined $fk->{DELETE}) {
$fk->{DELETE} = 'CASCADE';
$dbh->bz_alter_fk('tracking_flags', 'field_id', $fk);
}
+
+ $dbh->bz_add_column(
+ 'tracking_flags',
+ 'enter_bug',
+ {
+ TYPE => 'BOOLEAN',
+ NOTNULL => 1,
+ DEFAULT => 'TRUE',
+ }
+ );
}
sub active_custom_fields {
diff --git a/extensions/TrackingFlags/lib/Admin.pm b/extensions/TrackingFlags/lib/Admin.pm
index 3529d30a7..c87570632 100644
--- a/extensions/TrackingFlags/lib/Admin.pm
+++ b/extensions/TrackingFlags/lib/Admin.pm
@@ -110,6 +110,7 @@ sub admin_edit {
}
$flag->set_sortkey(_next_unique_sortkey($flag->sortkey));
$flag->set_type($flag->flag_type);
+ $flag->set_enter_bug($flag->enter_bug);
# always default new flags as active, even when copying an inactive one
$flag->set_is_active(1);
@@ -122,6 +123,7 @@ sub admin_edit {
$vars->{mode} = 'new';
$vars->{flag} = {
sortkey => 0,
+ enter_bug => 1,
is_active => 1,
};
$vars->{values} = _flag_values_to_json([
@@ -149,10 +151,12 @@ sub _load_from_input {
description => trim($input->{flag_desc} || ''),
sortkey => $input->{flag_sort} || 0,
type => trim($input->{flag_type} || ''),
+ enter_bug => $input->{flag_enter_bug} ? 1 : 0,
is_active => $input->{flag_active} ? 1 : 0,
};
detaint_natural($flag->{id});
detaint_natural($flag->{sortkey});
+ detaint_natural($flag->{enter_bug});
detaint_natural($flag->{is_active});
# values
@@ -289,6 +293,7 @@ sub _update_db_flag {
description => $flag->{description},
sortkey => $flag->{sortkey},
type => $flag->{type},
+ enter_bug => $flag->{enter_bug},
is_active => $flag->{is_active},
};
diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm
index f35b661eb..b7abe97d2 100644
--- a/extensions/TrackingFlags/lib/Flag.pm
+++ b/extensions/TrackingFlags/lib/Flag.pm
@@ -35,6 +35,7 @@ use constant DB_COLUMNS => qw(
description
type
sortkey
+ enter_bug
is_active
);
@@ -45,6 +46,7 @@ use constant UPDATE_COLUMNS => qw(
description
type
sortkey
+ enter_bug
is_active
);
@@ -53,8 +55,8 @@ use constant VALIDATORS => {
description => \&_check_description,
type => \&_check_type,
sortkey => \&_check_sortkey,
+ enter_bug => \&Bugzilla::Object::check_boolean,
is_active => \&Bugzilla::Object::check_boolean,
-
};
use constant UPDATE_VALIDATORS => {
@@ -62,6 +64,7 @@ use constant UPDATE_VALIDATORS => {
description => \&_check_description,
type => \&_check_type,
sortkey => \&_check_sortkey,
+ enter_bug => \&Bugzilla::Object::check_boolean,
is_active => \&Bugzilla::Object::check_boolean,
};
@@ -338,6 +341,7 @@ sub set_name { $_[0]->set('name', $_[1]); }
sub set_description { $_[0]->set('description', $_[1]); }
sub set_type { $_[0]->set('type', $_[1]); }
sub set_sortkey { $_[0]->set('sortkey', $_[1]); }
+sub set_enter_bug { $_[0]->set('enter_bug', $_[1]); }
sub set_is_active { $_[0]->set('is_active', $_[1]); }
###############################
@@ -349,6 +353,7 @@ sub name { return $_[0]->{'name'}; }
sub description { return $_[0]->{'description'}; }
sub flag_type { return $_[0]->{'type'}; }
sub sortkey { return $_[0]->{'sortkey'}; }
+sub enter_bug { return $_[0]->{'enter_bug'}; }
sub is_active { return $_[0]->{'is_active'}; }
sub values {
@@ -421,7 +426,6 @@ sub legal_values { return $_[0]->values; }
sub custom { return 1; }
sub in_new_bugmail { return 1; }
sub obsolete { return 0; }
-sub enter_bug { return 1; }
sub buglist { return 1; }
sub is_select { return 1; }
sub is_abnormal { return 1; }
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..f239791c7 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
@@ -98,6 +98,12 @@ var selected_components = [
</tr>
<tr>
+ <th>Enter [% terms.Bug %]</th>
+ <td><input type="checkbox" name="flag_enter_bug" id="flag_enter_bug" value="1" [% "checked" IF flag.enter_bug %]></td>
+ <td class="help">can be set on [% terms.bug %] creation</td>
+</tr>
+
+<tr>
<th>Active</th>
<td><input type="checkbox" name="flag_active" id="flag_active" value="1" [% "checked" IF flag.is_active %]></td>
</tr>
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 6c2ecc915..e310bcee5 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
@@ -9,9 +9,10 @@
[% PROCESS global/header.html.tmpl
title = "Release Tracking Flags"
style_urls = [ 'extensions/TrackingFlags/web/styles/admin.css' ]
+ javascript_urls = [ 'extensions/TrackingFlags/web/js/admin.js' ]
%]
-<table class="list" cellspacing="0">
+<table id="flag_list" class="list" cellspacing="0">
<tr>
<th>Name</th>
@@ -23,7 +24,9 @@
</tr>
[% FOREACH flag = flags %]
- <tr class="[% loop.count % 2 == 1 ? "odd_row" : "even_row" %]">
+ <tr class="flag_row
+ [% loop.count % 2 == 1 ? " odd_row" : " even_row" %]
+ [% " is_disabled" UNLESS flag.is_active %]">
<td [% 'class="disabled"' UNLESS flag.is_active %]>
<a href="page.cgi?id=tracking_flags_admin_edit.html&amp;mode=edit&amp;flag_id=[% flag.flag_id FILTER uri %]">
[% flag.name FILTER html %]
@@ -50,7 +53,9 @@
</table>
<div id="new_flag">
-<a href="page.cgi?id=tracking_flags_admin_edit.html">Add Flag</a>
+ <a href="page.cgi?id=tracking_flags_admin_edit.html">Add Flag</a> |
+ <input type="checkbox" onclick="filter_flag_list(this.checked)" id="filter">
+ <label for="filter">Show disabled flags</label>
</div>
[% INCLUDE global/footer.html.tmpl %]
diff --git a/extensions/TrackingFlags/web/js/admin.js b/extensions/TrackingFlags/web/js/admin.js
index 461ef7c63..e3eb81714 100644
--- a/extensions/TrackingFlags/web/js/admin.js
+++ b/extensions/TrackingFlags/web/js/admin.js
@@ -12,22 +12,26 @@ var Event = YAHOO.util.Event;
Event.onDOMReady(function() {
try {
- if (!JSON)
- JSON = YAHOO.lang.JSON;
-
- Event.addListener('flag_name', 'change', change_flag_name, Dom.get('flag_name'));
- Event.addListener('flag_desc', 'change', change_string_value, Dom.get('flag_desc'));
- Event.addListener('flag_type', 'change', change_select_value, Dom.get('flag_type'));
- Event.addListener('flag_sort', 'change', change_int_value, Dom.get('flag_sort'));
-
- Event.addListener('product', 'change', function() {
- if (Dom.get('product').value == '')
- Dom.get('component').options.length = 0;
- });
-
- update_flag_values();
- update_flag_visibility();
- tag_missing_values();
+ if (Dom.get('flag_list')) {
+ filter_flag_list(Dom.get('filter').checked);
+ }
+ else {
+ if (!JSON)
+ JSON = YAHOO.lang.JSON;
+ Event.addListener('flag_name', 'change', change_flag_name, Dom.get('flag_name'));
+ Event.addListener('flag_desc', 'change', change_string_value, Dom.get('flag_desc'));
+ Event.addListener('flag_type', 'change', change_select_value, Dom.get('flag_type'));
+ Event.addListener('flag_sort', 'change', change_int_value, Dom.get('flag_sort'));
+
+ Event.addListener('product', 'change', function() {
+ if (Dom.get('product').value == '')
+ Dom.get('component').options.length = 0;
+ });
+
+ update_flag_values();
+ update_flag_visibility();
+ tag_missing_values();
+ }
} catch(e) {
console.error(e);
}
@@ -36,349 +40,367 @@ Event.onDOMReady(function() {
// field
function change_flag_name(e, o) {
- change_string_value(e, o);
- if (o.value == '')
- return;
- o.value = o.value.replace(/[^a-z0-9_]/g, '_');
- if (!o.value.match(/^cf_/))
- o.value = 'cf_' + o.value;
- if (Dom.get('flag_desc').value == '') {
- var desc = o.value;
- desc = desc.replace(/^cf_/, '');
- desc = desc.replace(/_/g, '-');
- Dom.get('flag_desc').value = desc;
- tag_missing_value(Dom.get('flag_desc'));
- }
+ change_string_value(e, o);
+ if (o.value == '')
+ return;
+ o.value = o.value.replace(/[^a-z0-9_]/g, '_');
+ if (!o.value.match(/^cf_/))
+ o.value = 'cf_' + o.value;
+ if (Dom.get('flag_desc').value == '') {
+ var desc = o.value;
+ desc = desc.replace(/^cf_/, '');
+ desc = desc.replace(/_/g, '-');
+ Dom.get('flag_desc').value = desc;
+ tag_missing_value(Dom.get('flag_desc'));
+ }
}
function inc_field(id, amount) {
- var el = Dom.get(id);
- el.value = el.value.match(/-?\d+/) * 1 + amount;
- change_int_value(null, el);
+ var el = Dom.get(id);
+ el.value = el.value.match(/-?\d+/) * 1 + amount;
+ change_int_value(null, el);
}
// values
function update_flag_values() {
- // update the values table from the flag_values global
+ // update the values table from the flag_values global
- var tbl = Dom.get('flag_values');
- if (!tbl)
- return;
-
- // remove current entries
- while (tbl.rows.length > 3) {
- tbl.deleteRow(2);
- }
+ var tbl = Dom.get('flag_values');
+ if (!tbl)
+ return;
- // add all entries
-
- for (var i = 0, l = flag_values.length; i < l; i++) {
- var value = flag_values[i];
-
- var row = tbl.insertRow(2 + i);
- var cell;
-
- // value
- cell = row.insertCell(0);
- if (value.value == '---') {
- cell.innerHTML = '---';
- } else {
- var inputEl = document.createElement('input');
- inputEl.id = 'value_' + i;
- inputEl.type = 'text';
- inputEl.className = 'option_value';
- inputEl.value = value.value;
- Event.addListener(inputEl, 'change', change_string_value, inputEl);
- Event.addListener(inputEl, 'change', function(e, o) {
- flag_values[o.id.match(/\d+$/)].value = o.value;
- tag_invalid_values();
- }, inputEl);
- Event.addListener(inputEl, 'keyup', function(e, o) {
- if ((e.key || e.keyCode) == 27 && o.value == '')
- remove_value(o.id.match(/\d+$/));
- }, inputEl);
- cell.appendChild(inputEl);
+ // remove current entries
+ while (tbl.rows.length > 3) {
+ tbl.deleteRow(2);
}
- // setter
- cell = row.insertCell(1);
- var selectEl = document.createElement('select');
- selectEl.id = 'setter_' + i;
- Event.addListener(selectEl, 'change', change_select_value, selectEl);
- var optionEl = document.createElement('option');
- optionEl.value = '';
- selectEl.appendChild(optionEl);
- for (var j = 0, m = groups.length; j < m; j++) {
- var group = groups[j];
- optionEl = document.createElement('option');
- optionEl.value = group.id;
- optionEl.innerHTML = YAHOO.lang.escapeHTML(group.name);
- optionEl.selected = group.id == value.setter_group_id;
- selectEl.appendChild(optionEl);
- }
- Event.addListener(selectEl, 'change', function(e, o) {
- flag_values[o.id.match(/\d+$/)].setter_group_id = o.value;
- tag_invalid_values();
- }, selectEl);
- cell.appendChild(selectEl);
-
- // active
- cell = row.insertCell(2);
- if (value.value == '---') {
- cell.innerHTML = 'Yes';
- } else {
- var inputEl = document.createElement('input');
- inputEl.type = 'checkbox';
- inputEl.id = 'is_active_' + i;
- inputEl.checked = value.is_active;
- Event.addListener(inputEl, 'change', function(e, o) {
- flag_values[o.id.match(/\d+$/)].is_active = o.checked;
- }, inputEl);
- cell.appendChild(inputEl);
+ // add all entries
+
+ for (var i = 0, l = flag_values.length; i < l; i++) {
+ var value = flag_values[i];
+
+ var row = tbl.insertRow(2 + i);
+ var cell;
+
+ // value
+ cell = row.insertCell(0);
+ if (value.value == '---') {
+ cell.innerHTML = '---';
+ }
+ else {
+ var inputEl = document.createElement('input');
+ inputEl.id = 'value_' + i;
+ inputEl.type = 'text';
+ inputEl.className = 'option_value';
+ inputEl.value = value.value;
+ Event.addListener(inputEl, 'change', change_string_value, inputEl);
+ Event.addListener(inputEl, 'change', function(e, o) {
+ flag_values[o.id.match(/\d+$/)].value = o.value;
+ tag_invalid_values();
+ }, inputEl);
+ Event.addListener(inputEl, 'keyup', function(e, o) {
+ if ((e.key || e.keyCode) == 27 && o.value == '')
+ remove_value(o.id.match(/\d+$/));
+ }, inputEl);
+ cell.appendChild(inputEl);
+ }
+
+ // setter
+ cell = row.insertCell(1);
+ var selectEl = document.createElement('select');
+ selectEl.id = 'setter_' + i;
+ Event.addListener(selectEl, 'change', change_select_value, selectEl);
+ var optionEl = document.createElement('option');
+ optionEl.value = '';
+ selectEl.appendChild(optionEl);
+ for (var j = 0, m = groups.length; j < m; j++) {
+ var group = groups[j];
+ optionEl = document.createElement('option');
+ optionEl.value = group.id;
+ optionEl.innerHTML = YAHOO.lang.escapeHTML(group.name);
+ optionEl.selected = group.id == value.setter_group_id;
+ selectEl.appendChild(optionEl);
+ }
+ Event.addListener(selectEl, 'change', function(e, o) {
+ flag_values[o.id.match(/\d+$/)].setter_group_id = o.value;
+ tag_invalid_values();
+ }, selectEl);
+ cell.appendChild(selectEl);
+
+ // active
+ cell = row.insertCell(2);
+ if (value.value == '---') {
+ cell.innerHTML = 'Yes';
+ }
+ else {
+ var inputEl = document.createElement('input');
+ inputEl.type = 'checkbox';
+ inputEl.id = 'is_active_' + i;
+ inputEl.checked = value.is_active;
+ Event.addListener(inputEl, 'change', function(e, o) {
+ flag_values[o.id.match(/\d+$/)].is_active = o.checked;
+ }, inputEl);
+ cell.appendChild(inputEl);
+ }
+
+ // actions
+ cell = row.insertCell(3);
+ var html =
+ '[' +
+ (i == 0
+ ? '<span class="txt_icon">&nbsp;-&nbsp;</span>'
+ : '<a class="txt_icon" href="#" onclick="value_move_up(' + i + ');return false"> &Delta; </a>'
+ ) +
+ '|' +
+ (i == l - 1
+ ? '<span class="txt_icon">&nbsp;-&nbsp;</span>'
+ : '<a class="txt_icon" href="#" onclick="value_move_down(' + i + ');return false"> &nabla; </a>'
+ );
+ if (value.value != '---')
+ html += '| <a href="#" onclick="remove_value(' + i + ');return false">Remove</a>';
+ html += ']';
+ cell.innerHTML = html;
}
- // actions
- cell = row.insertCell(3);
- var html =
- '[' +
- (i == 0
- ? '<span class="txt_icon">&nbsp;-&nbsp;</span>'
- : '<a class="txt_icon" href="#" onclick="value_move_up(' + i + ');return false"> &Delta; </a>'
- ) +
- '|' +
- ( i == l - 1
- ? '<span class="txt_icon">&nbsp;-&nbsp;</span>'
- : '<a class="txt_icon" href="#" onclick="value_move_down(' + i + ');return false"> &nabla; </a>'
- );
- if (value.value != '---')
- html += '| <a href="#" onclick="remove_value(' + i + ');return false">Remove</a>';
- html += ']';
- cell.innerHTML = html;
- }
-
- tag_invalid_values();
+ tag_invalid_values();
}
function tag_invalid_values() {
- // reset
- for (var i = 0, l = flag_values.length; i < l; i++) {
- Dom.removeClass('value_' + i, 'admin_error');
- }
+ // reset
+ for (var i = 0, l = flag_values.length; i < l; i++) {
+ Dom.removeClass('value_' + i, 'admin_error');
+ }
- for (var i = 0, l = flag_values.length; i < l; i++) {
- // missing
- if (flag_values[i].value == '')
- Dom.addClass('value_' + i, 'admin_error');
- if (!flag_values[i].setter_group_id)
- Dom.addClass('setter_' + i, 'admin_error');
-
- // duplicate values
- for (var j = i; j < l; j++) {
- if (i != j && flag_values[i].value == flag_values[j].value) {
- Dom.addClass('value_' + i, 'admin_error');
- Dom.addClass('value_' + j, 'admin_error');
- }
+ for (var i = 0, l = flag_values.length; i < l; i++) {
+ // missing
+ if (flag_values[i].value == '')
+ Dom.addClass('value_' + i, 'admin_error');
+ if (!flag_values[i].setter_group_id)
+ Dom.addClass('setter_' + i, 'admin_error');
+
+ // duplicate values
+ for (var j = i; j < l; j++) {
+ if (i != j && flag_values[i].value == flag_values[j].value) {
+ Dom.addClass('value_' + i, 'admin_error');
+ Dom.addClass('value_' + j, 'admin_error');
+ }
+ }
}
- }
}
function value_move_up(idx) {
- if (idx == 0)
- return;
- var tmp = flag_values[idx];
- flag_values[idx] = flag_values[idx - 1];
- flag_values[idx - 1] = tmp;
- update_flag_values();
+ if (idx == 0)
+ return;
+ var tmp = flag_values[idx];
+ flag_values[idx] = flag_values[idx - 1];
+ flag_values[idx - 1] = tmp;
+ update_flag_values();
}
function value_move_down(idx) {
- if (idx == flag_values.length - 1)
- return;
- var tmp = flag_values[idx];
- flag_values[idx] = flag_values[idx + 1];
- flag_values[idx + 1] = tmp;
- update_flag_values();
+ if (idx == flag_values.length - 1)
+ return;
+ var tmp = flag_values[idx];
+ flag_values[idx] = flag_values[idx + 1];
+ flag_values[idx + 1] = tmp;
+ update_flag_values();
}
function add_value() {
- var value = new Object();
- value.id = 0;
- value.value = '';
- value.setter_group_id = '';
- value.is_active = true;
- var idx = flag_values.length;
- flag_values[idx] = value;
- update_flag_values();
- Dom.get('value_' + idx).focus();
+ var value = new Object();
+ value.id = 0;
+ value.value = '';
+ value.setter_group_id = '';
+ value.is_active = true;
+ var idx = flag_values.length;
+ flag_values[idx] = value;
+ update_flag_values();
+ Dom.get('value_' + idx).focus();
}
function remove_value(idx) {
- flag_values.splice(idx, 1);
- update_flag_values();
+ flag_values.splice(idx, 1);
+ update_flag_values();
}
function update_value(e, o) {
- var i = o.value.match(/\d+/);
- flag_values[i].value = o.value;
+ var i = o.value.match(/\d+/);
+ flag_values[i].value = o.value;
}
// visibility
function update_flag_visibility() {
- // update the visibility table from the flag_visibility global
+ // update the visibility table from the flag_visibility global
- var tbl = Dom.get('flag_visibility');
- if (!tbl)
- return;
+ var tbl = Dom.get('flag_visibility');
+ if (!tbl)
+ return;
- // remove current entries
- while (tbl.rows.length > 3) {
- tbl.deleteRow(2);
- }
+ // remove current entries
+ while (tbl.rows.length > 3) {
+ tbl.deleteRow(2);
+ }
- // show something if there aren't any components
+ // show something if there aren't any components
- if (!flag_visibility.length) {
- var row = tbl.insertRow(2);
- var cell = row.insertCell(0);
- cell.innerHTML = '<i class="admin_error_text">missing</i>';
- }
+ if (!flag_visibility.length) {
+ var row = tbl.insertRow(2);
+ var cell = row.insertCell(0);
+ cell.innerHTML = '<i class="admin_error_text">missing</i>';
+ }
- // add all entries
+ // add all entries
- for (var i = 0, l = flag_visibility.length; i < l; i++) {
- var visibility = flag_visibility[i];
+ for (var i = 0, l = flag_visibility.length; i < l; i++) {
+ var visibility = flag_visibility[i];
- var row = tbl.insertRow(2 + i);
- var cell;
+ var row = tbl.insertRow(2 + i);
+ var cell;
- // product
- cell = row.insertCell(0);
- cell.innerHTML = visibility.product;
+ // product
+ cell = row.insertCell(0);
+ cell.innerHTML = visibility.product;
- // component
- cell = row.insertCell(1);
- cell.innerHTML = visibility.component
- ? visibility.component
- : '<i>-- Any --</i>';
+ // component
+ cell = row.insertCell(1);
+ cell.innerHTML = visibility.component
+ ? visibility.component
+ : '<i>-- Any --</i>';
- // actions
- cell = row.insertCell(2);
- cell.innerHTML = '[ <a href="#" onclick="remove_visibility(' + i + ');return false">Remove</a> ]';
- }
+ // actions
+ cell = row.insertCell(2);
+ cell.innerHTML = '[ <a href="#" onclick="remove_visibility(' + i + ');return false">Remove</a> ]';
+ }
}
function add_visibility() {
- // validation
- var product = Dom.get('product').value;
- var component = Dom.get('component').value;
- if (!product) {
- alert('Please select a product.');
- return;
- }
+ // validation
+ var product = Dom.get('product').value;
+ var component = Dom.get('component').value;
+ if (!product) {
+ alert('Please select a product.');
+ return;
+ }
- // don't allow duplicates
- for (var i = 0, l = flag_visibility.length; i < l; i++) {
- if (flag_visibility[i].product == product && flag_visibility[i].component == component) {
- Dom.get('product').value = '';
- Dom.get('component').options.length = 0;
- return;
+ // don't allow duplicates
+ for (var i = 0, l = flag_visibility.length; i < l; i++) {
+ if (flag_visibility[i].product == product && flag_visibility[i].component == component) {
+ Dom.get('product').value = '';
+ Dom.get('component').options.length = 0;
+ return;
+ }
}
- }
- if (component == '') {
- // if we're adding an "any" component, remove non-any components
- for (var i = 0; i < flag_visibility.length; i++) {
- var visibility = flag_visibility[i];
- if (visibility.product == product) {
- flag_visibility.splice(i, 1);
- i--;
- }
+ if (component == '') {
+ // if we're adding an "any" component, remove non-any components
+ for (var i = 0; i < flag_visibility.length; i++) {
+ var visibility = flag_visibility[i];
+ if (visibility.product == product) {
+ flag_visibility.splice(i, 1);
+ i--;
+ }
+ }
}
- } else {
- // don't add non-any components if an "any" component exists
- for (var i = 0, l = flag_visibility.length; i < l; i++) {
- var visibility = flag_visibility[i];
- if (visibility.product == product && !visibility.component) {
- return;
- }
+ else {
+ // don't add non-any components if an "any" component exists
+ for (var i = 0, l = flag_visibility.length; i < l; i++) {
+ var visibility = flag_visibility[i];
+ if (visibility.product == product && !visibility.component)
+ return;
+ }
}
- }
- // add to model
- var visibility = new Object();
- visibility.id = 0;
- visibility.product = product;
- visibility.component = component;
- flag_visibility[flag_visibility.length] = visibility;
-
- // update ui
- update_flag_visibility();
- Dom.get('product').value = '';
- Dom.get('component').options.length = 0;
+ // add to model
+ var visibility = new Object();
+ visibility.id = 0;
+ visibility.product = product;
+ visibility.component = component;
+ flag_visibility[flag_visibility.length] = visibility;
+
+ // update ui
+ update_flag_visibility();
+ Dom.get('product').value = '';
+ Dom.get('component').options.length = 0;
}
function remove_visibility(idx) {
- flag_visibility.splice(idx, 1);
- update_flag_visibility();
+ flag_visibility.splice(idx, 1);
+ update_flag_visibility();
}
// validation and submission
function tag_missing_values() {
- var els = document.getElementsByTagName('input');
- for (var i = 0, l = els.length; i < l; i++) {
- var el = els[i];
- if (el.id.match(/^(flag|value)_/))
- tag_missing_value(el);
- }
- tag_missing_value(Dom.get('flag_type'));
+ var els = document.getElementsByTagName('input');
+ for (var i = 0, l = els.length; i < l; i++) {
+ var el = els[i];
+ if (el.id.match(/^(flag|value)_/))
+ tag_missing_value(el);
+ }
+ tag_missing_value(Dom.get('flag_type'));
}
function tag_missing_value(el) {
- el.value == ''
- ? Dom.addClass(el, 'admin_error')
- : Dom.removeClass(el, 'admin_error');
+ el.value == ''
+ ? Dom.addClass(el, 'admin_error')
+ : Dom.removeClass(el, 'admin_error');
}
function delete_confirm(flag) {
- if (confirm('Are you sure you want to delete the flag ' + flag + ' ?')) {
- Dom.get('delete').value = 1;
- return true;
- } else {
- return false;
- }
+ if (confirm('Are you sure you want to delete the flag ' + flag + ' ?')) {
+ Dom.get('delete').value = 1;
+ return true;
+ }
+ else {
+ return false;
+ }
}
function on_submit() {
- if (Dom.get('delete') && Dom.get('delete').value)
- return;
- // let perl manage most validation errors, because they are clearly marked
- // the exception is an empty visibility list, so catch that here as well
- if (!flag_visibility.length) {
- alert('You must provide at least one product for visibility.');
- return false;
- }
+ if (Dom.get('delete') && Dom.get('delete').value)
+ return;
+ // let perl manage most validation errors, because they are clearly marked
+ // the exception is an empty visibility list, so catch that here as well
+ if (!flag_visibility.length) {
+ alert('You must provide at least one product for visibility.');
+ return false;
+ }
- Dom.get('values').value = JSON.stringify(flag_values);
- Dom.get('visibility').value = JSON.stringify(flag_visibility);
- return true;
+ Dom.get('values').value = JSON.stringify(flag_values);
+ Dom.get('visibility').value = JSON.stringify(flag_visibility);
+ return true;
+}
+
+// flag list
+
+function filter_flag_list(show_disabled) {
+ var rows = Dom.getElementsByClassName('flag_row', 'tr', 'flag_list');
+ for (var i = 0, l = rows.length; i < l; i++) {
+ if (Dom.hasClass(rows[i], 'is_disabled')) {
+ if (show_disabled) {
+ Dom.removeClass(rows[i], 'bz_default_hidden');
+ }
+ else {
+ Dom.addClass(rows[i], 'bz_default_hidden');
+ }
+ }
+ }
}
// utils
function change_string_value(e, o) {
- o.value = YAHOO.lang.trim(o.value);
- tag_missing_value(o);
+ o.value = YAHOO.lang.trim(o.value);
+ tag_missing_value(o);
}
function change_int_value(e, o) {
- o.value = o.value.match(/-?\d+/);
- tag_missing_value(o);
+ o.value = o.value.match(/-?\d+/);
+ tag_missing_value(o);
}
function change_select_value(e, o) {
- tag_missing_value(o);
+ tag_missing_value(o);
}
-