Fixed duplicate entries in enrollment dialog.

The IPA.association_adder_dialog has been modified not to show
search results that are already selected to prevent duplicates.

Ticket #1859
This commit is contained in:
Endi S. Dewata 2011-09-26 13:44:22 -05:00
parent 8cf8870d3d
commit a2a42c3be8
2 changed files with 27 additions and 50 deletions

View File

@ -177,16 +177,19 @@ IPA.association_adder_dialog = function(spec) {
var other_entity = IPA.get_entity(that.other_entity);
var pkey_attr = other_entity.metadata.primary_key;
var selected = that.get_selected_values();
var results = data.result;
for (var i=0; i<results.count; i++) {
var result = results.result[i];
var pkey = result[pkey_attr][0];
if (that.exclude.indexOf(pkey) < 0) {
if (that.exclude.indexOf(pkey) >= 0) continue;
if (selected.indexOf(pkey) >= 0) continue;
that.add_available_value(result);
}
}
}
var options = { all: true };
var relationships = IPA.metadata.objects[that.other_entity].relationships;

View File

@ -314,10 +314,13 @@ IPA.adder_dialog = function(spec) {
top_panel.append(' ');
$('<input/>', {
type: 'button',
that.find_button = IPA.button({
name: 'find',
value: IPA.messages.buttons.find
label: IPA.messages.buttons.find,
click: function() {
that.search();
return false;
}
}).appendTo(top_panel);
top_panel.append(IPA.create_network_spinner());
@ -370,54 +373,26 @@ IPA.adder_dialog = function(spec) {
}).appendTo(container);
var p = $('<p/>').appendTo(buttons_panel);
$('<input />', {
type: 'button',
name: 'add',
value: '>>'
}).appendTo(p);
p = $('<p/>').appendTo(buttons_panel);
$('<input />', {
type: 'button',
name: 'remove',
value: '<<'
}).appendTo(p);
that.filter_field = $('input[name=filter]', that.container);
var button = $('input[name=find]', that.container);
that.find_button = IPA.button({
name: 'find',
'label': button.val(),
'click': function() {
that.search();
return false;
}
});
button.replaceWith(that.find_button);
button = $('input[name=remove]', that.container);
that.remove_button = IPA.button({
name: 'remove',
'label': button.val(),
'click': function() {
that.remove();
return false;
}
});
button.replaceWith(that.remove_button);
button = $('input[name=add]', that.container);
that.add_button = IPA.button({
name: 'add',
'label': button.val(),
'click': function() {
label: '>>',
click: function() {
that.add();
return false;
}
});
button.replaceWith(that.add_button);
}).appendTo(p);
p = $('<p/>').appendTo(buttons_panel);
that.remove_button = IPA.button({
name: 'remove',
label: '<<',
click: function() {
that.remove();
return false;
}
}).appendTo(p);
that.filter_field = $('input[name=filter]', that.container);
if (that.external) {
container.addClass('adder-dialog-with-external');
@ -440,7 +415,6 @@ IPA.adder_dialog = function(spec) {
type: 'text',
name: 'external'
}).appendTo(external_content);
}
that.search();