diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-04-23 15:17:54 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-05-06 16:22:29 +0200 |
commit | a069841ff0843c61edf5f501dd21b96dcac518c3 (patch) | |
tree | 107fab11444020e152d1e21f9ec54dc8ceb508a7 | |
parent | 3599357bcc74afe47e50ef1672021cc7a83a952a (diff) | |
download | freeipa-a069841ff0843c61edf5f501dd21b96dcac518c3.tar.gz freeipa-a069841ff0843c61edf5f501dd21b96dcac518c3.tar.xz freeipa-a069841ff0843c61edf5f501dd21b96dcac518c3.zip |
Replace ./facets with reg.facet
https://fedorahosted.org/freeipa/ticket/3235
-rw-r--r-- | install/ui/src/freeipa/entity.js | 5 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 24 | ||||
-rw-r--r-- | install/ui/src/freeipa/navigation/Router.js | 32 | ||||
-rw-r--r-- | install/ui/test/aci_tests.js | 5 | ||||
-rw-r--r-- | install/ui/test/details_tests.js | 10 | ||||
-rw-r--r-- | install/ui/test/entity_tests.js | 8 |
6 files changed, 39 insertions, 45 deletions
diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js index f132f325..427d300e 100644 --- a/install/ui/src/freeipa/entity.js +++ b/install/ui/src/freeipa/entity.js @@ -30,10 +30,9 @@ define([ './jquery', './reg', './text', - './facets', './facet'], function(lang, metadata_provider, Singleton_registry, builder, - IPA, $, reg, text, facet_reg) { + IPA, $, reg, text) { var exp = {}; @@ -168,7 +167,7 @@ exp.entity = IPA.entity = function(spec) { //build all facets on the first time if(!that.facets_created) { - facets = facet_reg.builder.build(that.facet_specs, { entity: that }); + facets = builder.build('facet', that.facet_specs, { entity: that }); for (i=0; i<facets.length; i++) { var facet = facets[i]; that.add_facet(facet); diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index ab897bff..f9510e77 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -29,8 +29,8 @@ define([ 'dojo/Stateful', 'dojo/Evented', './_base/metadata_provider', + './_base/Singleton_registry', './builder', - './facets', './ipa', './jquery', './navigation', @@ -42,7 +42,7 @@ define([ './field', './widget' ], function(declare, lang, construct, on, Stateful, Evented, metadata_provider, - builder, facets, IPA, $, navigation, phases, reg, su, text) { + Singleton_registry, builder, IPA, $, navigation, phases, reg, su, text) { /** * Facet represents the content of currently displayed page. @@ -1579,9 +1579,10 @@ exp.facet_preops = { } }; -phases.on('registration', function() { +exp.register_facets = function() { - facets.register({ + var f = reg.facet; + f.register({ type: 'search', factory: IPA.search_facet, pre_ops: [ @@ -1589,7 +1590,7 @@ phases.on('registration', function() { ] }); - facets.register({ + f.register({ type: 'nested_search', factory: IPA.nested_search_facet, pre_ops: [ @@ -1597,7 +1598,7 @@ phases.on('registration', function() { ] }); - facets.register({ + f.register({ type: 'details', factory: IPA.details_facet, pre_ops: [ @@ -1605,7 +1606,7 @@ phases.on('registration', function() { ] }); - facets.register({ + f.register({ type: 'association', factory: IPA.association_facet, pre_ops: [ @@ -1613,14 +1614,14 @@ phases.on('registration', function() { ] }); - facets.register({ + f.register({ type: 'attribute', factory: IPA.attribute_facet, pre_ops: [ exp.facet_preops.attribute ] }); -}); +}; exp.action = IPA.action = function(spec) { @@ -2421,6 +2422,10 @@ var FacetState = exp.FacetState = declare([Stateful, Evented], { } }); +// Facet builder and registry +var registry = new Singleton_registry(); +reg.set('facet', registry); +builder.set('facet', registry.builder); // Action builder and registry exp.action_builder = builder.get('action'); @@ -2441,6 +2446,7 @@ exp.register = function() { }; phases.on('registration', exp.register); +phases.on('registration', exp.register_facets); return exp; }); diff --git a/install/ui/src/freeipa/navigation/Router.js b/install/ui/src/freeipa/navigation/Router.js index ae29ee17..09aed16a 100644 --- a/install/ui/src/freeipa/navigation/Router.js +++ b/install/ui/src/freeipa/navigation/Router.js @@ -24,11 +24,10 @@ define(['dojo/_base/declare', 'dojo/Evented', 'dojo/io-query', 'dojo/router', - '../entities', - '../facets', - '../ipa' //TODO: remove dependancy + '../ipa', + '../reg' ], - function(declare, lang, array, Evented, ioquery, router, entities, facets, IPA) { + function(declare, lang, array, Evented, ioquery, router, IPA, reg) { /** * Class navigation @@ -132,8 +131,7 @@ define(['dojo/_base/declare', args.pkeys = pkeys; // set new facet state - //var entity = entities.get(entity_name); - var entity = IPA.get_entity(entity_name); // TODO: replace with prev line + var entity = reg.entity.get(entity_name); var facet = entity.get_facet(facet_name); facet.reset_state(args); @@ -151,16 +149,8 @@ define(['dojo/_base/declare', var facet_name = event.params.page; var args = ioquery.queryToObject(event.params.args || ''); -// // Find menu item -// var items = this.menu.items.query({ page: facet_name }); -// -// // Select menu item -// if (items.total > 0) { -// this.menu.select(items[items.total-1]); -// } - // set new facet state - var facet = facets.get(facet_name); + var facet = reg.facet.get(facet_name); facet.reset_state(args); this.show_facet(facet); @@ -173,8 +163,7 @@ define(['dojo/_base/declare', */ navigate_to_entity_facet: function(entity_name, facet_name, pkeys, args) { - //var entity = entities.get(entity_name); - var entity = IPA.get_entity(entity_name); // TODO: replace with prev line + var entity = reg.entity.get(entity_name); var facet = entity.get_facet(facet_name); if (!facet) return false; // TODO: maybe replace with exception @@ -197,11 +186,10 @@ define(['dojo/_base/declare', */ navigate_to_facet: function(facet_name, args) { - // TODO: uncoment when `facets` are implemented -// var facet = facets.get(facet_name); -// if (!args) args = facet.get_args(); -// var hash = this._create_facet_hash(facet, { args: args }); -// return this.navigate_to_hash(hash, facet); + var facet = reg.facet.get(facet_name); + if (!args) args = facet.get_state(); + var hash = this._create_facet_hash(facet, args); + return this.navigate_to_hash(hash, facet); }, /** diff --git a/install/ui/test/aci_tests.js b/install/ui/test/aci_tests.js index a98c45a1..a819d3f1 100644 --- a/install/ui/test/aci_tests.js +++ b/install/ui/test/aci_tests.js @@ -19,6 +19,7 @@ */ define([ + 'freeipa/_base/metadata_provider', 'freeipa/aci', 'freeipa/details', 'freeipa/facet', @@ -28,7 +29,7 @@ define([ 'freeipa/reg', 'freeipa/widget' ], - function(aci, mod_details, mod_facet, fields, IPA, $, reg, widgets) { + function(md, aci, mod_details, mod_facet, fields, IPA, $, reg, widgets) { return function() { var target_container; @@ -135,7 +136,7 @@ module('aci', { test("IPA.attributes_widget.", function() { - var aciattrs = IPA.metadata.objects['user'].aciattrs; + var aciattrs = md.source.objects.user.aciattrs; var container = $('<span/>', { name: 'attrs' diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 71eccfb4..cc087a6b 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -19,16 +19,16 @@ */ define([ + 'freeipa/_base/metadata_provider', 'freeipa/ipa', 'freeipa/jquery', 'freeipa/details', 'freeipa/facet', - 'freeipa/facets', 'freeipa/reg', 'freeipa/entity', 'freeipa/field', 'freeipa/widget'], - function(IPA, $, mod_details, mod_facet, facets, reg) { + function(md, IPA, $, mod_details, mod_facet, reg) { return function() { var details_container; @@ -38,7 +38,7 @@ module('details', { setup: function() { IPA.ajax_options.async = false; - facets.register({ + reg.facet.register({ type: 'details', factory: IPA.details_facet, pre_ops: [ @@ -62,13 +62,13 @@ module('details', { return IPA.entity({ name: 'user', - metadata: IPA.metadata.objects.user + metadata: md.source.objects.user }); }); }, teardown: function() { details_container.remove(); - facets.remove('details'); + reg.facet.remove('details'); } }); diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index 5a085f7a..8dbeab2f 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -23,11 +23,11 @@ define([ 'freeipa/ipa', 'freeipa/jquery', 'freeipa/facet', - 'freeipa/facets', 'freeipa/search', + 'freeipa/reg', 'freeipa/entity', 'freeipa/details'], - function(IPA, $, mod_facet, facets, mod_search) { + function(IPA, $, mod_facet, mod_search, reg) { return function() { var container; @@ -39,7 +39,7 @@ module('entity',{ mod_search.register(); - facets.register({ + reg.facet.register({ type: 'search', factory: IPA.search_facet, pre_ops: [ @@ -76,7 +76,7 @@ module('entity',{ }, teardown: function() { container.remove(); - facets.remove('search'); + reg.facet.remove('search'); } }); |