From a8ea42bda841c8773d68886614faf9efd38e33bd Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Wed, 16 Nov 2011 21:07:20 -0600 Subject: Fixed entity metadata resolution. The current code assumes that an entity will always have a corresponding LDAPObject on the server, so it looks for the metadata in a fixed location. This assumption doesn't work for HBAC Test since it is a Command, not an LDAPObject, so the metadata has to be obtained from a different location. A new method get_default_metadata() has been added to allow each entity to find the metadata from the correct location. Ticket #388 --- install/ui/entity.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'install/ui/entity.js') diff --git a/install/ui/entity.js b/install/ui/entity.js index 4e5c7244..a701009a 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -32,10 +32,12 @@ IPA.entity = function(spec) { spec = spec || {}; var that = {}; - that.metadata = spec.metadata; + that.name = spec.name; - that.label = spec.label || spec.metadata.label || spec.name; - that.title = spec.title || that.label; + that.label = spec.label; + + that.metadata = spec.metadata; + that.builder = spec.builder; that.dialogs = $.ordered_map(); that.dialog_specs = spec.dialogs || []; @@ -52,7 +54,21 @@ IPA.entity = function(spec) { that.redirect_facet = spec.redirect_facet; that.containing_entity = null; - that.init = function(params) { + that.init = function() { + if (!that.metadata) { + that.metadata = that.get_default_metadata(); + if (!that.metadata) { + throw { + expected: true, + message: "Entity " + that.name + " not supported by server." + }; + } + } + that.label = that.label || that.metadata.label || that.name; + }; + + that.get_default_metadata = function() { + return IPA.metadata.objects[that.name]; }; that.get_containing_entity = function() { @@ -210,6 +226,7 @@ IPA.entity = function(spec) { pkey.unshift(IPA.nav.get_state(current_entity.name+'-pkey')); return pkey; }; + /* most entites only require -pkey for their primary keys, but some are more specific. This call allows those entites a place to override the other parameters. */ @@ -305,14 +322,6 @@ IPA.entity_builder = function() { spec = { name: spec }; } - spec.metadata = spec.metadata || IPA.metadata.objects[spec.name]; - if (!spec.metadata) { - throw { - expected: true, - message: "Entity " + spec.name + "not supported by server." - }; - } - entity = factory(spec); that.facet_groups([ -- cgit