From a7f9814ab702cfa42988e47e80f44b57a195ad1e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 16 May 2011 14:40:09 -0500 Subject: Read-only association facet. The IPA.association_facet has been modified to take a read_only parameters. If the parameter is set to true, the Enroll and Delete buttons will not be shown. All facets under the memberindirect and memberofindirect facet groups are marked as read-only. Ticket #1030 --- install/ui/associate.js | 65 +++++++++++------------------- install/ui/details.js | 2 +- install/ui/entitle.js | 2 +- install/ui/entity.js | 71 +++++++++++++++++++++++---------- install/ui/hbac.js | 5 +-- install/ui/search.js | 2 - install/ui/sudo.js | 5 +-- install/ui/test/data/i18n_messages.json | 2 +- install/ui/test/data/ipa_init.json | 2 +- 9 files changed, 83 insertions(+), 73 deletions(-) (limited to 'install/ui') diff --git a/install/ui/associate.js b/install/ui/associate.js index 679e0070..9d04b0c8 100644 --- a/install/ui/associate.js +++ b/install/ui/associate.js @@ -668,7 +668,6 @@ IPA.association_facet = function (spec) { that.other_entity = spec.other_entity; that.facet_group = spec.facet_group; - that.label = that.label ? that.label : (IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity); that.read_only = spec.read_only; that.associator = spec.associator || IPA.bulk_associator; @@ -734,18 +733,15 @@ IPA.association_facet = function (spec) { var column; var i; - - - var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity; var pkey_name = IPA.metadata.objects[that.other_entity].primary_key; that.table = IPA.table_widget({ - 'id': that.entity_name+'-'+that.other_entity, - 'name': pkey_name, - 'label': label, - 'entity_name': that.entity_name, - 'other_entity': that.other_entity + id: that.entity_name+'-'+that.other_entity, + name: pkey_name, + label: label, + entity_name: that.entity_name, + other_entity: that.other_entity }); if (that.columns.length) { @@ -801,47 +797,34 @@ IPA.association_facet = function (spec) { that.facet_create_header(container); that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - - var relationships = IPA.metadata.objects[that.entity_name].relationships; - var relationship = relationships[that.attribute_member]; - if (!relationship) { - relationship = ['', '', '']; - } - var other_label = IPA.metadata.objects[that.other_entity].label; - /* TODO: generic handling of different relationships */ - var title = ''; - if (relationship[0] == 'Member') { - title = IPA.messages.association.member; - - } else if (relationship[0] == 'Member Of') { - title = IPA.messages.association.parent; - } - + var title = that.title; title = title.replace('${entity}', that.entity_name); title = title.replace('${primary_key}', that.pkey); title = title.replace('${other_entity}', other_label); that.set_title(container, title); - that.remove_button = IPA.action_button({ - label: IPA.messages.buttons.remove, - icon: 'ui-icon-trash', - click: function() { - that.show_remove_dialog(); - return false; - } - }).appendTo(that.controls); + if (!that.read_only) { + that.remove_button = IPA.action_button({ + label: IPA.messages.buttons.remove, + icon: 'ui-icon-trash', + click: function() { + that.show_remove_dialog(); + return false; + } + }).appendTo(that.controls); - that.add_button = IPA.action_button({ - label: IPA.messages.buttons.enroll, - icon: 'ui-icon-plus', - click: function() { - that.show_add_dialog(); - return false; - } - }).appendTo(that.controls); + that.add_button = IPA.action_button({ + label: IPA.messages.buttons.enroll, + icon: 'ui-icon-plus', + click: function() { + that.show_add_dialog(); + return false; + } + }).appendTo(that.controls); + } }; that.create_content = function(container) { diff --git a/install/ui/details.js b/install/ui/details.js index 44560b5b..e8033b30 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -324,7 +324,7 @@ IPA.details_facet = function(spec) { that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; var label = IPA.metadata.objects[that.entity_name].label; - var title = IPA.messages.details.settings; + var title = that.title; title = title.replace('${entity}', label); title = title.replace('${primary_key}', that.pkey); diff --git a/install/ui/entitle.js b/install/ui/entitle.js index 604bea90..7d56415c 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -38,7 +38,7 @@ IPA.entity_factories.entitle = function() { factory: IPA.entitle.entity, name: 'entitle' }). - facet({ + search_facet({ factory: IPA.entitle.search_facet, columns: [ { diff --git a/install/ui/entity.js b/install/ui/entity.js index dbee2b32..22d3eaff 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -34,6 +34,7 @@ IPA.facet = function (spec) { that.display_class = spec.display_class || 'entity-facet'; that.name = spec.name; that.label = spec.label; + that.title = spec.title || that.label; that._entity_name = spec.entity_name; that.dialogs = []; @@ -86,13 +87,13 @@ IPA.facet = function (spec) { that.create_header = function(container) { - that.title = $('
', { + that.title_container = $('
', { 'class': 'facet-title' }).appendTo(container); - $('

').append(IPA.create_network_spinner()).appendTo(that.title); + $('

').append(IPA.create_network_spinner()).appendTo(that.title_container); - that.set_title(container, that.label); + that.set_title(container, that.title); that.controls = $('
', { 'class': 'facet-controls' @@ -103,7 +104,7 @@ IPA.facet = function (spec) { }; that.set_title = function(container, title) { - var element = $('h1', that.title); + var element = $('h1', that.title_container); element.html(title); }; @@ -533,13 +534,13 @@ IPA.entity_header = function(spec) { that.create = function(container) { - that.title = $('
', { + that.title_container = $('
', { 'class': 'entity-title' }).appendTo(container); var title_text = $('

', { text: that.entity.metadata.label - }).appendTo(that.title); + }).appendTo(that.title_container); that.pkey = $('').appendTo(title_text); @@ -611,8 +612,10 @@ IPA.entity_builder = function(){ that.facet_groups([ 'member', + 'memberindirect', 'settings', 'memberof', + 'memberofindirect', 'managedby' ]); @@ -658,31 +661,42 @@ IPA.entity_builder = function(){ }; that.facet = function(spec) { + spec.entity_name = entity.name; + facet = spec.factory(spec); entity.add_facet(facet); + return that; }; that.search_facet = function(spec) { - facet = IPA.search_facet({ - entity_name: entity.name, - search_all: spec.search_all || false, - columns: spec.columns - }); + + spec.entity_name = entity.name; + spec.label = spec.label || IPA.messages.facets.search; + + var factory = spec.factory || IPA.search_facet; + facet = factory(spec); entity.add_facet(facet); + return that; }; that.details_facet = function(spec) { + var sections = spec.sections; spec.sections = null; spec.entity_name = entity.name; - facet = IPA.details_facet(spec); + spec.label = IPA.messages.details.settings; + + var factory = spec.factory || IPA.details_facet; + facet = factory(spec); entity.add_facet(facet); - for (var i=0; i