From 69307f0589fd34ca84e6a81fcee1751d50255b19 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Jan 11 2012 17:04:21 +0000 Subject: Fixed displaying of external records in rule association widgets It's a fix for regression introduced by widget refactoring #2040. https://fedorahosted.org/freeipa/ticket/2040 --- diff --git a/install/ui/association.js b/install/ui/association.js index 9d7950d..708b237 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -305,6 +305,8 @@ IPA.association_table_widget = function (spec) { that.adder_columns = $.ordered_map(); + that.needs_refresh = IPA.observer(); + that.get_adder_column = function(name) { return that.adder_columns.get(name); }; @@ -644,24 +646,7 @@ IPA.association_table_widget = function (spec) { that.refresh = function() { - function on_success(data, text_status, xhr) { - that.load(data.result.result); - } - - function on_error(xhr, text_status, error_thrown) { - var summary = $('span[name=summary]', that.tfoot).empty(); - summary.append(error_thrown.name+': '+error_thrown.message); - } - - var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); - IPA.command({ - entity: that.entity.name, - method: 'show', - args: [pkey], - options: { all: true, rights: true }, - on_success: on_success, - on_error: on_error - }).execute(); + that.needs_refresh.notify([], that); }; /*initialization code*/ @@ -687,6 +672,45 @@ IPA.association_table_widget = function (spec) { return that; }; +IPA.association_table_field = function (spec) { + + spec = spec || {}; + + var that = IPA.field(spec); + + that.refresh = function() { + + function on_success(data, text_status, xhr) { + that.load(data.result.result); + } + + function on_error(xhr, text_status, error_thrown) { + that.widget.summary.text(error_thrown.name+': '+error_thrown.message); + } + + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); + IPA.command({ + entity: that.entity.name, + method: 'show', + args: [pkey], + options: { all: true, rights: true }, + on_success: on_success, + on_error: on_error + }).execute(); + }; + + that.widgets_created = function() { + + that.field_widgets_created(); + that.widget.needs_refresh.attach(that.refresh); + }; + + return that; +}; + +IPA.widget_factories['association_table'] = IPA.association_table_widget; +IPA.field_factories['association_table'] = IPA.association_table_field; + IPA.association_facet = function (spec) { diff --git a/install/ui/rule.js b/install/ui/rule.js index 003785b..d36cd3d 100644 --- a/install/ui/rule.js +++ b/install/ui/rule.js @@ -134,10 +134,14 @@ IPA.rule_association_table_field = function(spec) { spec = spec || {}; - var that = IPA.field(spec); + var that = IPA.association_table_field(spec); + + that.external = spec.external; + that.load = function(result) { that.values = result[that.name] || []; + if (that.external) { var external_values = result[that.external] || []; $.merge(that.values, external_values); diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 5e1dedc..9914618 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -278,6 +278,7 @@ IPA.sudorule_details_facet = function(spec) { type: 'rule_association_table', name: 'memberuser_user', widget: 'user.rule.memberuser_user', + external: 'externaluser', priority: IPA.sudo.remove_method_priority }, { @@ -352,6 +353,7 @@ IPA.sudorule_details_facet = function(spec) { type: 'rule_association_table', name: 'memberhost_host', widget: 'host.rule.memberhost_host', + external: 'externalhost', priority: IPA.sudo.remove_method_priority }, { @@ -541,6 +543,7 @@ IPA.sudorule_details_facet = function(spec) { type: 'rule_association_table', name: 'ipasudorunas_user', widget: 'runas.runas_users.ipasudorunas_user', + external: 'ipasudorunasextuser', priority: IPA.sudo.remove_method_priority }, { @@ -558,6 +561,7 @@ IPA.sudorule_details_facet = function(spec) { type: 'rule_association_table', name: 'ipasudorunasgroup_group', widget: 'runas.runas_groups.ipasudorunasgroup_group', + external: 'ipasudorunasextgroup', priority: IPA.sudo.remove_method_priority } );