diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-05-14 17:36:28 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-05-17 12:32:06 +0200 |
commit | 6e90920233cc9a7c9feb040dea22cda837715c39 (patch) | |
tree | 2537b852644502a58c6afa83bf12cf1c0a267825 /install/ui/src/freeipa/search.js | |
parent | 8d07054e1b2ff8680c225e7cd847eb885e7246a4 (diff) | |
download | freeipa-6e90920233cc9a7c9feb040dea22cda837715c39.tar.gz freeipa-6e90920233cc9a7c9feb040dea22cda837715c39.tar.xz freeipa-6e90920233cc9a7c9feb040dea22cda837715c39.zip |
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
Diffstat (limited to 'install/ui/src/freeipa/search.js')
-rw-r--r-- | install/ui/src/freeipa/search.js | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js index a77f1768..8dc80cd5 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; @@ -354,16 +359,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); @@ -516,12 +525,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); |