summaryrefslogtreecommitdiffstats
path: root/install/ui/add.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-09-10 11:54:02 -0500
committerEndi S. Dewata <edewata@redhat.com>2011-09-23 13:13:10 +0000
commit390d017e321fd5ed56af094cf1f1c74f64e95735 (patch)
treeea90b38f292170059dd757f59ef6b757c5b9b5a5 /install/ui/add.js
parenta90e50cdf759a1b436381f0e9e91caf2d4288636 (diff)
downloadfreeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.tar.gz
freeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.tar.xz
freeipa-390d017e321fd5ed56af094cf1f1c74f64e95735.zip
Modified dialog to use sections.
The IPA.dialog has been modified to store sections instead of fields. If there is no sections specified, it will create a default section. The adder dialog for automount map has been modified such that the fields related to indirect map are stored in a section which will only be visible when the map type is set to indirect. The adder dialog for host has been modified such that it uses a custom section for hostname and DNS zone and standard section for the other fields. Ticket #1394
Diffstat (limited to 'install/ui/add.js')
-rw-r--r--install/ui/add.js69
1 files changed, 24 insertions, 45 deletions
diff --git a/install/ui/add.js b/install/ui/add.js
index b4f1228f0..21707df13 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -46,9 +46,8 @@ IPA.add_dialog = function (spec) {
that.show_edit_page = spec.show_edit_page || show_edit_page;
- that.add = function(record, on_success, on_error) {
+ that.add = function(on_success, on_error) {
- var field, value, pkey_prefix;
var pkey_name = that.entity.metadata.primary_key;
var command = IPA.command({
@@ -60,46 +59,36 @@ IPA.add_dialog = function (spec) {
});
that.command = command;
- pkey_prefix = that.entity.get_primary_key_prefix();
+ command.add_args(that.entity.get_primary_key_prefix());
- for (var h=0; h<pkey_prefix.length; h++) {
- command.add_arg(pkey_prefix[h]);
- }
+ var record = {};
+ that.save(record);
- var fields = that.fields.values;
+ var fields = that.get_fields();
for (var i=0; i<fields.length; i++) {
fields[i].validate();
}
- var required_fields_filled = true;
- for (i=0; i<fields.length; i++) {
- field = fields[i];
- if (!field.valid) return;
- required_fields_filled = field.check_required() &&
- required_fields_filled;
+ var valid = true;
- value = record[field.name];
- if (!value) continue;
+ var sections = that.sections.values;
+ for (i=0; i<sections.length; i++) {
+ var section = sections[i];
- if (field.name == pkey_name) {
- command.add_arg(value);
- } else {
- command.set_option(field.name, value);
+ if (!section.is_valid() || !valid) {
+ valid = false;
+ continue;
}
- }
-
- 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++) {
- field = section_fields[k];
- if (!field.valid) return;
- required_fields_filled = field.check_required() &&
- required_fields_filled;
+ for (var j=0; j<section_fields.length; j++) {
+ var field = section_fields[j];
- value = record[field.name];
+ var values = record[field.name];
+ if (!values) continue;
+
+ // TODO: Handle multi-valued attributes like in detail facet's update()
+ var value = values.join(',');
if (!value) continue;
if (field.name == pkey_name) {
@@ -110,23 +99,20 @@ IPA.add_dialog = function (spec) {
}
}
+ if (!valid) return;
+
//alert(JSON.stringify(command.to_json()));
- if (that.pre_execute_hook){
+ if (that.pre_execute_hook) {
that.pre_execute_hook(command);
}
- if (required_fields_filled){
- command.execute();
- }
+ command.execute();
};
/*dialog initialization*/
that.add_button(IPA.messages.buttons.add, function() {
- var record = {};
- that.save(record);
that.add(
- record,
function(data, text_status, xhr) {
var facet = IPA.current_entity.get_facet();
var table = facet.table;
@@ -137,10 +123,7 @@ IPA.add_dialog = function (spec) {
});
that.add_button(IPA.messages.buttons.add_and_add_another, function() {
- var record = {};
- that.save(record);
that.add(
- record,
function(data, text_status, xhr) {
var facet = IPA.current_entity.get_facet();
var table = facet.table;
@@ -151,14 +134,11 @@ IPA.add_dialog = function (spec) {
});
that.add_button(IPA.messages.buttons.add_and_edit, function() {
- var record = {};
- that.save(record);
that.add(
- record,
function(data, text_status, xhr) {
that.close();
var result = data.result.result;
- that.show_edit_page(that.entity,result);
+ that.show_edit_page(that.entity, result);
},
that.on_error);
});
@@ -167,7 +147,6 @@ IPA.add_dialog = function (spec) {
that.close();
});
-
return that;
};