[PATCH] 414 Move spec modifications from facet factories to pre_ops
-------------------------------------------------------------------

Spec modifications in factories makes inheritance and extensibility more difficult.

Moving them to pre_ops allows modification of their output by other pre_ops.

https://fedorahosted.org/freeipa/ticket/3605

[PATCH] 415 Unite and move facet pre_ops to related modules
-----------------------------------------------------------

Facet pre_ops defined in ./facet module were moved to modules where facet are actually defined. Moved pre_ops were united with the ones defined for the facets in these modules.

The move simplifies module dependencies - there is no reason to have general facet module dependent on specialized facet modules.

Pre_ops uniting makes the code simpler.

https://fedorahosted.org/freeipa/ticket/3605
--
Petr Vobornik
From 92d704bb6a7227fe4df2ab1daede3748b22b54ff Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 14 May 2013 17:36:28 +0200
Subject: [PATCH] Move spec modifications from facet factories to pre_ops

Spec modifications in factories makes inheritance and extensibility more difficult.

Moving them to pre_ops allows modification of their output by other pre_ops.

https://fedorahosted.org/freeipa/ticket/3605
---
 install/ui/src/freeipa/association.js | 54 ++++++++++++++++++++++++++++-------
 install/ui/src/freeipa/details.js     | 21 ++++++++++++--
 install/ui/src/freeipa/facet.js       | 47 +-----------------------------
 install/ui/src/freeipa/search.js      | 46 +++++++++++++++++++++++------
 install/ui/test/details_tests.js      |  8 ------
 install/ui/test/entity_tests.js       |  8 ------
 6 files changed, 99 insertions(+), 85 deletions(-)

diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 71ee71d488e4b8f042884762f0e73d994dba5011..9e200ecf27410e7cfabb9773336c687861d43d55 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -30,9 +30,12 @@ define([
     './phases',
     './reg',
     './text',
+    './facet',
     './search',
     './dialog'],
-        function(Deferred, IPA, $, navigation, phases, reg, text) {
+        function(Deferred, IPA, $, navigation, phases, reg, text, mod_facet) {
+
+var exp = {};
 
 IPA.associator = function (spec) {
 
@@ -760,16 +763,14 @@ IPA.association_table_field = function (spec) {
     return that;
 };
 
-IPA.association_facet = function (spec, no_init) {
+exp.association_facet_pre_op = function(spec, context) {
 
-    spec = spec || {};
-
-    /*
-       Link parameter is used to turn off the links in selfservice mode.
+     /*
+       Link parameter is used to turn off the links in self-service mode.
        Default it to true if not set so that facets that would not otherwise
        link by default get links set.
 
-       link must be set before the call to the base class, to affect the  table.
+       link must be set before the call to the base class, to affect the table.
      */
     spec.link = spec.link === undefined ? true : spec.link;
     spec.managed_entity = IPA.get_entity(spec.other_entity);
@@ -823,6 +824,13 @@ IPA.association_facet = function (spec, no_init) {
         IPA.association_type_state_evaluator,
         IPA.read_only_state_evaluator);
 
+    return spec;
+};
+
+exp.association_facet = IPA.association_facet = function (spec, no_init) {
+
+    spec = spec || {};
+
     var that = IPA.table_facet(spec, true);
 
     that.attribute_member = spec.attribute_member;
@@ -1156,9 +1164,7 @@ IPA.association_facet = function (spec, no_init) {
     return that;
 };
 
-IPA.attribute_facet = function(spec, no_init) {
-
-    spec = spec || {};
+exp.attribute_facet_pre_op = function(spec, context) {
 
     //default buttons and their actions
     spec.actions = spec.actions || [];
@@ -1212,6 +1218,13 @@ IPA.attribute_facet = function(spec, no_init) {
     spec.columns = spec.columns || [ spec.attribute ];
     spec.table_name = spec.table_name || spec.attribute;
 
+    return spec;
+};
+
+exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
+
+    spec = spec || {};
+
     var that = IPA.table_facet(spec, true);
 
     that.attribute = spec.attribute;
@@ -1447,10 +1460,29 @@ IPA.attr_read_only_evaluator = function(spec) {
 phases.on('registration', function() {
     var w = reg.widget;
     var f = reg.field;
+    var fa = reg.facet;
 
     w.register('association_table', IPA.association_table_widget);
     f.register('association_table', IPA.association_table_field);
+
+    fa.register({
+        type: 'association',
+        factory: exp.association_facet,
+        pre_ops: [
+            mod_facet.facet_preops.association,
+            exp.association_facet_pre_op
+        ]
+    });
+
+    fa.register({
+        type: 'attribute',
+        factory: exp.attribute_facet,
+        pre_ops: [
+            mod_facet.facet_preops.attribute,
+            exp.attribute_facet_pre_op
+        ]
+    });
 });
 
-return {};
+return exp;
 });
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index 15239d4445884a49e1122228f443004f9efa7b28..6811a1dfb1417649faee20f9a46c90c5dde14fee 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -33,7 +33,7 @@ define([
         './text',
         './facet',
         './add'],
-    function(lang, builder, IPA, $, phases, reg, text) {
+    function(lang, builder, IPA, $, phases, reg, text, mod_facet) {
 
 var exp = {};
 
@@ -241,9 +241,8 @@ exp.facet_policies = IPA.facet_policies = function(spec) {
     return that;
 };
 
-exp.details_facet = IPA.details_facet = function(spec, no_init) {
+exp.details_facet_pre_op = function(spec, context) {
 
-    spec = spec || {};
     spec.name = spec.name || 'details';
 
     spec.actions = spec.actions || [];
@@ -277,6 +276,12 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
     spec.state = spec.state || {};
     spec.state.evaluators = spec.state.evaluators || [];
     spec.state.evaluators.push(IPA.dirty_state_evaluator);
+    return spec;
+};
+
+exp.details_facet = IPA.details_facet = function(spec, no_init) {
+
+    spec = spec || {};
 
     var that = IPA.facet(spec, true);
 
@@ -1221,6 +1226,7 @@ exp.disabled_summary_cond = IPA.disabled_summary_cond = function() {
 
 exp.register = function() {
     var a = reg.action;
+    var f = reg.facet;
 
     a.register('select', exp.select_action);
     a.register('refresh', exp.refresh_action);
@@ -1230,6 +1236,15 @@ exp.register = function() {
     a.register('enable', exp.enable_action);
     a.register('disable', exp.disable_action);
     a.register('delete', exp.delete_action);
+
+    f.register({
+        type: 'details',
+        factory: IPA.details_facet,
+        pre_ops: [
+            mod_facet.facet_preops.details,
+            exp.details_facet_pre_op
+        ]
+    });
 };
 
 phases.on('registration', exp.register);
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index f9510e77adf48b849fa7dd251792080d6ca8fa3d..46aea0cc31cfdce7e86a91b60f881b3dc4efd4a8 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -1579,50 +1579,6 @@ exp.facet_preops = {
     }
 };
 
-exp.register_facets = function() {
-
-    var f = reg.facet;
-    f.register({
-        type: 'search',
-        factory: IPA.search_facet,
-        pre_ops: [
-            exp.facet_preops.search
-        ]
-    });
-
-    f.register({
-        type: 'nested_search',
-        factory: IPA.nested_search_facet,
-        pre_ops: [
-            exp.facet_preops.nested_search
-        ]
-    });
-
-    f.register({
-        type: 'details',
-        factory: IPA.details_facet,
-        pre_ops: [
-            exp.facet_preops.details
-        ]
-    });
-
-    f.register({
-        type: 'association',
-        factory: IPA.association_facet,
-        pre_ops: [
-            exp.facet_preops.association
-        ]
-    });
-
-    f.register({
-        type: 'attribute',
-        factory: IPA.attribute_facet,
-        pre_ops: [
-            exp.facet_preops.attribute
-        ]
-    });
-};
-
 exp.action = IPA.action = function(spec) {
 
     spec = spec || {};
@@ -2406,7 +2362,7 @@ var FacetState = exp.FacetState = declare([Stateful, Evented], {
     },
 
     /**
-     * Set completly new state. Old state is cleared.
+     * Set completely new state. Old state is cleared.
      *
      * Raises 'reset' event.
      */
@@ -2446,7 +2402,6 @@ exp.register = function() {
 };
 
 phases.on('registration', exp.register);
-phases.on('registration', exp.register_facets);
 
 return exp;
 });
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index 8af5a29d3de0b010390fb733072a2ae2b7a7c000..7caffead3016aefea138948eb781b26a15701ef9 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -28,13 +28,11 @@ define([
         './reg',
         './text',
         './facet'],
-    function(IPA, $, phases, reg, text) {
+    function(IPA, $, phases, reg, text, mod_facet) {
 
 var exp = {};
 
-IPA.search_facet = function(spec, no_init) {
-
-    spec = spec || {};
+exp.search_facet_pre_op = function(spec, context) {
 
     spec.name = spec.name || 'search';
     spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
@@ -78,6 +76,13 @@ IPA.search_facet = function(spec, no_init) {
         IPA.selected_state_evaluator,
         IPA.self_service_state_evaluator);
 
+    return spec;
+};
+
+IPA.search_facet = function(spec, no_init) {
+
+    spec = spec || {};
+
     var that = IPA.table_facet(spec, true);
 
     that.deleter_dialog = spec.deleter_dialog || IPA.search_deleter_dialog;
@@ -352,16 +357,20 @@ IPA.search_deleter_dialog = function(spec) {
     return that;
 };
 
-/*TODO.  this has much copied code from above.  Refactor the search_facet
-To either be nested or not nested. */
-IPA.nested_search_facet = function(spec) {
-
-    spec = spec || {};
+exp.nested_search_facet_preop = function(spec, context) {
 
     spec.managed_entity = IPA.get_entity(spec.nested_entity);
 
     spec.disable_breadcrumb = false;
     spec.disable_facet_tabs = false;
+    return spec;
+};
+
+/*TODO.  this has much copied code from above.  Refactor the search_facet
+To either be nested or not nested. */
+exp.nested_search_facet = IPA.nested_search_facet = function(spec) {
+
+    spec = spec || {};
 
     var that = IPA.search_facet(spec);
 
@@ -514,12 +523,31 @@ IPA.batch_enable_action = function(spec) {
 exp.register = function() {
 
     var a = reg.action;
+    var f = reg.facet;
 
     a.register('batch_remove', IPA.batch_remove_action);
     a.register('add', IPA.add_action);
     a.register('batch_items', IPA.batch_items_action);
     a.register('batch_disable', IPA.batch_disable_action);
     a.register('batch_enable', IPA.batch_enable_action);
+
+    f.register({
+        type: 'search',
+        factory: IPA.search_facet,
+        pre_ops: [
+            mod_facet.facet_preops.search,
+            exp.search_facet_pre_op
+        ]
+    });
+
+    f.register({
+        type: 'nested_search',
+        factory: IPA.nested_search_facet,
+        pre_ops: [
+            mod_facet.facet_preops.nested_search,
+            exp.nested_search_facet_preop
+        ]
+    });
 };
 
 phases.on('registration', exp.register);
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index cc087a6b4d07edfe78dc8e6c7ca63e7f886867a0..26bc4fb6649bd57de15cc4438c507bae0897cba4 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -38,14 +38,6 @@ module('details', {
     setup: function() {
         IPA.ajax_options.async = false;
 
-        reg.facet.register({
-            type: 'details',
-            factory: IPA.details_facet,
-            pre_ops: [
-                mod_facet.facet_preops.details
-            ]
-        });
-
         mod_facet.register();
         mod_details.register();
 
diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js
index 8dbeab2f6b90d1d0df3b228b36cbae66a29e439d..b4ac91b69ad754801bba4173722080541ab695e2 100644
--- a/install/ui/test/entity_tests.js
+++ b/install/ui/test/entity_tests.js
@@ -39,14 +39,6 @@ module('entity',{
 
         mod_search.register();
 
-        reg.facet.register({
-            type: 'search',
-            factory: IPA.search_facet,
-            pre_ops: [
-                mod_facet.facet_preops.search
-            ]
-        });
-
         IPA.init({
             url: 'data',
             on_success: function(data, text_status, xhr) {
-- 
1.8.1.4

From f6640f9b8c9f8fc2efb8df02f3ef641dd2225914 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 14 May 2013 18:13:48 +0200
Subject: [PATCH] Unite and move facet pre_ops to related modules

Facet pre_ops defined in ./facet module were moved to modules where facet are actually defined. Moved pre_ops were united with the ones defined for the facets in these modules.

The move simplifies module dependencies - there is no reason to have general facet module dependent on specialized facet modules.

Pre_ops uniting makes the code simpler.

https://fedorahosted.org/freeipa/ticket/3605
---
 install/ui/src/freeipa/association.js |  71 ++++++++++++++++++++-
 install/ui/src/freeipa/details.js     |  10 ++-
 install/ui/src/freeipa/facet.js       | 115 +---------------------------------
 install/ui/src/freeipa/search.js      |  21 +++++--
 4 files changed, 94 insertions(+), 123 deletions(-)

diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 9e200ecf27410e7cfabb9773336c687861d43d55..fc073eb06380dee57403676fe2729c0af430d508 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -24,16 +24,19 @@
 
 define([
     'dojo/Deferred',
+    './_base/metadata_provider',
     './ipa',
     './jquery',
     './navigation',
     './phases',
     './reg',
+    './spec_util',
     './text',
     './facet',
     './search',
     './dialog'],
-        function(Deferred, IPA, $, navigation, phases, reg, text, mod_facet) {
+        function(Deferred, metadata_provider, IPA, $, navigation,
+                 phases, reg, su, text) {
 
 var exp = {};
 
@@ -765,6 +768,49 @@ IPA.association_table_field = function (spec) {
 
 exp.association_facet_pre_op = function(spec, context) {
 
+    var 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;
+    };
+
+    var entity = context.entity;
+    su.context_entity(spec, context);
+    spec.entity = entity;
+
+    var index = spec.name.indexOf('_');
+    spec.attribute_member = spec.attribute_member ||
+        spec.name.substring(0, index);
+    spec.other_entity = spec.other_entity ||
+        spec.name.substring(index+1);
+
+    spec.add_title = '@i18n:association.add.'+spec.attribute_member;
+    spec.remove_title = '@i18n:association.remove.'+spec.attribute_member;
+
+    spec.facet_group = spec.facet_group || spec.attribute_member;
+
+    spec.label = spec.label || entity.metadata.label_singular;
+
+    spec.tab_label = spec.tab_label ||
+                    metadata_provider.get('@mo:'+spec.other_entity+'.label') ||
+                    spec.other_entity;
+
+    if (has_indirect_attribute_member(spec)) {
+
+        spec.indirect_attribute_member = spec.attribute_member + 'indirect';
+    }
+
+    if (spec.facet_group === 'memberindirect' ||
+        spec.facet_group === 'memberofindirect') {
+
+        spec.read_only = true;
+    }
+
      /*
        Link parameter is used to turn off the links in self-service mode.
        Default it to true if not set so that facets that would not otherwise
@@ -824,6 +870,12 @@ exp.association_facet_pre_op = function(spec, context) {
         IPA.association_type_state_evaluator,
         IPA.read_only_state_evaluator);
 
+    entity.policies.add_policy(IPA.build({
+        $factory: IPA.facet_update_policy,
+        source_facet: 'search',
+        dest_facet: spec.name
+    }));
+
     return spec;
 };
 
@@ -1166,6 +1218,21 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
 
 exp.attribute_facet_pre_op = function(spec, context) {
 
+    var entity = context.entity;
+    su.context_entity(spec, context);
+
+    spec.title = spec.title || entity.metadata.label_singular;
+    spec.label = spec.label || entity.metadata.label_singular;
+
+    var attr_metadata = IPA.get_entity_param(entity.name, spec.attribute);
+    spec.tab_label = spec.tab_label || attr_metadata.label;
+
+    entity.policies.add_policy(IPA.build({
+        $factory: IPA.facet_update_policy,
+        source_facet: 'search',
+        dest_facet: spec.name
+    }));
+
     //default buttons and their actions
     spec.actions = spec.actions || [];
     spec.actions.unshift(
@@ -1469,7 +1536,6 @@ phases.on('registration', function() {
         type: 'association',
         factory: exp.association_facet,
         pre_ops: [
-            mod_facet.facet_preops.association,
             exp.association_facet_pre_op
         ]
     });
@@ -1478,7 +1544,6 @@ phases.on('registration', function() {
         type: 'attribute',
         factory: exp.attribute_facet,
         pre_ops: [
-            mod_facet.facet_preops.attribute,
             exp.attribute_facet_pre_op
         ]
     });
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index 6811a1dfb1417649faee20f9a46c90c5dde14fee..149a04e43776303fdd7f1a8ff9bd1e0959d511aa 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -30,10 +30,11 @@ define([
         './jquery',
         './phases',
         './reg',
+        './spec_util',
         './text',
         './facet',
         './add'],
-    function(lang, builder, IPA, $, phases, reg, text, mod_facet) {
+    function(lang, builder, IPA, $, phases, reg, su, text) {
 
 var exp = {};
 
@@ -243,7 +244,13 @@ exp.facet_policies = IPA.facet_policies = function(spec) {
 
 exp.details_facet_pre_op = function(spec, context) {
 
+    var entity = context.entity;
+    su.context_entity(spec, context);
+
     spec.name = spec.name || 'details';
+    spec.title = spec.title || entity.metadata.label_singular;
+    spec.label = spec.label || entity.metadata.label_singular;
+    spec.tab_label = spec.tab_label || '@i18n:facets.details';
 
     spec.actions = spec.actions || [];
     spec.actions.unshift(
@@ -1241,7 +1248,6 @@ exp.register = function() {
         type: 'details',
         factory: IPA.details_facet,
         pre_ops: [
-            mod_facet.facet_preops.details,
             exp.details_facet_pre_op
         ]
     });
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 46aea0cc31cfdce7e86a91b60f881b3dc4efd4a8..80e867125bb62563bc40e566b085b02d725a1821 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -28,7 +28,6 @@ define([
         'dojo/on',
         'dojo/Stateful',
         'dojo/Evented',
-        './_base/metadata_provider',
         './_base/Singleton_registry',
         './builder',
         './ipa',
@@ -41,7 +40,7 @@ define([
         './dialog',
         './field',
         './widget'
-       ], function(declare, lang, construct, on, Stateful, Evented, metadata_provider,
+       ], function(declare, lang, construct, on, Stateful, Evented,
                    Singleton_registry, builder, IPA, $, navigation, phases, reg, su, text) {
 
 /**
@@ -1467,118 +1466,6 @@ exp.facet_group = IPA.facet_group = function(spec) {
     return that;
 };
 
-exp.facet_preops = {
-    search: function(spec, context) {
-
-        var entity = context.entity;
-        su.context_entity(spec, context);
-
-        spec.title = spec.title || entity.metadata.label;
-        spec.label = spec.label || entity.metadata.label;
-        spec.tab_label = spec.tab_label || '@i18n:facets.search';
-
-        return spec;
-    },
-
-    nested_search: function(spec, context) {
-
-        var entity = context.entity;
-        su.context_entity(spec, context);
-
-        spec.title = spec.title || entity.metadata.label_singular;
-        spec.label = spec.label || entity.metadata.label;
-        spec.tab_label = spec.tab_label || '@i18n:facets.search';
-
-        return spec;
-    },
-
-    details: function(spec, context) {
-
-        var entity = context.entity;
-        su.context_entity(spec, context);
-
-        spec.title = spec.title || entity.metadata.label_singular;
-        spec.label = spec.label || entity.metadata.label_singular;
-        spec.tab_label = spec.tab_label || '@i18n:facets.details';
-
-        return spec;
-    },
-
-    attribute: function(spec, context) {
-
-        var entity = context.entity;
-        su.context_entity(spec, context);
-
-        spec.title = spec.title || entity.metadata.label_singular;
-        spec.label = spec.label || entity.metadata.label_singular;
-
-        var attr_metadata = IPA.get_entity_param(entity.name, spec.attribute);
-        spec.tab_label = spec.tab_label || attr_metadata.label;
-
-        entity.policies.add_policy(IPA.build({
-            $factory: IPA.facet_update_policy,
-            source_facet: 'search',
-            dest_facet: spec.name
-        }));
-
-        return spec;
-    },
-
-    association: function(spec, context) {
-
-        var 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;
-        };
-
-        var entity = context.entity;
-        su.context_entity(spec, context);
-        spec.entity = entity;
-
-        var index = spec.name.indexOf('_');
-        spec.attribute_member = spec.attribute_member ||
-            spec.name.substring(0, index);
-        spec.other_entity = spec.other_entity ||
-            spec.name.substring(index+1);
-
-        spec.add_title = '@i18n:association.add.'+spec.attribute_member;
-        spec.remove_title = '@i18n:association.remove.'+spec.attribute_member;
-
-        spec.facet_group = spec.facet_group || spec.attribute_member;
-
-        spec.label = spec.label || entity.metadata.label_singular;
-
-        spec.tab_label = spec.tab_label ||
-                        metadata_provider.get('@mo:'+spec.other_entity+'.label') ||
-                        spec.other_entity;
-
-        if (has_indirect_attribute_member(spec)) {
-
-            spec.indirect_attribute_member = spec.attribute_member + 'indirect';
-        }
-
-        if (spec.facet_group === 'memberindirect' ||
-            spec.facet_group === 'memberofindirect') {
-
-            spec.read_only = true;
-        }
-
-        entity.policies.add_policy(IPA.build({
-            $factory: IPA.facet_update_policy,
-            source_facet: 'search',
-            dest_facet: spec.name
-        }));
-
-        return spec;
-    }
-};
-
 exp.action = IPA.action = function(spec) {
 
     spec = spec || {};
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index 7caffead3016aefea138948eb781b26a15701ef9..0f5220104dbdd716f0bf76707e5c3e5d1cc3c45c 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -26,15 +26,23 @@ define([
         './jquery',
         './phases',
         './reg',
+        './spec_util',
         './text',
         './facet'],
-    function(IPA, $, phases, reg, text, mod_facet) {
+    function(IPA, $, phases, reg, su, text, mod_facet) {
 
 var exp = {};
 
 exp.search_facet_pre_op = function(spec, context) {
 
+    var entity = context.entity;
+    su.context_entity(spec, context);
+
     spec.name = spec.name || 'search';
+    spec.title = spec.title || entity.metadata.label;
+    spec.label = spec.label || entity.metadata.label;
+    spec.tab_label = spec.tab_label || '@i18n:facets.search';
+
     spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
 
     spec.disable_breadcrumb =
@@ -359,7 +367,14 @@ IPA.search_deleter_dialog = function(spec) {
 
 exp.nested_search_facet_preop = function(spec, context) {
 
-    spec.managed_entity = IPA.get_entity(spec.nested_entity);
+    var entity = context.entity;
+    su.context_entity(spec, context);
+
+    spec.title = spec.title || entity.metadata.label_singular;
+    spec.label = spec.label || entity.metadata.label;
+    spec.tab_label = spec.tab_label || '@i18n:facets.search';
+
+    spec.managed_entity = spec.nested_entity;
 
     spec.disable_breadcrumb = false;
     spec.disable_facet_tabs = false;
@@ -535,7 +550,6 @@ exp.register = function() {
         type: 'search',
         factory: IPA.search_facet,
         pre_ops: [
-            mod_facet.facet_preops.search,
             exp.search_facet_pre_op
         ]
     });
@@ -544,7 +558,6 @@ exp.register = function() {
         type: 'nested_search',
         factory: IPA.nested_search_facet,
         pre_ops: [
-            mod_facet.facet_preops.nested_search,
             exp.nested_search_facet_preop
         ]
     });
-- 
1.8.1.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to