diff --git a/install/ui/association.js b/install/ui/association.js index a9a2b50a0..664c80e21 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -144,17 +144,9 @@ IPA.bulk_associator = function(spec) { /** * This dialog is used for adding associations between two entities. */ -IPA.association_adder_dialog = function (spec) { +IPA.association_adder_dialog = function(spec) { spec = spec || {}; - /* - TODO: columns map in IPA.adder_dialog should be removed and add_column() - should be modified to add the column directly into the available_table - and selected_table. This way IPA.association_adder_dialog can call - create_column() from the initialization area, no need to modify the - parameters. - */ - default_columns(spec); var that = IPA.adder_dialog(spec); @@ -162,17 +154,35 @@ IPA.association_adder_dialog = function (spec) { that.pkey = spec.pkey; that.other_entity = spec.other_entity; that.attribute_member = spec.attribute_member; + that.exclude = spec.exclude || []; + + var init = function() { + if (!that.get_columns().length) { + var pkey_name = IPA.metadata.objects[spec.other_entity].primary_key; + that.create_column({ + entity: that.entity, + name: pkey_name, + label: IPA.metadata.objects[spec.other_entity].label, + primary_key: true, + width: '600px' + }); + } + }; that.search = function() { function on_success(data, text_status, xhr) { - var results = data.result; + that.clear_available_values(); - var pkey_attr = that.entity.metadata.primary_key; + var other_entity = IPA.get_entity(that.other_entity); + var pkey_attr = other_entity.metadata.primary_key; - for (var i=0; i', { @@ -528,7 +527,6 @@ IPA.adder_dialog = function (spec) { that.search(); }; - that.open = function(container) { that.buttons[IPA.messages.buttons.enroll] = that.execute; @@ -571,13 +569,7 @@ IPA.adder_dialog = function (spec) { return that.selected_table.save(); }; - /*dialog initialization */ - if (spec.columns){ - for (var i =0; i < spec.columns.length; i +=1){ - that.create_column(spec.columns[i]); - } - } - + init(); that.adder_dialog_create = that.create; diff --git a/install/ui/sudo.js b/install/ui/sudo.js index cdd5e50af..23e5f7a24 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -1076,7 +1076,8 @@ IPA.sudorule_association_table_widget = function(spec) { other_entity: that.other_entity, attribute_member: that.attribute_member, entity: that.entity, - external: that.external + external: that.external, + exclude: that.values }); }; @@ -1102,24 +1103,6 @@ IPA.sudo.rule_association_adder_dialog = function(spec) { that.external = spec.external; - - function setup_table(){ - if (!that.columns.length) { - var pkey_name = IPA.metadata.objects[that.other_entity].primary_key; - that.create_column({ - entity: that.entity, - name: pkey_name, - label: IPA.metadata.objects[that.other_entity].label, - primary_key: true, - width: '200px' - }); - } - } - - that.create = function() { - that.adder_dialog_create(); - }; - that.add = function() { var rows = that.available_table.remove_selected_rows(); that.selected_table.add_rows(rows); @@ -1136,7 +1119,5 @@ IPA.sudo.rule_association_adder_dialog = function(spec) { } }; - setup_table(); - return that; };