summaryrefslogtreecommitdiffstats
path: root/install/ui
diff options
context:
space:
mode:
Diffstat (limited to 'install/ui')
-rw-r--r--install/ui/Makefile.am1
-rw-r--r--install/ui/add.js10
-rw-r--r--install/ui/associate.js69
-rw-r--r--install/ui/details.js49
-rw-r--r--install/ui/dialog.js59
-rw-r--r--install/ui/dns.js5
-rw-r--r--install/ui/entity.js100
-rw-r--r--install/ui/hbac.js5
-rw-r--r--install/ui/index.html1
-rw-r--r--install/ui/ipa.js22
-rwxr-xr-xinstall/ui/jquery.ordered-map.js68
-rw-r--r--install/ui/jsl.conf2
-rw-r--r--install/ui/search.js5
-rw-r--r--install/ui/sudo.js10
-rwxr-xr-xinstall/ui/test/aci_tests.html1
-rw-r--r--install/ui/test/all_tests.html2
-rw-r--r--install/ui/test/association_tests.html1
-rwxr-xr-xinstall/ui/test/certificate_tests.html1
-rw-r--r--install/ui/test/details_tests.html1
-rw-r--r--install/ui/test/details_tests.js4
-rw-r--r--install/ui/test/entity_tests.html1
-rw-r--r--install/ui/test/index.html1
-rw-r--r--install/ui/test/ipa_tests.html1
-rw-r--r--install/ui/test/navigation_tests.html1
-rwxr-xr-xinstall/ui/test/ordered_map_tests.html21
-rwxr-xr-xinstall/ui/test/ordered_map_tests.js128
-rwxr-xr-xinstall/ui/test/widget_tests.html1
-rw-r--r--install/ui/widget.js47
28 files changed, 427 insertions, 190 deletions
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index b7567749d..5f77b0698 100644
--- a/install/ui/Makefile.am
+++ b/install/ui/Makefile.am
@@ -25,6 +25,7 @@ app_DATA = \
jquery-ui.js \
jquery.ba-bbq.js \
jquery-ui.css \
+ jquery.ordered-map.js \
certificate.js \
entitle.js \
group.js \
diff --git a/install/ui/add.js b/install/ui/add.js
index 7a7bd086b..fcd320edf 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -102,8 +102,9 @@ IPA.add_dialog = function (spec) {
var field, value;
- for (var i=0; i<that.fields.length; i++) {
- field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ field = fields[i];
if (!field.valid) return;
value = record[field.name];
@@ -119,8 +120,9 @@ IPA.add_dialog = function (spec) {
for (var j=0; j<that.sections.length; j++) {
var section = that.sections[j];
- for (var k=0; k<section.fields.length; k++) {
- field = section.fields[k];
+ var section_fields = section.fields.values;
+ for (var k=0; k<section_fields.length; k++) {
+ field = section_fields[k];
if (!field.valid) return;
value = record[field.name];
diff --git a/install/ui/associate.js b/install/ui/associate.js
index 9d04b0c85..6f003418f 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -309,16 +309,14 @@ IPA.association_table_widget = function (spec) {
that.add_method = spec.add_method || 'add_member';
that.remove_method = spec.remove_method || 'remove_member';
- that.adder_columns = [];
- that.adder_columns_by_name = {};
+ that.adder_columns = $.ordered_map();
that.get_adder_column = function(name) {
- return that.adder_columns_by_name[name];
+ return that.adder_columns.get(name);
};
that.add_adder_column = function(column) {
- that.adder_columns.push(column);
- that.adder_columns_by_name[column.name] = column;
+ that.adder_columns.put(column.name, column);
};
that.create_adder_column = function(spec) {
@@ -362,13 +360,15 @@ IPA.association_table_widget = function (spec) {
});
}
- for (var i=0; i<that.columns.length; i++) {
- column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ column = columns[i];
column.entity_name = that.other_entity;
}
- for (var j=0; j<that.adder_columns.length; j++) {
- column = that.adder_columns[j];
+ var adder_columns = that.adder_columns.values;
+ for (var j=0; j<adder_columns.length; j++) {
+ column = adder_columns[j];
column.entity_name = that.other_entity;
}
@@ -504,8 +504,9 @@ IPA.association_table_widget = function (spec) {
that.empty();
- if (that.columns.length == 1) { // show pkey only
- var name = that.columns[0].name;
+ var columns = that.columns.values;
+ if (columns.length == 1) { // show pkey only
+ var name = columns[0].name;
for (var i=0; i<that.values.length; i++) {
var record = {};
record[name] = that.values[i];
@@ -548,8 +549,9 @@ IPA.association_table_widget = function (spec) {
var dialog = that.create_add_dialog();
- if (that.adder_columns.length) {
- dialog.set_columns(that.adder_columns);
+ var columns = that.adder_columns.values;
+ if (columns.length) {
+ dialog.set_columns(columns);
}
dialog.execute = function() {
@@ -674,19 +676,15 @@ IPA.association_facet = function (spec) {
that.add_method = spec.add_method || 'add_member';
that.remove_method = spec.remove_method || 'remove_member';
- that.columns = [];
- that.columns_by_name = {};
-
- that.adder_columns = [];
- that.adder_columns_by_name = {};
+ that.columns = $.ordered_map();
+ that.adder_columns = $.ordered_map();
that.get_column = function(name) {
- return that.columns_by_name[name];
+ return that.columns.get(name);
};
that.add_column = function(column) {
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
+ that.columns.put(column.name, column);
};
that.create_column = function(spec) {
@@ -699,12 +697,11 @@ IPA.association_facet = function (spec) {
};
that.get_adder_column = function(name) {
- return that.adder_columns_by_name[name];
+ return that.adder_columns.get(name);
};
that.add_adder_column = function(column) {
- that.adder_columns.push(column);
- that.adder_columns_by_name[column.name] = column;
+ that.adder_columns.put(column.name, column);
};
that.create_adder_column = function(spec) {
@@ -744,8 +741,9 @@ IPA.association_facet = function (spec) {
other_entity: that.other_entity
});
- if (that.columns.length) {
- that.table.set_columns(that.columns);
+ var columns = that.columns.values;
+ if (columns.length) {
+ that.table.set_columns(columns);
} else {
@@ -774,13 +772,14 @@ IPA.association_facet = function (spec) {
};
}
- for (i=0; i<that.columns.length; i++) {
- column = that.columns[i];
+ for (i=0; i<columns.length; i++) {
+ column = columns[i];
column.entity_name = that.other_entity;
}
- for (i=0; i<that.adder_columns.length; i++) {
- column = that.adder_columns[i];
+ var adder_columns = that.adder_columns.values;
+ for (i=0; i<adder_columns.length; i++) {
+ column = adder_columns[i];
column.entity_name = that.other_entity;
}
@@ -871,8 +870,9 @@ IPA.association_facet = function (spec) {
'attribute_member': that.attribute_member
});
- if (that.adder_columns.length) {
- dialog.set_columns(that.adder_columns);
+ var adder_columns = that.adder_columns.values;
+ if (adder_columns.length) {
+ dialog.set_columns(adder_columns);
}
dialog.execute = function() {
@@ -995,8 +995,9 @@ IPA.association_facet = function (spec) {
var pkeys = data.result.result[that.name];
if (!pkeys) return;
- if (that.table.columns.length == 1) { // show pkey only
- var name = that.table.columns[0].name;
+ var columns = that.table.columns.values;
+ if (columns.length == 1) { // show pkey only
+ var name = columns[0].name;
for (var i=0; i<pkeys.length; i++) {
var record = {};
record[name] = pkeys[i];
diff --git a/install/ui/details.js b/install/ui/details.js
index e8033b306..657d3bc30 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -40,8 +40,7 @@ IPA.details_section = function(spec) {
that.template = spec.template;
that._entity_name = spec.entity_name;
- that.fields = [];
- that.fields_by_name = {};
+ that.fields = $.ordered_map();
that.__defineGetter__('entity_name', function() {
return that._entity_name;
@@ -50,19 +49,19 @@ IPA.details_section = function(spec) {
that.__defineSetter__('entity_name', function(entity_name) {
that._entity_name = entity_name;
- for (var i=0; i<that.fields.length; i++) {
- that.fields[i].entity_name = entity_name;
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ fields[i].entity_name = entity_name;
}
});
that.get_field = function(name) {
- return that.fields_by_name[name];
+ return that.fields.get(name);
};
that.add_field = function(field) {
field.entity_name = that.entity_name;
- that.fields.push(field);
- that.fields_by_name[field.name] = field;
+ that.fields.put(field.name, field);
return field;
};
@@ -97,8 +96,9 @@ IPA.details_section = function(spec) {
};
that.init = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
field.init();
}
};
@@ -107,8 +107,8 @@ IPA.details_section = function(spec) {
if (that.template) return;
- var fields = that.fields;
- for (var i = 0; i < fields.length; ++i) {
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
var field = fields[i];
var span = $('<span/>', { 'name': field.name }).appendTo(container);
@@ -122,8 +122,8 @@ IPA.details_section = function(spec) {
if (that.template) return;
- var fields = that.fields;
- for (var i = 0; i < fields.length; ++i) {
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
var field = fields[i];
var span = $('span[name='+field.name+']', this.container).first();
@@ -135,14 +135,14 @@ IPA.details_section = function(spec) {
that.record = record;
- var fields = that.fields;
+ var fields = that.fields.values;
if (that.template) {
var template = IPA.get_template(that.template);
this.container.load(
template,
function(data, text_status, xhr) {
- for (var i = 0; i < fields.length; ++i) {
+ for (var i=0; i<fields.length; i++) {
var field = fields[i];
var span = $('span[name='+field.name+']', this.container).first();
field.setup(span);
@@ -161,16 +161,18 @@ IPA.details_section = function(spec) {
};
that.reset = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
var span = $('span[name='+field.name+']', this.container).first();
field.reset();
}
};
that.is_dirty = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
if (field.is_dirty()) {
return true;
}
@@ -234,8 +236,8 @@ IPA.details_list_section = function(spec) {
'class': 'entryattrs'
}).appendTo(container);
- var fields = that.fields;
- for (var i = 0; i < fields.length; ++i) {
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
var field = fields[i];
var label = field.label || '';
@@ -539,8 +541,9 @@ IPA.details_facet = function(spec) {
continue;
}
- for (var j=0; j<section.fields.length; j++) {
- var field = section.fields[j];
+ var section_fields = section.fields.values;
+ for (var j=0; j<section_fields.length; j++) {
+ var field = section_fields[j];
var span = $('span[name='+field.name+']', section.container).first();
values = field.save();
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 2c9fdb0e2..9cba47fdd 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -40,8 +40,7 @@ IPA.dialog = function(spec) {
that.buttons = {};
- that.fields = [];
- that.fields_by_name = {};
+ that.fields = $.ordered_map();
that.sections = [];
@@ -52,8 +51,9 @@ IPA.dialog = function(spec) {
that.__defineSetter__("entity_name", function(entity_name){
that._entity_name = entity_name;
- for (var i=0; i<that.fields.length; i++) {
- that.fields[i].entity_name = entity_name;
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ fields[i].entity_name = entity_name;
}
for (var j=0; j<that.sections.length; j++) {
@@ -66,12 +66,11 @@ IPA.dialog = function(spec) {
};
that.get_field = function(name) {
- return that.fields_by_name[name];
+ return that.fields.get(name);
};
that.add_field = function(field) {
- that.fields.push(field);
- that.fields_by_name[field.name] = field;
+ that.fields.put(field.name, field);
};
that.field = function(field) {
@@ -80,8 +79,9 @@ IPA.dialog = function(spec) {
};
that.is_valid = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
if (!field.valid) return false;
}
return true;
@@ -116,8 +116,9 @@ IPA.dialog = function(spec) {
that.entity = IPA.get_entity(that.entity_name);
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
field.entity_name = that.entity_name;
field.init();
}
@@ -136,8 +137,9 @@ IPA.dialog = function(spec) {
var table = $('<table/>').appendTo(that.container);
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
if (field.hidden) continue;
var tr = $('<tr/>').appendTo(table);
@@ -172,8 +174,9 @@ IPA.dialog = function(spec) {
* Setup behavior
*/
that.setup = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
var span = $('span[name="'+field.name+'"]', that.container);
field.setup(span);
@@ -241,8 +244,9 @@ IPA.dialog = function(spec) {
};
that.save = function(record) {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
var values = field.save();
record[field.name] = values.join(',');
}
@@ -262,8 +266,9 @@ IPA.dialog = function(spec) {
};
that.reset = function() {
- for (var i=0; i<that.fields.length; i++) {
- var field = that.fields[i];
+ var fields = that.fields.values;
+ for (var i=0; i<fields.length; i++) {
+ var field = fields[i];
field.reset();
}
for (var j=0; j<that.sections.length; j++) {
@@ -318,16 +323,14 @@ IPA.adder_dialog = function (spec) {
that.width = spec.width || '600px';
- that.columns = [];
- that.columns_by_name = {};
+ that.columns = $.ordered_map();
that.get_column = function(name) {
- return that.columns_by_name[name];
+ return that.columns.get(name);
};
that.add_column = function(column) {
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
+ that.columns.put(column.name, column);
};
that.set_columns = function(columns) {
@@ -338,8 +341,7 @@ IPA.adder_dialog = function (spec) {
};
that.clear_columns = function() {
- that.columns = [];
- that.columns_by_name = {};
+ that.columns.empty();
};
that.create_column = function(spec) {
@@ -355,7 +357,8 @@ IPA.adder_dialog = function (spec) {
height: '151px'
});
- that.available_table.set_columns(that.columns);
+ var columns = that.columns.values;
+ that.available_table.set_columns(columns);
that.available_table.init();
@@ -365,7 +368,7 @@ IPA.adder_dialog = function (spec) {
height: '151px'
});
- that.selected_table.set_columns(that.columns);
+ that.selected_table.set_columns(columns);
that.selected_table.init();
diff --git a/install/ui/dns.js b/install/ui/dns.js
index e62459afb..b6e6b23d8 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -117,8 +117,9 @@ IPA.records_facet = function(spec) {
entity_name: that.entity_name
});
- for (var i=0; i<that.columns.length; i++) {
- var column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ var column = columns[i];
that.table.add_column(column);
}
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 22d3eaffc..026e66f79 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -37,8 +37,7 @@ IPA.facet = function (spec) {
that.title = spec.title || that.label;
that._entity_name = spec.entity_name;
- that.dialogs = [];
- that.dialogs_by_name = {};
+ that.dialogs = $.ordered_map();
// facet group name
that.facet_group = spec.facet_group;
@@ -52,19 +51,19 @@ IPA.facet = function (spec) {
});
that.get_dialog = function(name) {
- return that.dialogs_by_name[name];
+ return that.dialogs.get(name);
};
that.dialog = function(dialog) {
- that.dialogs.push(dialog);
- that.dialogs_by_name[dialog.name] = dialog;
+ that.dialogs.put(dialog.name, dialog);
return that;
};
that.init = function() {
- for (var i=0; i<that.dialogs.length; i++){
- var dialog = that.dialogs[i];
+ var dialogs = that.dialogs.values;
+ for (var i=0; i<dialogs.length; i++){
+ var dialog = dialogs[i];
dialog.entity_name = that._entity_name;
dialog.init();
}
@@ -148,8 +147,7 @@ IPA.table_facet = function(spec) {
var that = IPA.facet(spec);
- that.columns = [];
- that.columns_by_name = {};
+ that.columns = $.ordered_map();
that.__defineGetter__('entity_name', function() {
return that._entity_name;
@@ -158,23 +156,23 @@ IPA.table_facet = function(spec) {
that.__defineSetter__('entity_name', function(entity_name) {
that._entity_name = entity_name;
- for (var i=0; i<that.columns.length; i++) {
- that.columns[i].entity_name = entity_name;
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ columns[i].entity_name = entity_name;
}
});
that.get_columns = function() {
- return that.columns;
+ return that.columns.values;
};
that.get_column = function(name) {
- return that.columns_by_name[name];
+ return that.columns.get(name);
};
that.add_column = function(column) {
column.entity_name = that.entity_name;
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
+ that.columns.put(column.name, column);
};
that.create_column = function(spec) {
@@ -214,16 +212,14 @@ IPA.facet_group = function(spec) {
that.name = spec.name;
that.label = spec.label;
- that.facets = [];
- that.facets_by_name = {};
+ that.facets = $.ordered_map();
that.add_facet = function(facet) {
- that.facets.push(facet);
- that.facets_by_name[facet.name] = facet;
+ that.facets.put(facet.name, facet);
};
that.get_facet = function(name) {
- return that.facets_by_name[name];
+ return that.facets.get(name);
};
return that;
@@ -240,20 +236,16 @@ IPA.entity = function (spec) {
that.header = spec.header || IPA.entity_header({entity: that});
- that.dialogs = [];
- that.dialogs_by_name = {};
+ that.dialogs = $.ordered_map();
- that.facets = [];
- that.facets_by_name = {};
+ that.facets = $.ordered_map();
+ that.facet_groups = $.ordered_map();
// current facet
that.facet_name = null;
- that.facet_groups = [];
- that.facet_groups_by_name = {};
-
that.get_dialog = function(name) {
- return that.dialogs_by_name[name];
+ return that.dialogs.get(name);
};
that.add_dialog = function(dialog) {
@@ -262,45 +254,43 @@ IPA.entity = function (spec) {
that.dialog = function(dialog) {
dialog.entity_name = that.name;
- that.dialogs.push(dialog);
- that.dialogs_by_name[dialog.name] = dialog;
+ that.dialogs.put(dialog.name, dialog);
return that;
};
that.add_facet_group = function(facet_group) {
- that.facet_groups.push(facet_group);
- that.facet_groups_by_name[facet_group.name] = facet_group;
+ that.facet_groups.put(facet_group.name, facet_group);
};
that.get_facet_group = function(name) {
- return that.facet_groups_by_name[name];
+ return that.facet_groups.get(name);
};
that.remove_facet_groups = function() {
- that.facet_groups = [];
- that.facet_groups_by_name = {};
+ that.facet_groups.empty();
};
that.get_facet = function(name) {
if (name === 'default') {
// return the first facet in the first facet group
- for (var i=0; i<that.facet_groups.length; i++) {
- var facet_group = that.facet_groups[i];
- if (!facet_group.facets.length) continue;
- return facet_group.facets[0];
+ var facet_groups = that.facet_groups.values;
+ for (var i=0; i<facet_groups.length; i++) {
+ var facet_group = facet_groups[i];
+ var facets = facet_group.facets.values;
+ if (!facets.length) continue;
+ return facets[0];
}
- return that.facets[0];
+ return that.facets.values[0];
}
- return that.facets_by_name[name];
+ return that.facets.get(name);
};
that.add_facet = function(facet) {
facet.entity_name = that.name;
- that.facets.push(facet);
- that.facets_by_name[facet.name] = facet;
-
+ that.facets.put(facet.name, facet);
+
if (facet.facet_group) {
var facet_group = that.get_facet_group(facet.facet_group);
if (facet_group) {
@@ -313,14 +303,16 @@ IPA.entity = function (spec) {
that.init = function() {
- for (var i=0; i<that.facets.length; i++) {
- var facet = that.facets[i];
+ var facets = that.facets.values;
+ for (var i=0; i<facets.length; i++) {
+ var facet = facets[i];
facet.entity = that;
facet.init();
}
- for (var j=0; j<that.dialogs.length; j++) {
- that.dialogs[j].init();
+ var dialogs = that.dialogs.values;
+ for (var j=0; j<dialogs.length; j++) {
+ dialogs[j].init();
}
};
@@ -382,8 +374,9 @@ IPA.entity = function (spec) {
IPA.current_facet = function (entity){
var facet_name = $.bbq.getState(entity.name + '-facet', true);
- if (!facet_name && entity.facets.length) {
- facet_name = entity.facets[0].name;
+ var facets = entity.facets.values;
+ if (!facet_name && facets.length) {
+ facet_name = facets[0].name;
}
return facet_name;
};
@@ -526,8 +519,9 @@ IPA.entity_header = function(spec) {
'class': 'facet-tab'
}).appendTo(section);
- for (var i=0; i<facet_group.facets.length; i++) {
- var facet = facet_group.facets[i];
+ var facets = facet_group.facets.values;
+ for (var i=0; i<facets.length; i++) {
+ var facet = facets[i];
that.facet_link(ul, facet);
}
};
@@ -574,7 +568,7 @@ IPA.entity_header = function(spec) {
'class': 'entity-tabs'
}).appendTo(container);
- var facet_groups = that.entity.facet_groups;
+ var facet_groups = that.entity.facet_groups.values;
for (var i=0; i<facet_groups.length; i++) {
var facet_group = facet_groups[i];
if (facet_group.facets.length) {
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 2b5e66545..b078d4286 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -434,8 +434,9 @@ IPA.hbacrule_details_facet = function (spec) {
for (var i=0; i<that.sections.length; i++) {
var section = that.sections[i];
- for (var j=0; j<section.fields.length; j++) {
- var field = section.fields[j];
+ var section_fields = section.fields.values;
+ for (var j=0; j<section_fields.length; j++) {
+ var field = section_fields[j];
var span = $('span[name='+field.name+']', section.container).first();
var values = field.save();
diff --git a/install/ui/index.html b/install/ui/index.html
index 6b17c7e30..af8a1e109 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -8,6 +8,7 @@
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="jquery.ba-bbq.js"></script>
+ <script type="text/javascript" src="jquery.ordered-map.js"></script>
<script type="text/javascript" src="ipa.js"></script>
<script type="text/javascript" src="widget.js"></script>
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index c21c16ec6..f2ffcf1d5 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -1,3 +1,4 @@
+/*jsl:import jquery.ordered-map.js */
/* Authors:
* Pavel Zuna <pzuna@redhat.com>
* Adam Young <ayoung@redhat.com>
@@ -21,6 +22,7 @@
*/
+/* REQUIRES: jquery.ordered-map.js */
/*global $:true, location:true */
var IPA = ( function () {
@@ -47,11 +49,9 @@ var IPA = ( function () {
that.messages = {};
that.whoami = {};
- that.entities = [];
+ that.entities = $.ordered_map();
that.entity_factories = {};
- that.entities_by_name = {};
-
that.layout = $.bbq.getState('layout');
that.layouts_dir = 'layouts';
@@ -127,27 +127,19 @@ var IPA = ( function () {
};
that.get_entities = function() {
- return that.entities;
+ return that.entities.values;
};
that.get_entity = function(name) {
- return that.entities_by_name[name];
+ return that.entities.get(name);
};
that.add_entity = function(entity) {
- that.entities.push(entity);
- that.entities_by_name[entity.name] = entity;
+ that.entities.put(entity.name, entity);
};
that.remove_entity = function(name) {
- for (var i=0; i<that.entities.length; i++) {
- var entity = that.entities[i];
- if (name == entity.name) {
- that.entities.splice(i, 1);
- break;
- }
- }
- delete that.entities_by_name[entity.name];
+ that.entities.remove(name);
};
that.start_entities = function() {
diff --git a/install/ui/jquery.ordered-map.js b/install/ui/jquery.ordered-map.js
new file mode 100755
index 000000000..8602c5571
--- /dev/null
+++ b/install/ui/jquery.ordered-map.js
@@ -0,0 +1,68 @@
+/* Authors:
+ * Endi Dewata <edewata@redhat.com>
+ *
+ * Copyright (C) 2010 Red Hat
+ * see file 'COPYING' for use and warranty information
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+jQuery.ordered_map = jQuery.fn.ordered_map = function() {
+
+ var that = {};
+
+ /**
+ * These variables can be read directly but should not be
+ * modified directly. Use the provided methods instead.
+ */
+ that.keys = [];
+ that.values = [];
+ that.map = {};
+
+ that.__defineGetter__('length', function() {
+ return that.keys.length;
+ });
+
+ that.get = function(key) {
+ return that.map[key];
+ };
+
+ that.put = function(key, value) {
+ that.keys.push(key);
+ that.values.push(value);
+ that.map[key] = value;
+ };
+
+ that.remove = function(key) {
+
+ var i = that.keys.indexOf(key);
+ if (i<0) return null;
+
+ that.keys.splice(i, 1);
+ that.values.splice(i, 1);
+
+ var value = that.map[key];
+ delete that.map[key];
+
+ return value;
+ };
+
+ that.empty = function() {
+ that.keys = [];
+ that.values = [];
+ that.map = {};
+ };
+
+ return that;
+};
diff --git a/install/ui/jsl.conf b/install/ui/jsl.conf
index ed4c892f3..e7d09ec0c 100644
--- a/install/ui/jsl.conf
+++ b/install/ui/jsl.conf
@@ -117,6 +117,7 @@
+define alert
+define $
+define JSON
++define jQuery
### Files
# Specify which files to lint
@@ -124,6 +125,7 @@
# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
# or "+process Folder\Path\*.htm".
#
++process jquery.ordered-map.js
+process ipa.js
+process widget.js
+process dialog.js
diff --git a/install/ui/search.js b/install/ui/search.js
index dad11f1a9..1e2186620 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -67,8 +67,9 @@ IPA.search_facet = function(spec) {
search_all: that.search_all
});
- for (var i=0; i<that.columns.length; i++) {
- var column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ var column = columns[i];
var param_info = IPA.get_entity_param(that.entity_name, column.name);
column.primary_key = param_info && param_info['primary_key'];
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 0f830acaa..e9e978be0 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -450,8 +450,9 @@ IPA.sudorule_details_facet = function (spec) {
for (var i=0; i<that.sections.length; i++) {
var section = that.sections[i];
- for (var j=0; j<section.fields.length; j++) {
- var field = section.fields[j];
+ var section_fields = section.fields.values;
+ for (var j=0; j<section_fields.length; j++) {
+ var field = section_fields[j];
var span = $('span[name='+field.name+']', section.container).first();
var values = field.save();
@@ -1097,7 +1098,8 @@ IPA.sudo.rule_association_adder_dialog = function (spec) {
name: 'available'
});
- that.available_table.set_columns(that.columns);
+ var columns = that.columns.values;
+ that.available_table.set_columns(columns);
that.available_table.init();
@@ -1105,7 +1107,7 @@ IPA.sudo.rule_association_adder_dialog = function (spec) {
name: 'selected'
});
- that.selected_table.set_columns(that.columns);
+ that.selected_table.set_columns(columns);
that.selected_table.init();
diff --git a/install/ui/test/aci_tests.html b/install/ui/test/aci_tests.html
index 0847e1501..be035c413 100755
--- a/install/ui/test/aci_tests.html
+++ b/install/ui/test/aci_tests.html
@@ -10,6 +10,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../widget.js"></script>
<script type="text/javascript" src="../dialog.js"></script>
diff --git a/install/ui/test/all_tests.html b/install/ui/test/all_tests.html
index 1d2c7b300..be0bf3ea1 100644
--- a/install/ui/test/all_tests.html
+++ b/install/ui/test/all_tests.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../widget.js"></script>
<script type="text/javascript" src="../dialog.js"></script>
@@ -18,6 +19,7 @@
<script type="text/javascript" src="../navigation.js"></script>
<script type="text/javascript" src="../certificate.js"></script>
<script type="text/javascript" src="../aci.js"></script>
+ <script type="text/javascript" src="ordered_map_tests.js"></script>
<script type="text/javascript" src="ipa_tests.js"></script>
<script type="text/javascript" src="details_tests.js"></script>
<script type="text/javascript" src="entity_tests.js"></script>
diff --git a/install/ui/test/association_tests.html b/install/ui/test/association_tests.html
index 383c9b0b6..e9e3650ba 100644
--- a/install/ui/test/association_tests.html
+++ b/install/ui/test/association_tests.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../details.js"></script>
<script type="text/javascript" src="../search.js"></script>
diff --git a/install/ui/test/certificate_tests.html b/install/ui/test/certificate_tests.html
index 5b411ff13..dd8ccb6e3 100755
--- a/install/ui/test/certificate_tests.html
+++ b/install/ui/test/certificate_tests.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../details.js"></script>
<script type="text/javascript" src="../search.js"></script>
diff --git a/install/ui/test/details_tests.html b/install/ui/test/details_tests.html
index ee3679b9c..e83e70e24 100644
--- a/install/ui/test/details_tests.html
+++ b/install/ui/test/details_tests.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../widget.js"></script>
<script type="text/javascript" src="../dialog.js"></script>
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 2715b4eac..8f98f1fef 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -62,7 +62,7 @@ test("Testing IPA.details_section.create().", function() {
section.entity_name = 'user';
section.init();
- var fields = section.fields;
+ var fields = section.fields.values;
var container = $("<div/>");
section.create(container);
@@ -264,7 +264,7 @@ test("Testing IPA.details_section_setup again()",function(){
text({name:'cn', label:'Entity Name'}).
text({name:'description', label:'Description'}).
text({name:'number', label:'Entity ID'});
- var fields = section.fields;
+ var fields = section.fields.values;
var container = $("<div title='entity'/>");
var details = $("<div/>");
container.append(details);
diff --git a/install/ui/test/entity_tests.html b/install/ui/test/entity_tests.html
index e512d4380..8b41f8fe9 100644
--- a/install/ui/test/entity_tests.html
+++ b/install/ui/test/entity_tests.html
@@ -6,6 +6,7 @@
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../widget.js"></script>
<script type="text/javascript" src="../dialog.js"></script>
diff --git a/install/ui/test/index.html b/install/ui/test/index.html
index 948cce000..3552cc77e 100644
--- a/install/ui/test/index.html
+++ b/install/ui/test/index.html
@@ -24,6 +24,7 @@
<div id="content">
<a href="all_tests.html">Complete Test Suite</a>
<ul>
+ <li><a href="ordered_map_tests.html">Ordered Map Test Suite</a>
<li><a href="ipa_tests.html">Core Test Suite</a>
<li><a href="entity_tests.html">Entity Test Suite</a>
<li><a href="details_tests.html">Details Test Suite</a>
diff --git a/install/ui/test/ipa_tests.html b/install/ui/test/ipa_tests.html
index 903e71545..8f8ab93ef 100644
--- a/install/ui/test/ipa_tests.html
+++ b/install/ui/test/ipa_tests.html
@@ -9,6 +9,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="ipa_tests.js"></script>
</head>
diff --git a/install/ui/test/navigation_tests.html b/install/ui/test/navigation_tests.html
index 16d095aca..a1a68f7f6 100644
--- a/install/ui/test/navigation_tests.html
+++ b/install/ui/test/navigation_tests.html
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../entity.js"></script>
<script type="text/javascript" src="../navigation.js"></script>
diff --git a/install/ui/test/ordered_map_tests.html b/install/ui/test/ordered_map_tests.html
new file mode 100755
index 000000000..dda669348
--- /dev/null
+++ b/install/ui/test/ordered_map_tests.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Ordered Map Test Suite</title>
+ <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
+ <link rel="stylesheet" type="text/css" href="../jquery-ui.css" />
+
+ <script type="text/javascript" src="qunit.js"></script>
+ <script type="text/javascript" src="../jquery.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
+ <script type="text/javascript" src="ordered_map_tests.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">Ordered Map Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-fixture"></div>
+</body>
+</html>
diff --git a/install/ui/test/ordered_map_tests.js b/install/ui/test/ordered_map_tests.js
new file mode 100755
index 000000000..b708a1283
--- /dev/null
+++ b/install/ui/test/ordered_map_tests.js
@@ -0,0 +1,128 @@
+/* Authors:
+ * Endi Sukma Dewata <edewata@redhat.com>
+ *
+ * Copyright (C) 2010 Red Hat
+ * see file 'COPYING' for use and warranty information
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+module('ordered_map');
+
+test("Testing $.ordered_map constructor.", function() {
+
+ var test = $.ordered_map();
+
+ strictEqual(test.length, 0, "Checking length.");
+ deepEqual(test.keys, [], "Checking keys.");
+ deepEqual(test.values, [], "Checking values.");
+ deepEqual(test.map, {}, "Checking map.");
+});
+
+test("Testing $.ordered_map.put().", function() {
+
+ var test = $.ordered_map();
+
+ var key1 = 'key1';
+ var value1 = 'value1';
+
+ var key2 = 'key2';
+ var value2 = 'value2';
+
+ var map = {};
+ map[key1] = value1;
+ map[key2] = value2;
+
+ test.put(key1, value1);
+ test.put(key2, value2);
+
+ strictEqual(test.length, 2, 'Checking length.');
+ deepEqual(test.keys, [key1, key2], 'Checking keys.');
+ deepEqual(test.values, [value1, value2], 'Checking values.');
+ deepEqual(test.map, map, 'Checking map.');
+});
+
+test("Testing $.ordered_map.get().", function() {
+
+ var test = $.ordered_map();
+
+ var key1 = 'key1';
+ var value1 = 'value1';
+
+ var key2 = 'key2';
+ var value2 = 'value2';
+
+ var map = {};
+ map[key1] = value1;
+ map[key2] = value2;
+
+ test.put(key1, value1);
+ test.put(key2, value2);
+
+ var result1 = test.get(key1);
+ var result2 = test.get(key2);
+
+ strictEqual(test.length, 2, 'Checking length.');
+ deepEqual(test.keys, [key1, key2], 'Checking keys.');
+ deepEqual(test.values, [value1, value2], 'Checking values.');
+ deepEqual(test.map, map, 'Checking map.');
+ strictEqual(result1, value1, 'Checking result 1.');
+ strictEqual(result2, value2, 'Checking result 2.');
+});
+
+test("Testing $.ordered_map.remove().", function() {
+
+ var test = $.ordered_map();
+
+ var key1 = 'key1';
+ var value1 = 'value1';
+
+ var key2 = 'key2';
+ var value2 = 'value2';
+
+ var map = {};
+ map[key2] = value2;
+
+ test.put(key1, value1);
+ test.put(key2, value2);
+
+ var result1 = test.remove(key1);
+
+ strictEqual(test.length, 1, 'Checking length.');
+ deepEqual(test.keys, [key2], 'Checking keys.');
+ deepEqual(test.values, [value2], 'Checking values.');
+ deepEqual(test.map, map, 'Checking map.');
+ strictEqual(result1, value1, 'Checking result.');
+});
+
+test("Testing $.ordered_map.empty().", function() {
+
+ var test = $.ordered_map();
+
+ var key1 = 'key1';
+ var value1 = 'value1';
+
+ var key2 = 'key2';
+ var value2 = 'value2';
+
+ test.put(key1, value1);
+ test.put(key2, value2);
+
+ test.empty();
+
+ strictEqual(test.length, 0, 'Checking length.');
+ deepEqual(test.keys, [], 'Checking keys.');
+ deepEqual(test.values, [], 'Checking values.');
+ deepEqual(test.map, {}, 'Checking map.');
+});
diff --git a/install/ui/test/widget_tests.html b/install/ui/test/widget_tests.html
index e38b44216..e504f6133 100755
--- a/install/ui/test/widget_tests.html
+++ b/install/ui/test/widget_tests.html
@@ -10,6 +10,7 @@
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
<script type="text/javascript" src="../jquery-ui.js"></script>
+ <script type="text/javascript" src="../jquery.ordered-map.js"></script>
<script type="text/javascript" src="../ipa.js"></script>
<script type="text/javascript" src="../widget.js"></script>
diff --git a/install/ui/widget.js b/install/ui/widget.js
index dd2288886..85980acee 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1078,20 +1078,18 @@ IPA.table_widget = function (spec) {
that.scrollable = spec.scrollable;
that.save_values = typeof spec.save_values == 'undefined' ? true : spec.save_values;
- that.columns = [];
- that.columns_by_name = {};
+ that.columns = $.ordered_map();
that.get_columns = function() {
- return that.columns;
+ return that.columns.values;
};
that.get_column = function(name) {
- return that.columns_by_name[name];
+ return that.columns.get(name);
};
that.add_column = function(column) {
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
+ that.columns.put(column.name, column);
};
that.set_columns = function(columns) {
@@ -1102,8 +1100,7 @@ IPA.table_widget = function (spec) {
};
that.clear_columns = function() {
- that.columns = [];
- that.columns_by_name = {};
+ that.columns.empty();
};
that.create_column = function(spec) {
@@ -1115,8 +1112,9 @@ IPA.table_widget = function (spec) {
that.init = function() {
that.widget_init();
- for (var i=0; i<that.columns.length; i++) {
- var column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ var column = columns[i];
column.init();
}
};
@@ -1144,12 +1142,13 @@ IPA.table_widget = function (spec) {
'name': 'select'
}).appendTo(th);
- for (var i=0; i<that.columns.length; i++) {
- var column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++) {
+ var column = columns[i];
th = $('<th/>').appendTo(tr);
- if (that.scrollable && (i == that.columns.length-1)) {
+ if (that.scrollable && (i == columns.length-1)) {
if (column.width) {
var width = parseInt(column.width.substring(0, column.width.length-2),10);
width += 16;
@@ -1168,7 +1167,7 @@ IPA.table_widget = function (spec) {
'html': label
}).appendTo(th);
- if (i == that.columns.length-1) {
+ if (i == columns.length-1) {
$('<span/>', {
'name': 'buttons',
'style': 'float: right;'
@@ -1194,8 +1193,8 @@ IPA.table_widget = function (spec) {
'value': 'user'
}).appendTo(td);
- for (/* var */ i=0; i<that.columns.length; i++) {
- /* var */ column = that.columns[i];
+ for (/* var */ i=0; i<columns.length; i++) {
+ /* var */ column = columns[i];
td = $('<td/>').appendTo(tr);
if (column.width) {
@@ -1211,7 +1210,7 @@ IPA.table_widget = function (spec) {
tr = $('<tr/>').appendTo(tfoot);
- td = $('<td/>', { colspan: that.columns.length+1 }).appendTo(tr);
+ td = $('<td/>', { colspan: columns.length+1 }).appendTo(tr);
$('<span/>', {
'name': 'summary'
@@ -1295,17 +1294,22 @@ IPA.table_widget = function (spec) {
};
that.get_record = function(result, index) {
+
var record = {};
- for (var i=0; i<that.columns.length; i++){
- var name = that.columns[i].name;
+
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++){
+ var name = columns[i].name;
var values = result[name];
if (!values) continue;
+
if (values instanceof Array){
record[name] = values[index];
}else{
record[name] = values;
}
}
+
return record;
};
@@ -1314,8 +1318,9 @@ IPA.table_widget = function (spec) {
var tr = that.row.clone();
tr.appendTo(that.tbody);
- for (var i=0; i<that.columns.length; i++){
- var column = that.columns[i];
+ var columns = that.columns.values;
+ for (var i=0; i<columns.length; i++){
+ var column = columns[i];
var value = record[column.name];
value = value ? value.toString() : '';