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];
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
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<columns.length; i++) {
|
||||
column = columns[i];
|
||||
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;
|
||||
@ -698,6 +678,7 @@ IPA.association_facet = function (spec) {
|
||||
that.facet_group = spec.facet_group;
|
||||
|
||||
that.read_only = spec.read_only;
|
||||
that.link = spec.link === undefined ? true : spec.link;
|
||||
|
||||
that.associator = spec.associator || IPA.bulk_associator;
|
||||
that.add_method = spec.add_method || 'add_member';
|
||||
@ -718,9 +699,6 @@ IPA.association_facet = function (spec) {
|
||||
|
||||
that.create_column = function(spec) {
|
||||
var column = IPA.column(spec);
|
||||
if (spec.link_entity){
|
||||
column.setup = IPA.association_pkey_setup;
|
||||
}
|
||||
that.add_column(column);
|
||||
return column;
|
||||
};
|
||||
@ -775,39 +753,26 @@ IPA.association_facet = function (spec) {
|
||||
});
|
||||
|
||||
var columns = that.columns.values;
|
||||
if (columns.length) {
|
||||
that.table.set_columns(columns);
|
||||
|
||||
} else {
|
||||
|
||||
column = that.table.create_column({
|
||||
name: that.table.name,
|
||||
label: IPA.metadata.objects[that.other_entity].label,
|
||||
primary_key: true
|
||||
if (!columns.length) {
|
||||
that.create_column({
|
||||
name: pkey_name,
|
||||
primary_key: true,
|
||||
link: that.link
|
||||
});
|
||||
|
||||
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++) {
|
||||
column = columns[i];
|
||||
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;
|
||||
|
@ -526,6 +526,7 @@ IPA.adder_dialog = function (spec) {
|
||||
'label': button.val(),
|
||||
'click': function() {
|
||||
that.remove();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
button.replaceWith(that.remove_button);
|
||||
@ -535,6 +536,7 @@ IPA.adder_dialog = function (spec) {
|
||||
'label': button.val(),
|
||||
'click': function() {
|
||||
that.add();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
button.replaceWith(that.add_button);
|
||||
|
@ -819,18 +819,13 @@ IPA.entity_builder = function(){
|
||||
return that;
|
||||
};
|
||||
|
||||
that.standard_association_facets = function() {
|
||||
that.standard_association_facets = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var attribute_members = entity.metadata.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];
|
||||
|
||||
@ -842,9 +837,11 @@ IPA.entity_builder = function(){
|
||||
var facet = entity.get_facet(association_name);
|
||||
if (facet) continue;
|
||||
|
||||
that.association_facet({
|
||||
name: association_name
|
||||
});
|
||||
var tmp_spec = $.extend({}, spec);
|
||||
tmp_spec.name = association_name;
|
||||
|
||||
that.association_facet(tmp_spec);
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
|
@ -42,7 +42,7 @@ IPA.entity_factories.group = function () {
|
||||
{
|
||||
name: 'uid',
|
||||
primary_key: true,
|
||||
link_entity: true
|
||||
link: true
|
||||
},
|
||||
{name: 'uidnumber'},
|
||||
{name: 'mail'},
|
||||
|
@ -106,27 +106,10 @@ IPA.hbacsvcgroup_member_hbacsvc_table_widget = function (spec) {
|
||||
var column = that.create_column({
|
||||
name: 'cn',
|
||||
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({
|
||||
name: 'description',
|
||||
width: '350px'
|
||||
|
@ -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() : '';
|
||||
|
||||
$('<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({
|
||||
name: 'fqdn',
|
||||
primary_key: true,
|
||||
width: '200px'
|
||||
});
|
||||
|
||||
|
||||
that.association_facet_init();
|
||||
};
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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() : '';
|
||||
|
||||
$('<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({
|
||||
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);
|
||||
|
@ -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() : '';
|
||||
|
||||
$('<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({
|
||||
name: 'fqdn',
|
||||
primary_key: true,
|
||||
|
@ -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',
|
||||
|
@ -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 || {};
|
||||
|
@ -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);
|
||||
|
@ -1014,40 +1014,54 @@ 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.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() {
|
||||
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) {
|
||||
$('<a/>', {
|
||||
href: '#'+value,
|
||||
html: value,
|
||||
click: function() {
|
||||
return that.link_handler(value);
|
||||
}
|
||||
}).appendTo(container);
|
||||
|
||||
} else {
|
||||
container.append(value);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
that.link_handler = function(value) {
|
||||
return false;
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user