From 5fc064f13e44812042a617a322bcd6111d2b39b2 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 7 Nov 2011 14:21:45 -0600 Subject: Refactored entity object resolution. The IPA.get_entity() has been modified to accept either entity name or entity object. If it receives an entity object it will return the object itself. Otherwise, it will resolve the name in the entity registry. The other_entity variables have been modified to store a reference to the entity object instead of its name. The test cases have been modified to use real entity objects instead of just the names. Ticket #2042 --- install/ui/widget.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 29c133c0a..43910d6e6 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -36,7 +36,7 @@ IPA.widget = function(spec) { that.id = spec.id; that.label = spec.label; that.tooltip = spec.tooltip; - that.entity = spec.entity; //some old widgets still need it + that.entity = IPA.get_entity(spec.entity); //some old widgets still need it that.create = function(container) { container.addClass('widget'); @@ -932,20 +932,20 @@ IPA.column = function (spec) { var that = {}; + that.entity = IPA.get_entity(spec.entity); that.name = spec.name; + that.label = spec.label; that.width = spec.width; - that.entity_name = spec.entity ? spec.entity.name : spec.entity_name; that.primary_key = spec.primary_key; that.link = spec.link; that.format = spec.format; - if (!that.entity_name){ - var except = { + if (!that.entity) { + throw { expected: false, - message:'Column created without an entity_name.' + message: 'Column created without an entity.' }; - throw except; } that.setup = function(container, record, suppress_link) { @@ -978,8 +978,8 @@ IPA.column = function (spec) { /*column initialization*/ - if (that.entity_name && !that.label) { - var metadata = IPA.get_entity_param(that.entity_name, that.name); + if (that.entity && !that.label) { + var metadata = IPA.get_entity_param(that.entity.name, that.name); if (metadata) { that.label = metadata.label; } @@ -1726,14 +1726,14 @@ IPA.entity_select_widget = function(spec) { var that = IPA.combobox_widget(spec); - that.other_entity = spec.other_entity; + that.other_entity = IPA.get_entity(spec.other_entity); that.other_field = spec.other_field; that.options = spec.options || []; that.create_search_command = function(filter) { return IPA.command({ - entity: that.other_entity, + entity: that.other_entity.name, method: 'find', args: [filter] }); -- cgit