entity link for password policy

https://fedorahosted.org/freeipa/ticket/1111

reset() now hides both the link and the label
calucalating  should_link is now a function that can be overloaded.
This commit is contained in:
Adam Young
2011-06-30 17:38:59 -04:00
parent 58eec70884
commit 7a25523d63
2 changed files with 65 additions and 2 deletions

View File

@@ -33,8 +33,15 @@ IPA.entity_factories.pwpolicy = function() {
sections:[
{
name : 'identity',
fields:['krbmaxpwdlife','krbminpwdlife','krbpwdhistorylength',
'krbpwdmindiffchars','krbpwdminlength']
fields:[
{
factory: IPA.entity_link_widget,
name: 'cn',
entity: 'group',
no_link_value: 'global_policy'
},
'krbmaxpwdlife','krbminpwdlife','krbpwdhistorylength',
'krbpwdmindiffchars','krbpwdminlength']
}]}).
standard_association_facets().
adder_dialog({

View File

@@ -1729,3 +1729,59 @@ IPA.entity_select_widget = function(spec) {
return that;
};
IPA.entity_link_widget = function(spec) {
var that = IPA.widget(spec);
var no_link_value = spec.no_link_value || null;
var should_link = true;
var other_pkey = null;
var other_entity = spec.entity;
that.super_create = that.create;
that.create = function(container) {
that.super_create(container);
that.link =
$('<a/>', {
href: 'jslink',
title: '',
html: '',
click: function() {
if (should_link){
IPA.nav.show_page(other_entity, 'default', other_pkey);
}
return false;
}
}).appendTo(container);
that.label = $('<label/>').
appendTo(container);
};
that.should_link = function(){
return (other_pkey !== no_link_value);
};
that.reset = function(record) {
other_pkey = null;
if (that.values || that.values.length > 0){
other_pkey = that.values[0];
var should_link = that.should_link();
if (should_link){
that.link.html(other_pkey);
that.link.css('display','inline');
that.label.css('display','none');
}else{
that.label.html(other_pkey);
that.link.css('display','none');
that.label.css('display','inline');
}
}else{
should_link = false;
that.link.html('');
that.label.html('');
that.link.css('display','none');
that.label.css('display','none');
}
};
return that;
};