summaryrefslogtreecommitdiffstats
path: root/install/ui/aci.js
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-02-22 12:53:00 +0100
committerPetr Vobornik <pvoborni@redhat.com>2012-02-29 13:01:22 +0100
commit37cdbae23424b0dd8c6296d0303efdfa3bfffcfd (patch)
treef6112a8b025ff499fe6caf8ed00b7005a10b59af /install/ui/aci.js
parent885ffe5a3e2ef4d370c4fffa458ef44fd61c5250 (diff)
downloadfreeipa-37cdbae23424b0dd8c6296d0303efdfa3bfffcfd.tar.gz
freeipa-37cdbae23424b0dd8c6296d0303efdfa3bfffcfd.tar.xz
freeipa-37cdbae23424b0dd8c6296d0303efdfa3bfffcfd.zip
Added attrs to permission when target is group or filter
Option to set attributes in permission was missing for target 'group' and 'filter'. Attribute_table_widget with type=group is shown for target=group. For target=filter a multivalued textbox is shown. This is because UI can't predict what type will the result of the filter be. In future it can be extended by interactive attribute selector to help user find what he wants to enter. Mutlivalued widget was modified to show undo button for new entries even if show_undo is false. It is useful in adder dialog to indicate that user added something and to enable it reversal. https://fedorahosted.org/freeipa/ticket/2372
Diffstat (limited to 'install/ui/aci.js')
-rw-r--r--install/ui/aci.js139
1 files changed, 108 insertions, 31 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js
index 02e03f309..ec3c8065b 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -52,7 +52,8 @@ IPA.aci.permission_entity = function(spec) {
{
type: 'select',
name: 'target',
- widget: 'target.target'
+ widget: 'target.target',
+ enabled: false
},
{
name: 'filter',
@@ -62,7 +63,8 @@ IPA.aci.permission_entity = function(spec) {
{
type: 'entity_select',
name: 'memberof',
- widget: 'target.memberof'
+ widget: 'target.memberof',
+ enabled: false
},
{
name: 'subtree',
@@ -85,6 +87,13 @@ IPA.aci.permission_entity = function(spec) {
name: 'attrs',
widget: 'target.attrs',
enabled: false
+ },
+ {
+ name: 'attrs_multi',
+ param: 'attrs',
+ type: 'multivalued',
+ widget: 'target.attrs_multi',
+ enabled: false
}
],
widgets: [
@@ -139,7 +148,8 @@ IPA.aci.permission_entity = function(spec) {
{
type: 'select',
name: 'target',
- widget: 'target.target'
+ widget: 'target.target',
+ enabled: false
},
{
name: 'filter',
@@ -149,7 +159,8 @@ IPA.aci.permission_entity = function(spec) {
{
type: 'entity_select',
name: 'memberof',
- widget: 'target.memberof'
+ widget: 'target.memberof',
+ enabled: false
},
{
name: 'subtree',
@@ -172,6 +183,13 @@ IPA.aci.permission_entity = function(spec) {
name: 'attrs',
widget: 'target.attrs',
enabled: false
+ },
+ {
+ name: 'attrs_multi',
+ type: 'multivalued',
+ param: 'attrs',
+ widget: 'target.attrs_multi',
+ enabled: false
}
],
widgets: [
@@ -702,6 +720,14 @@ IPA.permission_target_widget = function(spec) {
});
that.widgets.add_widget(that.attribute_table);
+
+ that.attribute_multivalued = IPA.multivalued_widget({
+ entity: that.entity,
+ name: 'attrs_multi',
+ hidden: true
+ });
+
+ that.widgets.add_widget(that.attribute_multivalued);
};
init();
@@ -725,34 +751,41 @@ IPA.permission_target_policy = function (widget_name) {
});
var type_select = widgets.get_widget('type');
- var attribute_table = widgets.get_widget('attrs');
- var attribute_field = that.container.fields.get_field('attrs');
+
type_select.value_changed.attach(function() {
var type = type_select.save()[0];
- attribute_table.object_type = type;
- attribute_field.reset();
+ that.set_attrs_type(type);
});
};
+ that.set_attrs_type = function(type) {
+ var attribute_field = that.container.fields.get_field('attrs');
+ var attribute_table = that.permission_target.widgets.get_widget('attrs');
+ attribute_table.object_type = type;
+ attribute_field.reset();
+ };
+
that.post_create = function() {
that.select_target(that.permission_target.targets[0]);
};
that.post_load = function(data) {
- var targets = that.permission_target.targets;
-
- that.set_target_visible_core('memberof', false);
+ var displayed_target;
- for (var i=0; i<targets.length; i++) {
- var target = targets[i];
+ for (var target in that.target_mapping) {
- if(data.result.result[target]) {
- that.select_target(target);
+ if (data.result.result[target]) {
+ displayed_target = target;
} else {
that.set_target_visible(target, false);
}
}
+
+ if (displayed_target) {
+ that.permission_target.target = displayed_target;
+ that.set_target_visible(displayed_target, true);
+ }
};
that.select_target = function(target) {
@@ -763,27 +796,71 @@ IPA.permission_target_policy = function (widget_name) {
that.set_target_visible = function(target, visible) {
- that.set_target_visible_core(target, visible);
+ var target_info = that.target_mapping[target];
+ that.set_target_visible_core(target_info, visible);
+ };
- if (target === 'type') {
- that.set_target_visible_core('attrs', visible);
- } else {
- var field = that.container.fields.get_field(target);
- field.set_required(visible);
- }
+ that.set_target_visible_core = function(target_info, visible) {
+ var widget = that.permission_target.widgets.get_widget(target_info.name);
+ var field = that.container.fields.get_field(target_info.name);
+ that.permission_target.set_row_visible(target_info.name, visible);
+ field.enabled = visible;
+ field.set_required(visible && target_info.required);
+ widget.hidden = !visible;
- if (visible) {
- var member_of_visible = target === 'type' || target === 'subtree';
- that.set_target_visible_core('memberof', member_of_visible);
+ if (target_info.additional) {
+ for (var i=0; i<target_info.additional.length; i++) {
+ var nested_info = target_info.additional[i];
+ that.set_target_visible_core(nested_info, visible);
+ }
}
+
+ if (target_info.action) target_info.action();
};
- that.set_target_visible_core = function(target, visible) {
- var widget = that.permission_target.widgets.get_widget(target);
- var field = that.container.fields.get_field(target);
- that.permission_target.set_row_visible(target, visible);
- field.enabled = visible;
- widget.hidden = !visible;
+
+ that.target_mapping = {
+ filter: {
+ name: 'filter',
+ required: true,
+ additional: [
+ {
+ name: 'attrs_multi'
+ }
+ ]
+ },
+ subtree: {
+ name: 'subtree',
+ required: true,
+ additional: [
+ {
+ name: 'memberof'
+ }
+ ]
+ },
+ targetgroup: {
+ name: 'targetgroup',
+ required: true,
+ additional: [
+ {
+ name: 'attrs'
+ }
+ ],
+ action: function() {
+ that.set_attrs_type('group');
+ }
+ },
+ type: {
+ name: 'type',
+ additional: [
+ {
+ name: 'memberof'
+ },
+ {
+ name: 'attrs'
+ }
+ ]
+ }
};