mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Support for enabling/disabling table widget.
The table widget now can be enabled/disabled. When disabled, the checkboxes and links/buttons are grayed out and non functional. The radio buttons in HBAC and SUDO details page have been modified to enable/disable the corresponding tables.
This commit is contained in:
committed by
Adam Young
parent
e79406a0f9
commit
409b6efa5f
@@ -352,17 +352,32 @@ function ipa_association_table_widget(spec) {
|
||||
button.replaceWith(IPA.action_button({
|
||||
'label': button.val(),
|
||||
'icon': 'ui-icon-trash',
|
||||
'click': function() { that.show_remove_dialog(); }
|
||||
'click': function() {
|
||||
if ($(this).hasClass('action-button-disabled')) return false;
|
||||
that.show_remove_dialog();
|
||||
}
|
||||
}));
|
||||
|
||||
button = $('input[name=add]', container);
|
||||
button.replaceWith(IPA.action_button({
|
||||
'label': button.val(),
|
||||
'icon': 'ui-icon-plus',
|
||||
'click': function() { that.show_add_dialog() }
|
||||
'click': function() {
|
||||
if ($(this).hasClass('action-button-disabled')) return false;
|
||||
that.show_add_dialog();
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
that.set_enabled = function(enabled) {
|
||||
that.table_set_enabled(enabled);
|
||||
if (enabled) {
|
||||
$('.action-button', that.table).removeClass('action-button-disabled');
|
||||
} else {
|
||||
$('.action-button', that.table).addClass('action-button-disabled');
|
||||
}
|
||||
};
|
||||
|
||||
that.get_records = function(on_success, on_error) {
|
||||
|
||||
if (!that.values.length) return;
|
||||
|
||||
@@ -511,6 +511,11 @@ span.main-separator{
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
a.action-button-disabled {
|
||||
color: gray;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.action-controls {
|
||||
position: relative;
|
||||
display:inline;
|
||||
|
||||
@@ -85,6 +85,39 @@ function ipa_rule_details_section(spec){
|
||||
}
|
||||
};
|
||||
|
||||
that.setup = function(container) {
|
||||
|
||||
that.section_setup(container);
|
||||
|
||||
function update_tables(value) {
|
||||
|
||||
var enabled = '' == value;
|
||||
|
||||
for (var i=0; i<that.tables.length; i++) {
|
||||
var table = that.tables[i];
|
||||
|
||||
var field = that.get_field(table.field_name);
|
||||
field.set_enabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
var category = that.get_field(that.field_name);
|
||||
category.reset = function() {
|
||||
category.widget_reset();
|
||||
var values = category.save();
|
||||
if (values.length == 0) return;
|
||||
var value = values[0];
|
||||
update_tables(value);
|
||||
};
|
||||
|
||||
var inputs = $('input[name='+that.field_name+']', container);
|
||||
inputs.change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
update_tables(value);
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
@@ -107,7 +140,7 @@ function ipa_rule_association_table_widget(spec) {
|
||||
|
||||
var command;
|
||||
|
||||
if (that.category.save() != '') {
|
||||
if (that.category) {
|
||||
command = ipa_command({
|
||||
'method': that.entity_name+'_mod',
|
||||
'args': [pkey],
|
||||
@@ -115,7 +148,7 @@ function ipa_rule_association_table_widget(spec) {
|
||||
'on_success': function() {
|
||||
var record = {};
|
||||
record[that.category.name] = [''];
|
||||
that.category.load(['']);
|
||||
that.category.load(record);
|
||||
}
|
||||
});
|
||||
command.set_option(that.category.name, '');
|
||||
|
||||
@@ -633,6 +633,38 @@ function ipa_sudorule_details_command_section(spec){
|
||||
field.create(table_span);
|
||||
};
|
||||
|
||||
that.setup = function(container) {
|
||||
|
||||
that.section_setup(container);
|
||||
|
||||
function update_tables(value) {
|
||||
|
||||
var enabled = '' == value;
|
||||
|
||||
var field = that.get_field('memberallowcmd_sudocmd');
|
||||
field.set_enabled(enabled);
|
||||
|
||||
field = that.get_field('memberallowcmd_sudocmdgroup');
|
||||
field.set_enabled(enabled);
|
||||
}
|
||||
|
||||
var cmdcategory = that.get_field('cmdcategory');
|
||||
cmdcategory.reset = function() {
|
||||
cmdcategory.widget_reset();
|
||||
var values = cmdcategory.save();
|
||||
if (values.length == 0) return;
|
||||
var value = values[0];
|
||||
update_tables(value);
|
||||
};
|
||||
|
||||
var inputs = $('input[name=cmdcategory]', container);
|
||||
inputs.change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
update_tables(value);
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
@@ -769,6 +801,62 @@ function ipa_sudorule_details_runas_section(spec){
|
||||
field.create(table_span);
|
||||
};
|
||||
|
||||
that.setup = function(container) {
|
||||
|
||||
that.section_setup(container);
|
||||
|
||||
function user_update_tables(value) {
|
||||
|
||||
var enabled = '' == value;
|
||||
|
||||
var field = that.get_field('ipasudorunas_user');
|
||||
field.set_enabled(enabled);
|
||||
|
||||
field = that.get_field('ipasudorunas_group');
|
||||
field.set_enabled(enabled);
|
||||
}
|
||||
|
||||
var user_category = that.get_field('ipasudorunasusercategory');
|
||||
user_category.reset = function() {
|
||||
user_category.widget_reset();
|
||||
var values = user_category.save();
|
||||
if (values.length == 0) return;
|
||||
var value = values[0];
|
||||
user_update_tables(value);
|
||||
};
|
||||
|
||||
var user_inputs = $('input[name=ipasudorunasusercategory]', container);
|
||||
user_inputs.change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
user_update_tables(value);
|
||||
});
|
||||
|
||||
function group_update_tables(value) {
|
||||
|
||||
var enabled = '' == value;
|
||||
|
||||
var field = that.get_field('ipasudorunasgroup_group');
|
||||
field.set_enabled(enabled);
|
||||
}
|
||||
|
||||
var group_category = that.get_field('ipasudorunasgroupcategory');
|
||||
group_category.reset = function() {
|
||||
group_category.widget_reset();
|
||||
var values = group_category.save();
|
||||
if (values.length == 0) return;
|
||||
var value = values[0];
|
||||
group_update_tables(value);
|
||||
};
|
||||
|
||||
var group_inputs = $('input[name=ipasudorunasgroupcategory]', container);
|
||||
group_inputs.change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
group_update_tables(value);
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
@@ -985,7 +1073,7 @@ function ipa_sudorule_command_table_widget(spec) {
|
||||
|
||||
var command;
|
||||
|
||||
if (that.category && that.category.save() == 'all') {
|
||||
if (that.category) {
|
||||
command = ipa_command({
|
||||
'method': that.entity_name+'_mod',
|
||||
'args': [pkey],
|
||||
@@ -993,7 +1081,7 @@ function ipa_sudorule_command_table_widget(spec) {
|
||||
'on_success': function() {
|
||||
var record = {};
|
||||
record[that.category.name] = [''];
|
||||
that.category.load(['']);
|
||||
that.category.load(record);
|
||||
}
|
||||
});
|
||||
command.set_option(that.category.name, '');
|
||||
|
||||
@@ -155,7 +155,8 @@ function ipa_widget(spec) {
|
||||
error_link.css('display', 'none');
|
||||
};
|
||||
|
||||
|
||||
that.set_enabled = function() {
|
||||
};
|
||||
|
||||
that.refresh = function() {
|
||||
};
|
||||
@@ -164,6 +165,7 @@ function ipa_widget(spec) {
|
||||
that.widget_init = that.init;
|
||||
that.widget_create = that.create;
|
||||
that.widget_setup = that.setup;
|
||||
that.widget_reset = that.reset;
|
||||
|
||||
return that;
|
||||
}
|
||||
@@ -795,6 +797,14 @@ function ipa_table_widget(spec) {
|
||||
return rows;
|
||||
};
|
||||
|
||||
that.set_enabled = function(enabled) {
|
||||
if (enabled) {
|
||||
$('input[name="select"]', that.table).attr('disabled', false);
|
||||
} else {
|
||||
$('input[name="select"]', that.table).attr('disabled', true);
|
||||
}
|
||||
};
|
||||
|
||||
that.refresh = function() {
|
||||
|
||||
function on_success(data, text_status, xhr) {
|
||||
@@ -822,6 +832,7 @@ function ipa_table_widget(spec) {
|
||||
that.table_init = that.init;
|
||||
that.table_create = that.create;
|
||||
that.table_setup = that.setup;
|
||||
that.table_set_enabled = that.set_enabled;
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user