From f9a8d772e35982bed1c39b286b3120b9b5f64c0c Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 13 May 2011 20:05:35 -0500 Subject: Customizable facet groups. The IPA.entity has been modified to support customizable facet groups. The default list of facet groups is defined in IPA.entity_header and can be overriden in the entity definition. Ticket #1219 --- install/ui/entity.js | 400 +++++++++++++++++++++++++++------------------------ 1 file changed, 215 insertions(+), 185 deletions(-) (limited to 'install/ui/entity.js') diff --git a/install/ui/entity.js b/install/ui/entity.js index f649833e..dbee2b32 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -39,6 +39,7 @@ IPA.facet = function (spec) { that.dialogs = []; that.dialogs_by_name = {}; + // facet group name that.facet_group = spec.facet_group; that.__defineGetter__('entity_name', function() { @@ -203,16 +204,29 @@ IPA.table_facet = function(spec) { return that; }; -IPA.fetch_facet_group = function (name,attribute_member){ - var relationships = IPA.metadata.objects[name].relationships; - var relationship = relationships[attribute_member]; - if (!relationship){ - relationship = ['Member', '', 'no_']; - } - var facet_group = relationship[0]; - return facet_group; -}; +IPA.facet_group = function(spec) { + spec = spec || {}; + + var that = {}; + + that.name = spec.name; + that.label = spec.label; + + that.facets = []; + that.facets_by_name = {}; + + that.add_facet = function(facet) { + that.facets.push(facet); + that.facets_by_name[facet.name] = facet; + }; + + that.get_facet = function(name) { + return that.facets_by_name[name]; + }; + + return that; +}; IPA.entity = function (spec) { @@ -231,13 +245,11 @@ IPA.entity = function (spec) { that.facets = []; that.facets_by_name = {}; + // current facet that.facet_name = null; - /*TODO: Facet_groups are currently unordered. If we need to - * maintain order, we will introduce a class that keeps the order - in an array, while maintaining the dictionary for direct access.*/ - that.facet_groups = {}; - that.autogenerate_associations = false; + that.facet_groups = []; + that.facet_groups_by_name = {}; that.get_dialog = function(name) { return that.dialogs_by_name[name]; @@ -254,31 +266,30 @@ IPA.entity = function (spec) { return that; }; - function init_dialogs (){ - var i; - for (i = 0; i < that.dialogs.length; i += 1){ - that.dialogs[i].init(); - } - return that; - } + that.add_facet_group = function(facet_group) { + that.facet_groups.push(facet_group); + that.facet_groups_by_name[facet_group.name] = facet_group; + }; + + that.get_facet_group = function(name) { + return that.facet_groups_by_name[name]; + }; + + that.remove_facet_groups = function() { + that.facet_groups = []; + that.facet_groups_by_name = {}; + }; that.get_facet = function(name) { - if (name === 'default'){ - var facet_group; - var facet; - if (that.facet_groups["Member"]){ - facet_group = that.facet_groups["Member"]; - facet = facet_group[0]; - } else if (that.facets_by_name.details){ - facet= that.facets_by_name.details; - }else if (that.facet_groups["Member Of"]){ - facet_group = that.facet_groups["Member Of"]; - facet = facet_group[0]; - } - if (facet){ - name = facet.name; - return facet; + if (name === 'default') { + // return the first facet in the first facet group + for (var i=0; i', { 'class': 'facet-tab-group' - }).appendTo(container); + }).appendTo(that.facet_tabs); $('