summaryrefslogtreecommitdiffstats
path: root/install/ui/association.js
diff options
context:
space:
mode:
Diffstat (limited to 'install/ui/association.js')
-rw-r--r--install/ui/association.js121
1 files changed, 55 insertions, 66 deletions
diff --git a/install/ui/association.js b/install/ui/association.js
index 56a2761c1..b78e1e36b 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -355,88 +355,77 @@ IPA.association_table_widget = function (spec) {
that.table_create(container);
- var buttons = $('span[name=buttons]', container);
-
- $('<input/>', {
- 'type': 'button',
- 'name': 'remove',
- 'value': IPA.messages.buttons.remove
- }).appendTo(buttons);
-
- $('<input/>', {
- 'type': 'button',
- 'name': 'add',
- 'value': IPA.messages.buttons.add
- }).appendTo(buttons);
- };
+ var button = IPA.action_button({
+ name: 'remove',
+ label: IPA.messages.buttons.remove,
+ icon: 'remove-icon',
+ click: function() {
+ that.remove_handler();
+ return false;
+ }
+ }).appendTo(that.buttons);
- that.setup = function(container) {
+ button = IPA.action_button({
+ name: 'add',
+ label: IPA.messages.buttons.add,
+ icon: 'add-icon',
+ click: function() {
+ that.add_handler();
+ return false;
+ }
+ }).appendTo(that.buttons);
+ };
- that.table_setup(container);
+ that.add_handler = function() {
+ if ($(this).hasClass('action-button-disabled')) {
+ return;
+ }
var entity = IPA.get_entity(that.entity_name);
var facet_name = IPA.current_facet(entity);
var facet = entity.get_facet(facet_name);
- var button = $('input[name=remove]', container);
- button.replaceWith(IPA.action_button({
- name: 'remove',
- 'label': button.val(),
- 'icon': 'remove-icon',
- 'click': function() {
- if ($(this).hasClass('action-button-disabled')) {
- return false;
- }
-
- if (facet.is_dirty()) {
- var dialog = IPA.dirty_dialog({
- facet: facet
- });
-
- dialog.callback = function() {
- that.show_remove_dialog();
- };
+ if (facet.is_dirty()) {
+ var dialog = IPA.dirty_dialog({
+ facet: facet
+ });
- dialog.init();
- dialog.open(that.container);
+ dialog.callback = function() {
+ that.show_add_dialog();
+ };
- } else {
- that.show_remove_dialog();
- }
+ dialog.init();
+ dialog.open(that.container);
- return false;
- }
- }));
+ } else {
+ that.show_add_dialog();
+ }
+ };
- button = $('input[name=add]', container);
- button.replaceWith(IPA.action_button({
- name: 'add',
- 'label': button.val(),
- 'icon': 'add-icon',
- 'click': function() {
- if ($(this).hasClass('action-button-disabled')) {
- return false;
- }
+ that.remove_handler = function() {
+ if ($(this).hasClass('action-button-disabled')) {
+ return;
+ }
- if (facet.is_dirty()) {
- var dialog = IPA.dirty_dialog({
- facet: facet
- });
+ var entity = IPA.get_entity(that.entity_name);
+ var facet_name = IPA.current_facet(entity);
+ var facet = entity.get_facet(facet_name);
- dialog.callback = function() {
- that.show_add_dialog();
- };
+ if (facet.is_dirty()) {
+ var dialog = IPA.dirty_dialog({
+ facet: facet
+ });
- dialog.init();
- dialog.open(that.container);
+ dialog.callback = function() {
+ that.show_remove_dialog();
+ };
- } else {
- that.show_add_dialog();
- }
+ dialog.init();
+ dialog.open(that.container);
- return false;
- }
- }));
+ } else {
+ that.show_remove_dialog();
+ }
};
that.set_enabled = function(enabled) {