mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
committed by
Adam Young
parent
f9a8d772e3
commit
a7f9814ab7
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ IPA.entity_factories.entitle = function() {
|
||||
factory: IPA.entitle.entity,
|
||||
name: 'entitle'
|
||||
}).
|
||||
facet({
|
||||
search_facet({
|
||||
factory: IPA.entitle.search_facet,
|
||||
columns: [
|
||||
{
|
||||
|
||||
@@ -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 = $('<div/>', {
|
||||
that.title_container = $('<div/>', {
|
||||
'class': 'facet-title'
|
||||
}).appendTo(container);
|
||||
|
||||
$('<h1/>').append(IPA.create_network_spinner()).appendTo(that.title);
|
||||
$('<h1/>').append(IPA.create_network_spinner()).appendTo(that.title_container);
|
||||
|
||||
that.set_title(container, that.label);
|
||||
that.set_title(container, that.title);
|
||||
|
||||
that.controls = $('<div/>', {
|
||||
'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 = $('<div/>', {
|
||||
that.title_container = $('<div/>', {
|
||||
'class': 'entity-title'
|
||||
}).appendTo(container);
|
||||
|
||||
var title_text = $('<h3/>', {
|
||||
text: that.entity.metadata.label
|
||||
}).appendTo(that.title);
|
||||
}).appendTo(that.title_container);
|
||||
|
||||
that.pkey = $('<span/>').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<sections.length; i++) {
|
||||
that.section(sections[i]);
|
||||
if (sections) {
|
||||
for (var i=0; i<sections.length; i++) {
|
||||
that.section(sections[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
@@ -698,7 +712,24 @@ IPA.entity_builder = function(){
|
||||
|
||||
spec.facet_group = spec.facet_group || spec.attribute_member;
|
||||
|
||||
entity.add_facet(IPA.association_facet(spec));
|
||||
if (spec.facet_group == 'memberindirect' || spec.facet_group == 'memberofindirect') {
|
||||
spec.read_only = true;
|
||||
}
|
||||
|
||||
spec.label = spec.label || (IPA.metadata.objects[spec.other_entity] ? IPA.metadata.objects[spec.other_entity].label : spec.other_entity);
|
||||
|
||||
if (!spec.title) {
|
||||
if (spec.facet_group == 'member' || spec.facet_group == 'memberindirect') {
|
||||
spec.title = IPA.messages.association.member;
|
||||
|
||||
} else if (spec.facet_group == 'memberof' || spec.facet_group == 'memberofindirect') {
|
||||
spec.title = IPA.messages.association.memberof;
|
||||
}
|
||||
}
|
||||
|
||||
var factory = spec.factory || IPA.association_facet;
|
||||
facet = factory(spec);
|
||||
entity.add_facet(facet);
|
||||
|
||||
return that;
|
||||
};
|
||||
@@ -737,14 +768,14 @@ IPA.entity_builder = function(){
|
||||
that.section = function(spec) {
|
||||
spec.entity_name = entity.name;
|
||||
|
||||
if (!spec.label){
|
||||
if (!spec.label) {
|
||||
var obj_messages = IPA.messages.objects[entity.name];
|
||||
spec.label = obj_messages[spec.name];
|
||||
spec.label = obj_messages[spec.name];
|
||||
}
|
||||
|
||||
if (spec.factory){
|
||||
section = spec.factory(spec);
|
||||
}else{
|
||||
if (spec.factory) {
|
||||
section = spec.factory(spec);
|
||||
} else {
|
||||
section = IPA.details_list_section(spec);
|
||||
}
|
||||
facet.add_section(section);
|
||||
|
||||
@@ -29,9 +29,8 @@ IPA.entity_factories.hbacrule = function () {
|
||||
columns:['cn','usercategory','hostcategory','ipaenabledflag',
|
||||
'servicecategory','sourcehostcategory']
|
||||
}).
|
||||
facet({
|
||||
factory: IPA.hbacrule_details_facet,
|
||||
'name': 'details'
|
||||
details_facet({
|
||||
factory: IPA.hbacrule_details_facet
|
||||
}).
|
||||
adder_dialog({
|
||||
fields:[
|
||||
|
||||
@@ -29,8 +29,6 @@ IPA.search_facet = function(spec) {
|
||||
spec = spec || {};
|
||||
|
||||
spec.name = spec.name || 'search';
|
||||
spec.label = spec.label || IPA.messages.facets.search;
|
||||
|
||||
spec.display_class = 'search-facet';
|
||||
|
||||
var that = IPA.table_facet(spec);
|
||||
|
||||
@@ -30,9 +30,8 @@ IPA.entity_factories.sudorule = function () {
|
||||
search_facet({
|
||||
columns:['cn','description','cmdcategory']
|
||||
}).
|
||||
facet({
|
||||
factory: IPA.sudorule_details_facet,
|
||||
'name': 'details'
|
||||
details_facet({
|
||||
factory: IPA.sudorule_details_facet
|
||||
}).
|
||||
adder_dialog({
|
||||
fields:['cn']
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"association": {
|
||||
"add": "Add ${other_entity} into ${entity} ${primary_key}",
|
||||
"member": "${other_entity} enrolled in ${entity} ${primary_key}",
|
||||
"parent": "${entity} ${primary_key} is enrolled in the following ${other_entity}",
|
||||
"memberof": "${entity} ${primary_key} is enrolled in the following ${other_entity}",
|
||||
"remove": "Remove ${other_entity} from ${entity} ${primary_key}"
|
||||
},
|
||||
"buttons": {
|
||||
|
||||
@@ -9963,7 +9963,7 @@
|
||||
"association": {
|
||||
"add": "Add ${other_entity} into ${entity} ${primary_key}",
|
||||
"member": "${other_entity} enrolled in ${entity} ${primary_key}",
|
||||
"parent": "${entity} ${primary_key} is enrolled in the following ${other_entity}",
|
||||
"memberof": "${entity} ${primary_key} is enrolled in the following ${other_entity}",
|
||||
"remove": "Remove ${other_entity} from ${entity} ${primary_key}"
|
||||
},
|
||||
"buttons": {
|
||||
|
||||
@@ -378,7 +378,7 @@ class i18n_messages(Command):
|
||||
"association":{
|
||||
"add":_("Add ${other_entity} into ${entity} ${primary_key}"),
|
||||
"member":_("${other_entity} enrolled in ${entity} ${primary_key}"),
|
||||
"parent":_("${entity} ${primary_key} is enrolled in the following ${other_entity}"),
|
||||
"memberof":_("${entity} ${primary_key} is enrolled in the following ${other_entity}"),
|
||||
"remove":_("Remove ${other_entity} from ${entity} ${primary_key}"),
|
||||
},
|
||||
"widget":{
|
||||
|
||||
Reference in New Issue
Block a user