From c206249bd2321535883d36493d76b7de4ed59299 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 17 Apr 2013 16:18:26 +0200 Subject: [PATCH] Make summary conditions declarative https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/freeipa/details.js | 16 +++++++++++----- install/ui/src/freeipa/dns.js | 4 ++-- install/ui/src/freeipa/facet.js | 2 +- install/ui/src/freeipa/hbac.js | 4 ++-- install/ui/src/freeipa/selinux.js | 4 ++-- install/ui/src/freeipa/sudo.js | 4 ++-- install/ui/src/freeipa/user.js | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js index 4388eb856..425e885b0 100644 --- a/install/ui/src/freeipa/details.js +++ b/install/ui/src/freeipa/details.js @@ -24,6 +24,7 @@ /* IPA Object Details - populating definiton lists from entry data */ define([ + 'dojo/_base/lang', './builder', './ipa', './jquery', @@ -32,7 +33,7 @@ define([ './text', './facet', './add'], - function(builder, IPA, $, phases, reg, text) { + function(lang, builder, IPA, $, phases, reg, text) { var exp = {}; @@ -1194,21 +1195,26 @@ exp.delete_action = IPA.delete_action = function(spec) { exp.enabled_summary_cond = IPA.enabled_summary_cond = function() { - return { + + var that = IPA.object(); + lang.mixin(that, { pos: ['enabled'], neg: [], description: text.get('@i18n:status.enabled'), state: ['enabled'] - }; + }); + return that; }; exp.disabled_summary_cond = IPA.disabled_summary_cond = function() { - return { + var that = IPA.object(); + lang.mixin(that, { pos: [], neg: ['enabled'], description: text.get('@i18n:status.disabled'), state: ['disabled'] - }; + }); + return that; }; exp.register = function() { diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index b4dbf1acd..0347b9ff1 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -255,8 +255,8 @@ IPA.dns.zone_entity = function(spec) { IPA.dns.zone_has_permission_evaluator ], summary_conditions: [ - IPA.enabled_summary_cond(), - IPA.disabled_summary_cond() + IPA.enabled_summary_cond, + IPA.disabled_summary_cond ] } }). diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 06aa4a838..a69e9a575 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -1787,7 +1787,7 @@ exp.state = IPA.state = function(spec) { that.evaluators = builder.build('state_evaluator', spec.evaluators) || []; that.summary_evaluator = builder.build('', spec.summary_evaluator || IPA.summary_evaluator); - that.summary_conditions = spec.summary_conditions || []; + that.summary_conditions = builder.build('', spec.summary_conditions) || []; that.init = function(facet) { diff --git a/install/ui/src/freeipa/hbac.js b/install/ui/src/freeipa/hbac.js index 502d005b4..852f06ae9 100644 --- a/install/ui/src/freeipa/hbac.js +++ b/install/ui/src/freeipa/hbac.js @@ -82,8 +82,8 @@ IPA.hbac.rule_entity = function(spec) { } ], summary_conditions: [ - IPA.enabled_summary_cond(), - IPA.disabled_summary_cond() + IPA.enabled_summary_cond, + IPA.disabled_summary_cond ] } }). diff --git a/install/ui/src/freeipa/selinux.js b/install/ui/src/freeipa/selinux.js index 3ecf004e5..c27195d4d 100644 --- a/install/ui/src/freeipa/selinux.js +++ b/install/ui/src/freeipa/selinux.js @@ -81,8 +81,8 @@ IPA.selinux.selinuxusermap_entity = function(spec) { } ], summary_conditions: [ - IPA.enabled_summary_cond(), - IPA.disabled_summary_cond() + IPA.enabled_summary_cond, + IPA.disabled_summary_cond ] } }). diff --git a/install/ui/src/freeipa/sudo.js b/install/ui/src/freeipa/sudo.js index 05b75d901..ff8732a02 100644 --- a/install/ui/src/freeipa/sudo.js +++ b/install/ui/src/freeipa/sudo.js @@ -80,8 +80,8 @@ IPA.sudo.rule_entity = function(spec) { } ], summary_conditions: [ - IPA.enabled_summary_cond(), - IPA.disabled_summary_cond() + IPA.enabled_summary_cond, + IPA.disabled_summary_cond ] } }). diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js index 422377894..8b09d16f3 100644 --- a/install/ui/src/freeipa/user.js +++ b/install/ui/src/freeipa/user.js @@ -251,8 +251,8 @@ IPA.user.entity = function(spec) { IPA.user.reset_password_acl_evaluator ], summary_conditions: [ - IPA.enabled_summary_cond(), - IPA.disabled_summary_cond() + IPA.enabled_summary_cond, + IPA.disabled_summary_cond ] } }).