From 0d05a50e19b71cade636d9ca4882e453f614a78c Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 13 Nov 2013 15:49:25 +0100 Subject: 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 --- install/ui/src/freeipa/automember.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'install/ui/src/freeipa/automember.js') diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js index e9619b731..ae7304d95 100644 --- a/install/ui/src/freeipa/automember.js +++ b/install/ui/src/freeipa/automember.js @@ -19,6 +19,8 @@ */ define([ + 'dojo/_base/declare', + './field', './metadata', './ipa', './jquery', @@ -31,7 +33,8 @@ define([ './search', './association', './entity'], - function(metadata_provider, IPA, $, navigation, phases, reg, rpc, text) { + function(declare, field_mod, metadata_provider, IPA, $, navigation, + phases, reg, rpc, text) { var exp = IPA.automember = {}; @@ -445,28 +448,26 @@ IPA.automember.parse_condition_regex = function(regex) { IPA.automember.condition_field = function(spec) { spec = spec || {}; + spec.adapter = spec.adapter || IPA.automember.condition_adapter; var that = IPA.field(spec); + return that; +}; - that.attr_name = spec.attribute || that.name; - - that.load = function(record) { - - var regexes = record[that.attr_name]; - that.values = []; +IPA.automember.condition_adapter = declare([field_mod.Adapter], { + load: function(record) { + var regexes = this.inherited(arguments); + var values = []; if (regexes) { for (var i=0, j=0; i