summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/service.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/service.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/service.js')
-rw-r--r--install/ui/src/freeipa/service.js60
1 files changed, 17 insertions, 43 deletions
diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js
index 09880a937..bd1d3842b 100644
--- a/install/ui/src/freeipa/service.js
+++ b/install/ui/src/freeipa/service.js
@@ -19,6 +19,8 @@
*/
define([
+ 'dojo/_base/declare',
+ './field',
'./ipa',
'./jquery',
'./phases',
@@ -29,7 +31,7 @@ define([
'./search',
'./association',
'./entity'],
- function(IPA, $, phases, reg, rpc, text) {
+ function(declare, field_mod, IPA, $, phases, reg, rpc, text) {
var exp =IPA.service = {};
@@ -66,16 +68,16 @@ return {
fields: [
'krbprincipalname',
{
- $type: 'service_name',
name: 'service',
label: '@i18n:objects.service.service',
- read_only: true
+ read_only: true,
+ adapter: IPA.service_name_adapter
},
{
- $type: 'service_host',
name: 'host',
label: '@i18n:objects.service.host',
- read_only: true
+ read_only: true,
+ adapter: IPA.service_host_adapter
},
{
name: 'ipakrbauthzdata',
@@ -271,45 +273,21 @@ IPA.service_adder_dialog = function(spec) {
return that;
};
-IPA.service_name_field = function(spec) {
-
- spec = spec || {};
-
- var that = IPA.field(spec);
-
- that.load = function(record) {
-
- that.field_load(record);
-
+IPA.service_name_adapter = declare([field_mod.Adapter], {
+ load: function(record) {
var krbprincipalname = record.krbprincipalname[0];
var value = krbprincipalname.replace(/\/.*$/, '');
- that.values = [value];
-
- that.reset();
- };
-
- return that;
-};
-
-IPA.service_host_field = function(spec) {
-
- spec = spec || {};
-
- var that = IPA.field(spec);
-
- that.load = function(record) {
-
- that.field_load(record);
+ return [value];
+ }
+});
+IPA.service_host_adapter = declare([field_mod.Adapter], {
+ load: function(record) {
var krbprincipalname = record.krbprincipalname[0];
var value = krbprincipalname.replace(/^.*\//, '').replace(/@.*$/, '');
- that.values = [value];
-
- that.reset();
- };
-
- return that;
-};
+ return [value];
+ }
+});
IPA.service_provisioning_status_widget = function (spec) {
@@ -512,10 +490,6 @@ phases.on('registration', function() {
e.register({type: 'service', spec: exp.entity_spec});
- f.register('service_name', IPA.service_name_field);
- w.register('service_name', IPA.text_widget);
- f.register('service_host', IPA.service_host_field);
- w.register('service_host', IPA.text_widget);
f.register('service_provisioning_status', IPA.field);
w.register('service_provisioning_status', IPA.service_provisioning_status_widget);
a.register('service_unprovision', IPA.service.unprovision_action);