From ffeafa6ec2974de5e3f2303fa8ffccf1638e9254 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Fri, 12 Apr 2013 17:29:29 +0200 Subject: Replace IPA.facet_builder with facets.builder https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/freeipa/facet.js | 170 ++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'install/ui/src/freeipa/facet.js') diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 3afe76e04..3e4474580 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -29,15 +29,18 @@ define([ 'dojo/Stateful', 'dojo/Evented', './_base/Builder', + './facets', './ipa', './jquery', './navigation', + './phases', + './spec_util', './text', './dialog', './field', './widget' ], function(declare, lang, construct, on, Stateful, Evented, - Builder, IPA, $, navigation, text) { + Builder, facets, IPA, $, navigation, phases, su, text) { /** * Facet represents the content of currently displayed page. @@ -1462,95 +1465,53 @@ exp.facet_group = IPA.facet_group = function(spec) { return that; }; -exp.facet_builder = IPA.facet_builder = function(entity) { +exp.facet_preops = { + search: function(spec, context) { - var that = IPA.object(); - - that.prepare_methods = {}; - - function init() { - that.prepare_methods.search = that.prepare_search_spec; - that.prepare_methods.nested_search = that.prepare_nested_search_spec; - that.prepare_methods.details = that.prepare_details_spec; - that.prepare_methods.association = that.prepare_association_spec; - that.prepare_methods.attribute = that.prepare_attribute_spec; - } - - that.build_facets = function() { - - if(entity.facet_specs && entity.facet_specs.length) { - var facets = entity.facet_specs; - for(var i=0; i -1) { + return true; + } + } + return false; + }; + + var entity = context.entity; + su.context_entity(spec, context); spec.entity = entity; var index = spec.name.indexOf('_'); @@ -1576,14 +1550,12 @@ exp.facet_builder = IPA.facet_builder = function(entity) { spec.facet_group = spec.facet_group || spec.attribute_member; - spec.$factory = spec.$factory || IPA.association_facet; - spec.label = spec.label || entity.metadata.label_singular; spec.tab_label = spec.tab_label || (IPA.metadata.objects[spec.other_entity] ? IPA.metadata.objects[spec.other_entity].label : spec.other_entity); - if (that.has_indirect_attribute_member(spec)) { + if (has_indirect_attribute_member(spec)) { spec.indirect_attribute_member = spec.attribute_member + 'indirect'; } @@ -1601,24 +1573,52 @@ exp.facet_builder = IPA.facet_builder = function(entity) { })); return spec; - }; - - that.has_indirect_attribute_member = function(spec) { - - var indirect_members = entity.metadata.attribute_members[spec.attribute_member + 'indirect']; - if (indirect_members) { - if (indirect_members.indexOf(spec.other_entity) > -1) { - return true; - } - } - return false; - }; - - init(); - - return that; + } }; +phases.on('registration', function() { + + facets.register({ + type: 'search', + factory: IPA.search_facet, + pre_ops: [ + exp.facet_preops.search + ] + }); + + facets.register({ + type: 'nested_search', + factory: IPA.nested_search_facet, + pre_ops: [ + exp.facet_preops.nested_search + ] + }); + + facets.register({ + type: 'details', + factory: IPA.details_facet, + pre_ops: [ + exp.facet_preops.details + ] + }); + + facets.register({ + type: 'association', + factory: IPA.association_facet, + pre_ops: [ + exp.facet_preops.association + ] + }); + + facets.register({ + type: 'attribute', + factory: IPA.attribute_facet, + pre_ops: [ + exp.facet_preops.attribute + ] + }); +}); + exp.action = IPA.action = function(spec) { spec = spec || {}; -- cgit