webui: do not use dom for getting selected automount keys

Old implementation crawled DOM for gathering data from DOM. Such code
is very error prone. Little visual change somewhere else can break it
- as happened in main patch for #4217.

prerequisite for:
https://fedorahosted.org/freeipa/ticket/4217

Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
This commit is contained in:
Petr Vobornik 2014-03-13 17:34:42 +01:00
parent fddb2212bc
commit ffab72cc79
2 changed files with 14 additions and 9 deletions

View File

@ -337,16 +337,20 @@ IPA.automount.key_search_facet = function(spec) {
that.get_selected_values = function() {
var values = [];
var keys = that.table.get_selected_values();
var records = that.table.records;
$('input[name="description"]:checked', that.table.tbody).each(function() {
var value = {};
$('div', $(this).parent().parent()).each(function() {
var div = $(this);
var name = div.attr('name');
value[name] = div.text();
});
values.push(value);
});
if (keys.length === 0 || !records) return values;
for (var i=0,l=records.length; i<l; i++) {
var record = records[i];
if (keys.indexOf(record.description[0]) > -1) {
values.push({
automountkey: record.automountkey[0],
automountinformation: record.automountinformation[0]
});
}
}
return values;
};

View File

@ -1827,6 +1827,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
*/
that.load_records = function(records) {
that.table.empty();
that.table.records = records;
for (var i=0; i<records.length; i++) {
that.add_record(records[i]);
}