mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
parent
724dd99744
commit
d6343f4bb0
@ -83,7 +83,7 @@ IPA.add_dialog = function (spec) {
|
|||||||
pkey = pkey[0];
|
pkey = pkey[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
IPA.nav.show_page(that.entity_name, 'details', pkey);
|
IPA.nav.show_page(that.entity_name, 'default', pkey);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -277,25 +277,6 @@ IPA.association_config = function (spec) {
|
|||||||
return that;
|
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() : '';
|
|
||||||
$('<a/>', {
|
|
||||||
'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) {
|
IPA.association_table_widget = function (spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
@ -325,14 +306,6 @@ IPA.association_table_widget = function (spec) {
|
|||||||
return column;
|
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*/
|
/*this is duplicated in the facet... should be unified*/
|
||||||
var i;
|
var i;
|
||||||
if (spec.columns){
|
if (spec.columns){
|
||||||
@ -363,6 +336,13 @@ IPA.association_table_widget = function (spec) {
|
|||||||
for (var i=0; i<columns.length; i++) {
|
for (var i=0; i<columns.length; i++) {
|
||||||
column = columns[i];
|
column = columns[i];
|
||||||
column.entity_name = that.other_entity;
|
column.entity_name = that.other_entity;
|
||||||
|
|
||||||
|
if (column.link) {
|
||||||
|
column.link_handler = function(value) {
|
||||||
|
IPA.nav.show_page(that.other_entity, 'default', value);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var adder_columns = that.adder_columns.values;
|
var adder_columns = that.adder_columns.values;
|
||||||
@ -698,6 +678,7 @@ IPA.association_facet = function (spec) {
|
|||||||
that.facet_group = spec.facet_group;
|
that.facet_group = spec.facet_group;
|
||||||
|
|
||||||
that.read_only = spec.read_only;
|
that.read_only = spec.read_only;
|
||||||
|
that.link = spec.link === undefined ? true : spec.link;
|
||||||
|
|
||||||
that.associator = spec.associator || IPA.bulk_associator;
|
that.associator = spec.associator || IPA.bulk_associator;
|
||||||
that.add_method = spec.add_method || 'add_member';
|
that.add_method = spec.add_method || 'add_member';
|
||||||
@ -718,9 +699,6 @@ IPA.association_facet = function (spec) {
|
|||||||
|
|
||||||
that.create_column = function(spec) {
|
that.create_column = function(spec) {
|
||||||
var column = IPA.column(spec);
|
var column = IPA.column(spec);
|
||||||
if (spec.link_entity){
|
|
||||||
column.setup = IPA.association_pkey_setup;
|
|
||||||
}
|
|
||||||
that.add_column(column);
|
that.add_column(column);
|
||||||
return column;
|
return column;
|
||||||
};
|
};
|
||||||
@ -775,39 +753,26 @@ IPA.association_facet = function (spec) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var columns = that.columns.values;
|
var columns = that.columns.values;
|
||||||
if (columns.length) {
|
if (!columns.length) {
|
||||||
that.table.set_columns(columns);
|
that.create_column({
|
||||||
|
name: pkey_name,
|
||||||
} else {
|
primary_key: true,
|
||||||
|
link: that.link
|
||||||
column = that.table.create_column({
|
|
||||||
name: that.table.name,
|
|
||||||
label: IPA.metadata.objects[that.other_entity].label,
|
|
||||||
primary_key: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
column.setup = function(container, record) {
|
|
||||||
container.empty();
|
|
||||||
|
|
||||||
var value = record[column.name];
|
|
||||||
value = value ? value.toString() : '';
|
|
||||||
|
|
||||||
$('<a/>', {
|
|
||||||
'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<columns.length; i++) {
|
for (i=0; i<columns.length; i++) {
|
||||||
column = columns[i];
|
column = columns[i];
|
||||||
column.entity_name = that.other_entity;
|
column.entity_name = that.other_entity;
|
||||||
|
|
||||||
|
if (column.link) {
|
||||||
|
column.link_handler = function(value) {
|
||||||
|
IPA.nav.show_page(that.other_entity, 'default', value);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var adder_columns = that.adder_columns.values;
|
var adder_columns = that.adder_columns.values;
|
||||||
|
@ -526,6 +526,7 @@ IPA.adder_dialog = function (spec) {
|
|||||||
'label': button.val(),
|
'label': button.val(),
|
||||||
'click': function() {
|
'click': function() {
|
||||||
that.remove();
|
that.remove();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button.replaceWith(that.remove_button);
|
button.replaceWith(that.remove_button);
|
||||||
@ -535,6 +536,7 @@ IPA.adder_dialog = function (spec) {
|
|||||||
'label': button.val(),
|
'label': button.val(),
|
||||||
'click': function() {
|
'click': function() {
|
||||||
that.add();
|
that.add();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button.replaceWith(that.add_button);
|
button.replaceWith(that.add_button);
|
||||||
|
@ -819,18 +819,13 @@ IPA.entity_builder = function(){
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.standard_association_facets = function() {
|
that.standard_association_facets = function(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
var attribute_members = entity.metadata.attribute_members;
|
var attribute_members = entity.metadata.attribute_members;
|
||||||
|
|
||||||
for (var attribute_member in attribute_members) {
|
for (var attribute_member in attribute_members) {
|
||||||
that.association_facets(attribute_member);
|
|
||||||
}
|
|
||||||
|
|
||||||
return that;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.association_facets = function(attribute_member) {
|
|
||||||
|
|
||||||
var other_entities = entity.metadata.attribute_members[attribute_member];
|
var other_entities = entity.metadata.attribute_members[attribute_member];
|
||||||
|
|
||||||
@ -842,9 +837,11 @@ IPA.entity_builder = function(){
|
|||||||
var facet = entity.get_facet(association_name);
|
var facet = entity.get_facet(association_name);
|
||||||
if (facet) continue;
|
if (facet) continue;
|
||||||
|
|
||||||
that.association_facet({
|
var tmp_spec = $.extend({}, spec);
|
||||||
name: association_name
|
tmp_spec.name = association_name;
|
||||||
});
|
|
||||||
|
that.association_facet(tmp_spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
@ -42,7 +42,7 @@ IPA.entity_factories.group = function () {
|
|||||||
{
|
{
|
||||||
name: 'uid',
|
name: 'uid',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
link_entity: true
|
link: true
|
||||||
},
|
},
|
||||||
{name: 'uidnumber'},
|
{name: 'uidnumber'},
|
||||||
{name: 'mail'},
|
{name: 'mail'},
|
||||||
|
@ -106,27 +106,10 @@ IPA.hbacsvcgroup_member_hbacsvc_table_widget = function (spec) {
|
|||||||
var column = that.create_column({
|
var column = that.create_column({
|
||||||
name: 'cn',
|
name: 'cn',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
width: '150px'
|
width: '150px',
|
||||||
|
link: true
|
||||||
});
|
});
|
||||||
|
|
||||||
column.setup = function(container, record) {
|
|
||||||
container.empty();
|
|
||||||
|
|
||||||
var value = record[column.name];
|
|
||||||
value = value ? value.toString() : '';
|
|
||||||
|
|
||||||
$('<a/>', {
|
|
||||||
'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({
|
that.create_column({
|
||||||
name: 'description',
|
name: 'description',
|
||||||
width: '350px'
|
width: '350px'
|
||||||
|
@ -365,34 +365,16 @@ IPA.host_managedby_host_facet = function (spec) {
|
|||||||
|
|
||||||
var column = that.create_column({
|
var column = that.create_column({
|
||||||
name: 'fqdn',
|
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() : '';
|
|
||||||
|
|
||||||
$('<a/>', {
|
|
||||||
'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({
|
that.create_adder_column({
|
||||||
name: 'fqdn',
|
name: 'fqdn',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
width: '200px'
|
width: '200px'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
that.association_facet_init();
|
that.association_facet_init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ IPA.navigation = function(spec) {
|
|||||||
|
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
that.name = spec.name;
|
||||||
|
|
||||||
that.container = spec.container;
|
that.container = spec.container;
|
||||||
that.content = spec.content;
|
that.content = spec.content;
|
||||||
that.tab_class = spec.tab_class || 'tabs';
|
that.tab_class = spec.tab_class || 'tabs';
|
||||||
|
@ -51,26 +51,6 @@ IPA.search_facet = function(spec) {
|
|||||||
|
|
||||||
that.init_table = function(entity){
|
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() : '';
|
|
||||||
|
|
||||||
$('<a/>', {
|
|
||||||
'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({
|
that.table = IPA.table_widget({
|
||||||
id: entity.name+'-search',
|
id: entity.name+'-search',
|
||||||
'class': 'content-table',
|
'class': 'content-table',
|
||||||
@ -88,9 +68,13 @@ IPA.search_facet = function(spec) {
|
|||||||
|
|
||||||
var param_info = IPA.get_entity_param(entity.name, column.name);
|
var param_info = IPA.get_entity_param(entity.name, column.name);
|
||||||
column.primary_key = param_info && param_info['primary_key'];
|
column.primary_key = param_info && param_info['primary_key'];
|
||||||
|
column.link = column.primary_key;
|
||||||
|
|
||||||
if (column.primary_key) {
|
if (column.link) {
|
||||||
setup_column(column,entity);
|
column.link_handler = function(value) {
|
||||||
|
IPA.nav.show_page(entity.name, 'default', value);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
that.table.add_column(column);
|
that.table.add_column(column);
|
||||||
|
@ -355,28 +355,10 @@ IPA.service_managedby_host_facet = function(spec) {
|
|||||||
|
|
||||||
var column = that.create_column({
|
var column = that.create_column({
|
||||||
name: 'fqdn',
|
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() : '';
|
|
||||||
|
|
||||||
$('<a/>', {
|
|
||||||
'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({
|
that.create_adder_column({
|
||||||
name: 'fqdn',
|
name: 'fqdn',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
|
@ -66,7 +66,7 @@ IPA.entity_factories.sudocmd = function () {
|
|||||||
name: 'cn',
|
name: 'cn',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
width: '150px',
|
width: '150px',
|
||||||
link_entity: true
|
link: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'description',
|
name: 'description',
|
||||||
@ -120,7 +120,7 @@ IPA.entity_factories.sudocmdgroup = function () {
|
|||||||
name: 'sudocmd',
|
name: 'sudocmd',
|
||||||
primary_key: true,
|
primary_key: true,
|
||||||
width: '150px',
|
width: '150px',
|
||||||
link_entity: true
|
link: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'description',
|
name: 'description',
|
||||||
|
@ -26,6 +26,11 @@
|
|||||||
|
|
||||||
IPA.entity_factories.user = function() {
|
IPA.entity_factories.user = function() {
|
||||||
|
|
||||||
|
var link = true;
|
||||||
|
if (IPA.nav && IPA.nav.name == 'self-service') {
|
||||||
|
link = false;
|
||||||
|
}
|
||||||
|
|
||||||
var builder = IPA.entity_builder();
|
var builder = IPA.entity_builder();
|
||||||
|
|
||||||
builder.
|
builder.
|
||||||
@ -90,17 +95,22 @@ IPA.entity_factories.user = function() {
|
|||||||
}]}).
|
}]}).
|
||||||
association_facet({
|
association_facet({
|
||||||
name: 'memberof_group',
|
name: 'memberof_group',
|
||||||
associator: IPA.serial_associator
|
associator: IPA.serial_associator,
|
||||||
|
link: link
|
||||||
}).
|
}).
|
||||||
association_facet({
|
association_facet({
|
||||||
name: 'memberof_netgroup',
|
name: 'memberof_netgroup',
|
||||||
associator: IPA.serial_associator
|
associator: IPA.serial_associator,
|
||||||
|
link: link
|
||||||
}).
|
}).
|
||||||
association_facet({
|
association_facet({
|
||||||
name: 'memberof_role',
|
name: 'memberof_role',
|
||||||
associator: IPA.serial_associator
|
associator: IPA.serial_associator,
|
||||||
|
link: link
|
||||||
|
}).
|
||||||
|
standard_association_facets({
|
||||||
|
link: link
|
||||||
}).
|
}).
|
||||||
standard_association_facets().
|
|
||||||
adder_dialog({
|
adder_dialog({
|
||||||
fields: ['uid', 'givenname', 'sn']
|
fields: ['uid', 'givenname', 'sn']
|
||||||
});
|
});
|
||||||
@ -108,9 +118,6 @@ IPA.entity_factories.user = function() {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ATTRIBUTE CALLBACKS */
|
|
||||||
|
|
||||||
|
|
||||||
IPA.user_status_widget = function(spec) {
|
IPA.user_status_widget = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
@ -30,6 +30,8 @@ IPA.admin_navigation = function(spec) {
|
|||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
|
spec.name = 'admin';
|
||||||
|
|
||||||
spec.tabs = [
|
spec.tabs = [
|
||||||
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
||||||
{entity: 'user'},
|
{entity: 'user'},
|
||||||
@ -79,10 +81,11 @@ IPA.self_serv_navigation = function(spec) {
|
|||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
|
spec.name = 'self-service';
|
||||||
|
|
||||||
spec.tabs = [
|
spec.tabs = [
|
||||||
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
||||||
{entity: 'user'},
|
{entity: 'user'}
|
||||||
{entity: 'group'}
|
|
||||||
]}];
|
]}];
|
||||||
|
|
||||||
var that = IPA.navigation(spec);
|
var that = IPA.navigation(spec);
|
||||||
|
@ -1014,40 +1014,54 @@ IPA.column = function (spec) {
|
|||||||
|
|
||||||
that.name = spec.name;
|
that.name = spec.name;
|
||||||
that.label = spec.label;
|
that.label = spec.label;
|
||||||
that.primary_key = spec.primary_key;
|
|
||||||
that.width = spec.width;
|
that.width = spec.width;
|
||||||
that.entity_name = spec.entity_name;
|
|
||||||
that.format = spec.format;
|
|
||||||
|
|
||||||
that.setup = spec.setup || setup;
|
that.entity_name = spec.entity_name;
|
||||||
|
that.primary_key = spec.primary_key;
|
||||||
|
that.link = spec.link;
|
||||||
|
|
||||||
|
that.format = spec.format;
|
||||||
|
|
||||||
that.init = function() {
|
that.init = function() {
|
||||||
if (that.entity_name && !that.label) {
|
if (that.entity_name && !that.label) {
|
||||||
var param_info = IPA.get_entity_param(that.entity_name, that.name);
|
var param_info = IPA.get_entity_param(that.entity_name, that.name);
|
||||||
if (param_info) {
|
if (param_info) {
|
||||||
that.label = param_info.label;
|
that.label = param_info.label;
|
||||||
}else{
|
} else {
|
||||||
alert('cannot find label for ' + that.entity_name + ' ' +
|
alert('cannot find label for ' + that.entity_name + ' ' +
|
||||||
that.name);
|
that.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup(container, record) {
|
that.setup = function(container, record) {
|
||||||
|
|
||||||
container.empty();
|
container.empty();
|
||||||
|
|
||||||
var value = record[that.name];
|
var value = record[that.name];
|
||||||
if (that.format && value){
|
if (that.format && value) {
|
||||||
value = that.format(value);
|
value = that.format(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = value ? value.toString() : '';
|
value = value ? value.toString() : '';
|
||||||
|
|
||||||
|
if (that.link) {
|
||||||
|
$('<a/>', {
|
||||||
|
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;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user