summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/ui/add.js5
-rw-r--r--install/ui/details.js119
-rw-r--r--install/ui/dialog.js36
-rw-r--r--install/ui/hbac.js42
-rw-r--r--install/ui/ipa.js9
-rw-r--r--install/ui/sudo.js35
-rw-r--r--install/ui/test/details_tests.js10
7 files changed, 143 insertions, 113 deletions
diff --git a/install/ui/add.js b/install/ui/add.js
index 0df0db612..73a423f00 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -128,8 +128,9 @@ IPA.add_dialog = function (spec) {
}
}
- for (var j=0; j<that.sections.length; j++) {
- var section = that.sections[j];
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ var section = sections[j];
var section_fields = section.fields.values;
for (var k=0; k<section_fields.length; k++) {
diff --git a/install/ui/details.js b/install/ui/details.js
index 4aa864fed..fbf2ff52d 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -269,7 +269,7 @@ IPA.details_facet = function(spec) {
that.label = (IPA.messages && IPA.messages.facets && IPA.messages.facets.details) || spec.label;
that.facet_group = spec.facet_group || 'settings';
- that.sections = [];
+ that.sections = $.ordered_map();
that.__defineGetter__("entity_name", function(){
return that._entity_name;
@@ -278,14 +278,15 @@ IPA.details_facet = function(spec) {
that.__defineSetter__("entity_name", function(entity_name){
that._entity_name = entity_name;
- for (var i=0; i<that.sections.length; i++) {
- that.sections[i].entity_name = entity_name;
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ sections[i].entity_name = entity_name;
}
});
that.add_section = function(section) {
section.entity_name = that.entity_name;
- that.sections.push(section);
+ that.sections.put(section.name, section);
return section;
};
@@ -304,8 +305,9 @@ IPA.details_facet = function(spec) {
that.facet_init();
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
section.init();
}
};
@@ -375,8 +377,9 @@ IPA.details_facet = function(spec) {
that.expand_button.css('display', 'none');
that.collapse_button.css('display', 'inline');
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
that.toggle(section, true);
}
@@ -393,8 +396,9 @@ IPA.details_facet = function(spec) {
that.expand_button.css('display', 'inline');
that.collapse_button.css('display', 'none');
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
that.toggle(section, false);
}
@@ -409,8 +413,9 @@ IPA.details_facet = function(spec) {
'name': 'details'
}).appendTo(container);
- for (var i = 0; i < that.sections.length; ++i) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
var header = $('<h2/>', {
name: section.name,
@@ -450,8 +455,9 @@ IPA.details_facet = function(spec) {
var details = $('div[name=details]', that.container);
- for (var i = 0; i < that.sections.length; ++i) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
var div = $('div.details-section[name='+section.name+']', that.container);
@@ -496,8 +502,9 @@ IPA.details_facet = function(spec) {
that.is_dirty = function() {
- for (var i=0; i<that.sections.length; i++) {
- if (that.sections[i].is_dirty()) {
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ if (sections[i].is_dirty()) {
return true;
}
}
@@ -506,16 +513,17 @@ IPA.details_facet = function(spec) {
that.load = function (record) {
that.record = record;
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
section.load(record);
}
};
that.reset = function() {
-
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
section.reset();
}
};
@@ -539,21 +547,35 @@ IPA.details_facet = function(spec) {
on_fail(xhr, text_status, error_thrown);
}
+ var args = that.get_primary_key();
+
+ var command = IPA.command({
+ entity: entity_name,
+ method: 'mod',
+ args: args,
+ options: {
+ all: true,
+ rights: true
+ },
+ on_success: on_success,
+ on_error: on_error
+ });
+
var values;
- var modlist = {'all': true, 'setattr': [], 'addattr': [], 'rights': true};
- var attrs_wo_option = {};
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
- if (section.save){
- section.save(modlist);
+ if (section.save) {
+ section.save(command.options);
continue;
}
var section_fields = section.fields.values;
for (var j=0; j<section_fields.length; j++) {
var field = section_fields[j];
+ if (!field.is_dirty()) continue;
values = field.save();
if (!values) continue;
@@ -562,41 +584,26 @@ IPA.details_facet = function(spec) {
if (param_info) {
if (param_info['primary_key']) continue;
if (values.length === 1) {
- modlist[field.name] = values[0];
- } else if (values.length > 1){
- if (field.join) {
- modlist[field.name] = values.join(',');
- } else {
- modlist[field.name] = values;
- }
- } else if (param_info['multivalue']){
- modlist[field.name] = [];
+ command.set_option(field.name, values[0]);
+ } else if (field.join) {
+ command.set_option(field.name, values.join(','));
+ } else {
+ command.set_option(field.name, values);
}
+
} else {
- if (values.length) attrs_wo_option[field.name] = values;
+ if (values.length) {
+ command.add_option('setattr', field.name+'='+values[0]);
+ } else {
+ command.add_option('setattr', field.name+'=');
+ }
+ for (var k=1; k<values.length; k++) {
+ command.add_option('addattr', field.name+'='+values[k]);
+ }
}
}
}
- for (var attr in attrs_wo_option) {
- values = attrs_wo_option[attr];
- modlist['setattr'].push(attr + '=' + values[0]);
- for (var k = 1; k < values.length; ++k){
- modlist['addattr'].push(attr + '=' + values[k]);
- }
- }
-
- var args = that.get_primary_key();
-
- var command = IPA.command({
- entity: entity_name,
- method: 'mod',
- args: args,
- options: modlist,
- on_success: on_success,
- on_error: on_error
- });
-
//alert(JSON.stringify(command.to_json()));
command.execute();
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 9cba47fdd..4f93760bf 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -41,8 +41,7 @@ IPA.dialog = function(spec) {
that.buttons = {};
that.fields = $.ordered_map();
-
- that.sections = [];
+ that.sections = $.ordered_map();
that.__defineGetter__("entity_name", function(){
return that._entity_name;
@@ -56,8 +55,9 @@ IPA.dialog = function(spec) {
fields[i].entity_name = entity_name;
}
- for (var j=0; j<that.sections.length; j++) {
- that.sections[j].entity_name = entity_name;
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ sections[j].entity_name = entity_name;
}
});
@@ -97,7 +97,7 @@ IPA.dialog = function(spec) {
};
that.add_section = function(section) {
- that.sections.push(section);
+ that.sections.put(section.name, section);
return that;
};
@@ -123,8 +123,9 @@ IPA.dialog = function(spec) {
field.init();
}
- for (var j=0; j<that.sections.length; j++) {
- var section = that.sections[j];
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ var section = sections[j];
section.entity_name = that.entity_name;
section.init();
}
@@ -158,8 +159,9 @@ IPA.dialog = function(spec) {
field.create(span);
}
- for (var j=0; j<that.sections.length; j++) {
- var section = that.sections[j];
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ var section = sections[j];
var div = $('<div/>', {
name: section.name,
@@ -182,8 +184,9 @@ IPA.dialog = function(spec) {
field.setup(span);
}
- for (var j=0; j<that.sections.length; j++) {
- var section = that.sections[j];
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ var section = sections[j];
var div = $('div.details-section[name='+section.name+']',
that.container);
@@ -251,8 +254,9 @@ IPA.dialog = function(spec) {
record[field.name] = values.join(',');
}
- for (var j=0; j<that.sections.length; j++) {
- var section = that.sections[j];
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ var section = sections[j];
if (section.save) {
section.save(record);
@@ -271,8 +275,10 @@ IPA.dialog = function(spec) {
var field = fields[i];
field.reset();
}
- for (var j=0; j<that.sections.length; j++) {
- that.sections[j].reset();
+
+ var sections = that.sections.values;
+ for (var j=0; j<sections.length; j++) {
+ sections[j].reset();
}
};
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 4d46a18f5..64881a457 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -431,12 +431,14 @@ IPA.hbacrule_details_facet = function (spec) {
})
};
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
var section_fields = section.fields.values;
for (var j=0; j<section_fields.length; j++) {
var field = section_fields[j];
+ if (!field.is_dirty()) continue;
var values = field.save();
if (!values) continue;
@@ -486,23 +488,26 @@ IPA.hbacrule_details_facet = function (spec) {
}
}
- // use setattr/addattr if param_info not available
- if (!param_info) {
- for (var l=0; l<values.length; l++) {
- modify_operation.command.set_option(
- l === 0 ? 'setattr' : 'addattr',
- field.name+'='+values[l]);
- modify_operation.execute = true;
+ if (param_info) {
+ if (values.length == 1) {
+ modify_operation.command.set_option(field.name, values[0]);
+ } else if (field.join) {
+ modify_operation.command.set_option(field.name, values.join(','));
+ } else {
+ modify_operation.command.set_option(field.name, values);
}
- continue;
- }
- // set modify options
- if (values.length == 1) {
- modify_operation.command.set_option(field.name, values[0]);
} else {
- modify_operation.command.set_option(field.name, values);
+ if (values.length) {
+ modify_operation.command.set_option('setattr', field.name+'='+values[0]);
+ } else {
+ modify_operation.command.set_option('setattr', field.name+'=');
+ }
+ for (var l=1; l<values.length; l++) {
+ modify_operation.command.set_option('addattr', field.name+'='+values[l]);
+ }
}
+
modify_operation.execute = true;
}
}
@@ -538,13 +543,6 @@ IPA.hbacrule_details_facet = function (spec) {
batch.execute();
};
- that.reset = function() {
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
- section.reset();
- }
- };
-
return that;
};
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 7fd784b54..9f75f4936 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -214,6 +214,15 @@ IPA.command = function(spec) {
that.options[name] = value;
};
+ that.add_option = function(name, value) {
+ var values = that.options[name];
+ if (!values) {
+ values = [];
+ that.options[name] = values;
+ }
+ values.push(value);
+ };
+
that.get_option = function(name) {
return that.options[name];
};
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 89b7101bd..38075f9b0 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -447,12 +447,14 @@ IPA.sudorule_details_facet = function (spec) {
})
};
- for (var i=0; i<that.sections.length; i++) {
- var section = that.sections[i];
+ var sections = that.sections.values;
+ for (var i=0; i<sections.length; i++) {
+ var section = sections[i];
var section_fields = section.fields.values;
for (var j=0; j<section_fields.length; j++) {
var field = section_fields[j];
+ if (!field.is_dirty()) continue;
var values = field.save();
if (!values) continue;
@@ -490,23 +492,26 @@ IPA.sudorule_details_facet = function (spec) {
categories[field.name].remove_values = true;
}
- // use setattr/addattr if param_info not available
- if (!param_info) {
- for (var k=0; k<values.length; k++) {
- modify_operation.command.set_option(
- k === 0 ? 'setattr' : 'addattr',
- field.name+'='+values[k]);
- modify_operation.execute = true;
+ if (param_info) {
+ if (values.length == 1) {
+ modify_operation.command.set_option(field.name, values[0]);
+ } else if (field.join) {
+ modify_operation.command.set_option(field.name, values.join(','));
+ } else {
+ modify_operation.command.set_option(field.name, values);
}
- continue;
- }
- // set modify options
- if (values.length == 1) {
- modify_operation.command.set_option(field.name, values[0]);
} else {
- modify_operation.command.set_option(field.name, values);
+ if (values.length) {
+ modify_operation.command.set_option('setattr', field.name+'='+values[0]);
+ } else {
+ modify_operation.command.set_option('setattr', field.name+'=');
+ }
+ for (var k=1; k<values.length; k++) {
+ modify_operation.command.set_option('addattr', field.name+'='+values[k]);
+ }
}
+
modify_operation.execute = true;
}
}
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 1c8d7ef80..dc84dc020 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -128,7 +128,7 @@ test("Testing details lifecycle: create, setup, load.", function(){
}).execute();
var setup_called = false;
- var save_called= false;
+ var save_called = false;
var load_called = false;
var load_success_called = false;
@@ -149,8 +149,8 @@ test("Testing details lifecycle: create, setup, load.", function(){
load_called = true;
}
- function test_widget(){
- var widget = IPA.widget({name: 'cn'});
+ function test_widget(spec){
+ var widget = IPA.widget(spec);
widget.setup = function(container) {
setup_called = true;
@@ -244,6 +244,10 @@ test("Testing details lifecycle: create, setup, load.", function(){
ok (load_called, 'load manager called');
+ var section = facet.sections.get('contact');
+ var field = section.fields.get('test');
+ field.set_dirty(true);
+
facet.update(
function(){update_success_called = true},
function(){update_failure_called = true}