summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-02-22 09:21:56 +0100
committerPetr Vobornik <pvoborni@redhat.com>2012-02-29 13:01:16 +0100
commit885ffe5a3e2ef4d370c4fffa458ef44fd61c5250 (patch)
tree8e829320177d31ada422dc33c407fe87c865658b /install
parent34f742bec2dec8fd4ade51946cd38b9dea123295 (diff)
downloadfreeipa-885ffe5a3e2ef4d370c4fffa458ef44fd61c5250.tar.gz
freeipa-885ffe5a3e2ef4d370c4fffa458ef44fd61c5250.tar.xz
freeipa-885ffe5a3e2ef4d370c4fffa458ef44fd61c5250.zip
Multiple fields for one attribute
Current implementation has a limitation to have one field per one attribute. This is fine for most cases. For cases where an attribute can have two editor widgets which can be swapped a need for two different types of field may occur. This patch introduces 'param' option which supposes to contain attribute name. If 'param' is not specified it will contain field's name therefore backward compatibility is maintained. This extension allows to have two fields with different name and same param -> two fields get/supply value from/to the same attribute. Needed for: https://fedorahosted.org/freeipa/ticket/2372
Diffstat (limited to 'install')
-rw-r--r--install/ui/add.js6
-rw-r--r--install/ui/details.js16
-rw-r--r--install/ui/field.js11
-rw-r--r--install/ui/rule.js4
-rw-r--r--install/ui/service.js2
5 files changed, 21 insertions, 18 deletions
diff --git a/install/ui/add.js b/install/ui/add.js
index c1031f8b3..9b473ccc2 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -122,17 +122,17 @@ IPA.entity_adder_dialog = function(spec) {
for (var j=0; j<fields.length; j++) {
var field = fields[j];
- var values = record[field.name];
+ var values = record[field.param];
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) {
+ if (field.param === pkey_name) {
command.add_arg(value);
} else {
- command.set_option(field.name, value);
+ command.set_option(field.param, value);
}
}
diff --git a/install/ui/details.js b/install/ui/details.js
index acd498aa0..d68ebd07c 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -493,7 +493,7 @@ IPA.details_facet = function(spec) {
if (only_dirty && !field.is_dirty()) continue;
- var values = record[field.name];
+ var values = record[field.param];
if (require_value && !values) continue;
update_info.append_field(field, values);
@@ -838,23 +838,25 @@ IPA.command_builder = function() {
that.add_field_option = function(command, field, values) {
if (!field || !values) return;
+ var name = field.param;
+
if (field.metadata) {
if (field.metadata.primary_key) return;
if (values.length === 1) {
- command.set_option(field.name, values[0]);
+ command.set_option(name, values[0]);
} else if (field.join) {
- command.set_option(field.name, values.join(','));
+ command.set_option(name, values.join(','));
} else {
- command.set_option(field.name, values);
+ command.set_option(name, values);
}
} else {
if (values.length) {
- command.add_option('setattr', field.name+'='+values[0]);
+ command.add_option('setattr', name+'='+values[0]);
} else {
- command.add_option('setattr', field.name+'=');
+ command.add_option('setattr', name+'=');
}
for (var k=1; k<values.length; k++) {
- command.add_option('addattr', field.name+'='+values[k]);
+ command.add_option('addattr', name+'='+values[k]);
}
}
};
diff --git a/install/ui/field.js b/install/ui/field.js
index e78a4e962..5c10abb64 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -32,6 +32,7 @@ IPA.field = function(spec) {
that.entity = IPA.get_entity(spec.entity);
that.container = null;
that.name = spec.name;
+ that.param = spec.param || spec.name;
that.label = spec.label;
that.tooltip = spec.tooltip;
that.formatter = spec.formatter;
@@ -66,7 +67,7 @@ IPA.field = function(spec) {
var init = function() {
if (!that.metadata && that.entity) {
- that.metadata = IPA.get_entity_param(that.entity.name, that.name);
+ that.metadata = IPA.get_entity_param(that.entity.name, that.param);
}
if (that.metadata) {
if (that.label === undefined) {
@@ -148,7 +149,7 @@ IPA.field = function(spec) {
that.load = function(record) {
that.record = record;
- that.values = that.get_value(record, that.name);
+ that.values = that.get_value(record, that.param);
that.load_writable(record);
@@ -185,7 +186,7 @@ IPA.field = function(spec) {
}
if (record.attributelevelrights) {
- var rights = record.attributelevelrights[that.name];
+ var rights = record.attributelevelrights[that.param];
if (!rights || rights.indexOf('w') < 0) {
that.writable = false;
}
@@ -249,7 +250,7 @@ IPA.field = function(spec) {
}
if(record) {
- record[that.name] = values;
+ record[that.param] = values;
}
return values;
@@ -600,7 +601,7 @@ IPA.sshkeys_field = function(spec) {
that.load = function(record) {
- var keys = that.get_value(record, that.name);
+ var keys = that.get_value(record, that.param);
var fingerprints = that.get_value(record, that.sshfp_attr);
var values = [];
diff --git a/install/ui/rule.js b/install/ui/rule.js
index f2d7c6dd1..2a1648321 100644
--- a/install/ui/rule.js
+++ b/install/ui/rule.js
@@ -170,7 +170,7 @@ IPA.rule_association_table_field = function(spec) {
if (typeof record !== 'object') {
record = {};
- record[that.name] = values[i];
+ record[that.param] = values[i];
}
record[that.external] = external;
@@ -180,7 +180,7 @@ IPA.rule_association_table_field = function(spec) {
};
that.load = function(result) {
- that.values = result[that.name] || [];
+ that.values = result[that.param] || [];
if (that.external) {
that.set_values_external(that.values, '');
diff --git a/install/ui/service.js b/install/ui/service.js
index f60d45550..c86a6d05d 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -347,7 +347,7 @@ IPA.service_provisioning_status_field = function (spec) {
that.load = function(record) {
that.values = {
- value: record[that.name],
+ value: record[that.param],
pkey: record['krbprincipalname'][0]
};