webui: add simple link column support

Usual link columns are link with primary key of current entity.

This patch allows to create a link to arbitrary non-nested entity.

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik 2014-09-18 17:28:41 +02:00
parent 8b0e2ed991
commit 749101db74
2 changed files with 9 additions and 1 deletions

View File

@ -1965,7 +1965,9 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
var metadata = IPA.get_entity_param(entity.name, column.name);
column.primary_key = metadata && metadata.primary_key;
column.link = (column.link === undefined ? true : column.link) && column.primary_key;
if (column.primary_key) {
column.link = column.link === undefined ? true : column.link;
}
if (column.link && column.primary_key) {
column.link_handler = function(value) {

View File

@ -2489,6 +2489,8 @@ IPA.column = function (spec) {
that.link = spec.link;
that.adapter = builder.build('adapter', spec.adapter || 'adapter', { context: that });
that.formatter = builder.build('formatter', spec.formatter);
that.target_entity = spec.target_entity;
that.target_facet = spec.target_facet;
if (!that.entity) {
throw {
@ -2585,6 +2587,10 @@ IPA.column = function (spec) {
* Intended to be overridden.
*/
that.link_handler = function(value) {
// very simple implementation which doesn't handle navigation to
// nested entities
navigation.show_entity(that.target_entity, that.target_facet, [value]);
return false;
};