From d6343f4bb079eec744553078c75205abec7e692d Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 13 Jun 2011 23:18:57 -0500 Subject: Fixed self-service links. In self-service mode the user's association facets have been modified such that the entries are not linked since the only available entity is the user entity. A 'link' parameter has been added to IPA.association_facet and IPA.column to control whether to link the entries. The link_handler() method can be used to define how to handle the link. Ticket #1072 --- install/ui/add.js | 2 +- install/ui/association.js | 79 +++++++++++++---------------------------------- install/ui/dialog.js | 2 ++ install/ui/entity.js | 29 ++++++++--------- install/ui/group.js | 2 +- install/ui/hbac.js | 21 ++----------- install/ui/host.js | 22 ++----------- install/ui/navigation.js | 2 ++ install/ui/search.js | 28 ++++------------- install/ui/service.js | 22 ++----------- install/ui/sudo.js | 4 +-- install/ui/user.js | 21 ++++++++----- install/ui/webui.js | 7 +++-- install/ui/widget.js | 34 ++++++++++++++------ 14 files changed, 98 insertions(+), 177 deletions(-) (limited to 'install') diff --git a/install/ui/add.js b/install/ui/add.js index 33df62abc..cde6d335b 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -83,7 +83,7 @@ IPA.add_dialog = function (spec) { pkey = pkey[0]; } - IPA.nav.show_page(that.entity_name, 'details', pkey); + IPA.nav.show_page(that.entity_name, 'default', pkey); } ); }); diff --git a/install/ui/association.js b/install/ui/association.js index 2115e0fe1..8030631b4 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -277,25 +277,6 @@ IPA.association_config = function (spec) { return that; }; - -IPA.association_pkey_setup = function (container, record) { - var other_entity = this.entity_name; - container.empty(); - var value = record[this.name]; - value = value ? value.toString() : ''; - $('', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(other_entity, 'default', value); - return false; - }; - }(value) - }).appendTo(container); -}; - - IPA.association_table_widget = function (spec) { spec = spec || {}; @@ -325,14 +306,6 @@ IPA.association_table_widget = function (spec) { return column; }; - that.super_create_column = that.create_column; - - that.create_column = function(spec){ - if (spec.link_entity){ - spec.setup = IPA.association_pkey_setup; - } - return that.super_create_column(spec); - }; /*this is duplicated in the facet... should be unified*/ var i; if (spec.columns){ @@ -363,6 +336,13 @@ IPA.association_table_widget = function (spec) { for (var i=0; i', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(that.other_entity, 'default', value); - return false; - }; - }(value) - }).appendTo(container); - }; } + that.table.set_columns(columns); + for (i=0; i', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(that.other_entity, 'details', value); - return false; - }; - }(value) - }).appendTo(container); - }; - that.create_column({ name: 'description', width: '350px' diff --git a/install/ui/host.js b/install/ui/host.js index cece90d11..fe35e0f1f 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -365,34 +365,16 @@ IPA.host_managedby_host_facet = function (spec) { var column = that.create_column({ name: 'fqdn', - primary_key: true + primary_key: true, + link: true }); - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(that.other_entity, 'details', value); - return false; - }; - }(value) - }).appendTo(container); - }; - that.create_adder_column({ name: 'fqdn', primary_key: true, width: '200px' }); - that.association_facet_init(); }; diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 875f4056c..8e332cf67 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -27,6 +27,8 @@ IPA.navigation = function(spec) { var that = {}; + that.name = spec.name; + that.container = spec.container; that.content = spec.content; that.tab_class = spec.tab_class || 'tabs'; diff --git a/install/ui/search.js b/install/ui/search.js index 5a9b14f05..9d6e51369 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -51,26 +51,6 @@ IPA.search_facet = function(spec) { that.init_table = function(entity){ - function setup_column(column,entity) { - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(entity.name, 'default', value); - return false; - }; - }(value) - }).appendTo(container); - }; - } - that.table = IPA.table_widget({ id: entity.name+'-search', 'class': 'content-table', @@ -88,9 +68,13 @@ IPA.search_facet = function(spec) { var param_info = IPA.get_entity_param(entity.name, column.name); column.primary_key = param_info && param_info['primary_key']; + column.link = column.primary_key; - if (column.primary_key) { - setup_column(column,entity); + if (column.link) { + column.link_handler = function(value) { + IPA.nav.show_page(entity.name, 'default', value); + return false; + }; } that.table.add_column(column); diff --git a/install/ui/service.js b/install/ui/service.js index 9b9b1d59b..7af80c7ee 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -355,28 +355,10 @@ IPA.service_managedby_host_facet = function(spec) { var column = that.create_column({ name: 'fqdn', - primary_key: true + primary_key: true, + link: true }); - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - IPA.nav.show_page(that.other_entity, 'details', value); - return false; - }; - }(value) - }).appendTo(container); - }; - - that.create_adder_column({ name: 'fqdn', primary_key: true, diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 9624ae824..b3882b05f 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -66,7 +66,7 @@ IPA.entity_factories.sudocmd = function () { name: 'cn', primary_key: true, width: '150px', - link_entity: true + link: true }, { name: 'description', @@ -120,7 +120,7 @@ IPA.entity_factories.sudocmdgroup = function () { name: 'sudocmd', primary_key: true, width: '150px', - link_entity: true + link: true }, { name: 'description', diff --git a/install/ui/user.js b/install/ui/user.js index 63c2ec4c8..8a8f9443d 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -26,6 +26,11 @@ IPA.entity_factories.user = function() { + var link = true; + if (IPA.nav && IPA.nav.name == 'self-service') { + link = false; + } + var builder = IPA.entity_builder(); builder. @@ -90,17 +95,22 @@ IPA.entity_factories.user = function() { }]}). association_facet({ name: 'memberof_group', - associator: IPA.serial_associator + associator: IPA.serial_associator, + link: link }). association_facet({ name: 'memberof_netgroup', - associator: IPA.serial_associator + associator: IPA.serial_associator, + link: link }). association_facet({ name: 'memberof_role', - associator: IPA.serial_associator + associator: IPA.serial_associator, + link: link + }). + standard_association_facets({ + link: link }). - standard_association_facets(). adder_dialog({ fields: ['uid', 'givenname', 'sn'] }); @@ -108,9 +118,6 @@ IPA.entity_factories.user = function() { return builder.build(); }; -/* ATTRIBUTE CALLBACKS */ - - IPA.user_status_widget = function(spec) { spec = spec || {}; diff --git a/install/ui/webui.js b/install/ui/webui.js index 94c20d4a9..c014cea72 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -30,6 +30,8 @@ IPA.admin_navigation = function(spec) { spec = spec || {}; + spec.name = 'admin'; + spec.tabs = [ {name: 'identity', label: IPA.messages.tabs.identity, children: [ {entity: 'user'}, @@ -79,10 +81,11 @@ IPA.self_serv_navigation = function(spec) { spec = spec || {}; + spec.name = 'self-service'; + spec.tabs = [ {name: 'identity', label: IPA.messages.tabs.identity, children: [ - {entity: 'user'}, - {entity: 'group'} + {entity: 'user'} ]}]; var that = IPA.navigation(spec); diff --git a/install/ui/widget.js b/install/ui/widget.js index 1af9fd839..3e31b4c4a 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1014,39 +1014,53 @@ IPA.column = function (spec) { that.name = spec.name; that.label = spec.label; - that.primary_key = spec.primary_key; that.width = spec.width; + that.entity_name = spec.entity_name; - that.format = spec.format; + that.primary_key = spec.primary_key; + that.link = spec.link; - that.setup = spec.setup || setup; + that.format = spec.format; that.init = function() { if (that.entity_name && !that.label) { var param_info = IPA.get_entity_param(that.entity_name, that.name); if (param_info) { that.label = param_info.label; - }else{ + } else { alert('cannot find label for ' + that.entity_name + ' ' + that.name); } } }; - function setup(container, record) { - + that.setup = function(container, record) { container.empty(); var value = record[that.name]; - if (that.format && value){ + if (that.format && value) { value = that.format(value); } - value = value ? value.toString() : ''; + if (that.link) { + $('', { + href: '#'+value, + html: value, + click: function() { + return that.link_handler(value); + } + }).appendTo(container); + + } else { + container.append(value); + } + + }; - container.append(value); - } + that.link_handler = function(value) { + return false; + }; return that; }; -- cgit