summaryrefslogtreecommitdiffstats
path: root/install/ui/widget.js
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2011-06-30 17:38:59 -0400
committerAdam Young <ayoung@redhat.com>2011-07-01 16:49:49 -0400
commit7a25523d63559b19babd83c74223d2d0c4d75157 (patch)
tree3a6048b9c4c8bead5e9879e8edd4ba58f42226ae /install/ui/widget.js
parent58eec70884fba522fe5865355351e906f07d228e (diff)
downloadfreeipa-7a25523d63559b19babd83c74223d2d0c4d75157.tar.gz
freeipa-7a25523d63559b19babd83c74223d2d0c4d75157.tar.xz
freeipa-7a25523d63559b19babd83c74223d2d0c4d75157.zip
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.
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r--install/ui/widget.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index a56e55250..2ea345d9a 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -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;
+}; \ No newline at end of file