From 18a6ab356a159a88c5aab014f344eb14a9d38c81 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 22 Mar 2012 17:31:48 +0100 Subject: Inter-facet expiration Problem: When some facet perform action which modifies data, some other facet may become expired. Example: User modifies group's description. Now group search facet contains old data and has to be refreshed. Solution: New event was added to facet: on_update. It should be executed when facet performs action which modifies data ie: details facet update or add entry to dnsrecord. Then entity policies were introduced. Entity policies are a objects which are stored in entity.policies. They have similar function as facet_policies - performing communications and other functionality between facets. This way facets don't have to contain such logic and thus they aren't dependant on each other. This patch adds IPA.facet_update_policy, IPA.adder_facet_update_policy, IPA.search_facet_update_policy, IPA.details_facet_update_policy. IPA.facet_update_policy: On facets_created it bind itself to [current entity].[source facet].[event]. Default event is on_update. When the event is executed it sets expiration flag to [dest entity].[dest facet]. IPA.search_facet_update_policy: IPA.facet_update_policy where source facet = search, dest facet = details, dest entity = current entity. Its a default policy for updatein changes from search facet to details facet. Right now it isn't needed but it will be needed when action lists come to play. IPA.details_facet_update_policy: same as IPA.search_facet_update_policy just reversed. Very important. IPA.adder_facet_update_policy: similar functionality, just source of the event is dialog. Default event is added (new event in entity_adder_dialog). Entity policies should be specified in entity's spec object. If none are specified a default ones are used. Default policies are: IPA.search_facet_update_policy and IPA.details_facet_update_policy. https://fedorahosted.org/freeipa/ticket/2075 --- install/ui/entity.js | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) (limited to 'install/ui/entity.js') diff --git a/install/ui/entity.js b/install/ui/entity.js index 6b2be9e6..49f30b0b 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -31,6 +31,11 @@ IPA.entity = function(spec) { spec = spec || {}; + spec.policies = spec.policies || [ + IPA.search_facet_update_policy(), + IPA.details_facet_update_policy() + ]; + var that = {}; that.name = spec.name; @@ -43,6 +48,11 @@ IPA.entity = function(spec) { that.dialog_specs = spec.dialogs || []; that.dialogs_created = false; + that.policies = IPA.entity_policies({ + entity: that, + policies: spec.policies + }); + that.facets = $.ordered_map(); that.facet_groups = $.ordered_map(); that.facet_specs = spec.facets || []; @@ -116,6 +126,7 @@ IPA.entity = function(spec) { var builder = IPA.facet_builder(that); builder.build_facets(); that.facets_created = true; + that.policies.facets_created(); } if (name === undefined) { @@ -568,4 +579,144 @@ IPA.dialog_builder = function(entity) { }; return that; +}; + +IPA.entity_policy = function(spec) { + + spec = spec || {}; + + var that = {}; + + that.entity = spec.entity; + + that.facets_created = function() { + }; + + return that; +}; + +IPA.entity_policies = function(spec) { + + var that = {}; + + that.entity = spec.entity; + that.policies = []; + + that.add_policy = function(policy) { + + policy.entity = that.entity; + that.policies.push(policy); + }; + + that.add_policies = function(policies) { + + if (!policies) return; + + for (var i=0; i