summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/aci.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-11-13 15:49:25 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-04-03 12:40:37 +0200
commit0d05a50e19b71cade636d9ca4882e453f614a78c (patch)
tree8b7fee3645c6c08f0a90be334ecd11543a6c2f91 /install/ui/src/freeipa/aci.js
parent66fb4d5e849a049e95d3ef4fcf2b86217488634d (diff)
downloadfreeipa-0d05a50e19b71cade636d9ca4882e453f614a78c.tar.gz
freeipa-0d05a50e19b71cade636d9ca4882e453f614a78c.tar.xz
freeipa-0d05a50e19b71cade636d9ca4882e453f614a78c.zip
webui: field and widget binding refactoring
This is a Web UI wide change. Fields and Widgets binding was refactored to enable proper two-way binding between them. This should allow to have one source of truth (field) for multiple consumers - widgets or something else. One of the goal is to have fields and widget implementations independent on each other. So that one could use a widget without field or use one field for multiple widgets, etc.. Basically a fields logic was split into separate components: - adapters - parsers & formatters - binder Adapters - extract data from data source (FreeIPA RPC command result) - prepares them for commands. Parsers - parse extracted data to format expected by field - parse widget value to format expected by field Formatters - format field value to format suitable for widgets - format field value to format suitable for adapter Binder - is a communication bridge between field and widget - listens to field's and widget's events and call appropriate methods Some side benefits: - better validation reporting in multivalued widget Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
Diffstat (limited to 'install/ui/src/freeipa/aci.js')
-rw-r--r--install/ui/src/freeipa/aci.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/install/ui/src/freeipa/aci.js b/install/ui/src/freeipa/aci.js
index 9aab2d7ec..0615184c0 100644
--- a/install/ui/src/freeipa/aci.js
+++ b/install/ui/src/freeipa/aci.js
@@ -20,6 +20,7 @@
*/
define([
+ 'dojo/on',
'./metadata',
'./ipa',
'./jquery',
@@ -30,7 +31,7 @@ define([
'./search',
'./association',
'./entity'],
- function(metadata_provider, IPA, $, phases, reg, text) {
+ function(on, metadata_provider, IPA, $, phases, reg, text) {
/**
* Widgets, entities and fields related to Access Control that means
@@ -577,6 +578,7 @@ aci.attributes_widget = function(spec) {
$('.aci-attribute', that.table).
prop('checked', $(this).prop('checked'));
that.value_changed.notify([], that);
+ that.emit('value-change', { source: that });
}
}, th);
@@ -615,6 +617,7 @@ aci.attributes_widget = function(spec) {
'class': 'aci-attribute',
change: function() {
that.value_changed.notify([], that);
+ that.emit('value-change', { source: that });
}
}, td);
td = $('<td/>').appendTo(tr);
@@ -827,15 +830,9 @@ aci.permission_target_policy = function (spec) {
that.init = function() {
that.permission_target = that.container.widgets.get_widget(that.widget_name);
- var type_select = that.permission_target.widgets.get_widget('type');
-
- type_select.value_changed.attach(function() {
- that.apply_type();
- });
+ var type_f = that.container.fields.get_field('type');
- type_select.undo_clicked.attach(function() {
- that.apply_type();
- });
+ on(type_f, 'value-change', that.apply_type);
};
that.apply_type = function () {
@@ -861,9 +858,7 @@ aci.permission_target_policy = function (spec) {
// permission plugin resets ipapermlocation to basedn when
// type is unset. -> use it as pristine value so undo will
// work correctly.
- var loc = [IPA.env.basedn];
- loc_w.update(loc);
- loc_f.values = loc;
+ loc_f.set_value([IPA.env.basedn], true);
} else {
attrs = attr_multi.save();
attr_table.update(attrs);
@@ -1077,9 +1072,9 @@ aci.register = function() {
e.register({ type: 'delegation', spec: aci.delegation_entity_spec });
w.register('attributes', aci.attributes_widget);
- f.register('attributes', IPA.checkboxes_field);
+ f.register('attributes', IPA.field);
w.register('rights', aci.rights_widget);
- f.register('rights', IPA.checkboxes_field);
+ f.register('rights', IPA.field);
w.register('permission_target', aci.permission_target_widget);
};