Re: [Freeipa-devel] [PATCH] 0261-entity-link-for-password-policy

2011-07-01 Thread Adam Young

On 06/30/2011 08:46 PM, Endi Sukma Dewata wrote:

On 6/30/2011 4:42 PM, Adam Young wrote:




Some issues:

1. Suppose initially you open an entry that contains a value that 
matches no_link_value, it will hide the link and show the label. Then 
suppose you open another entry that has no value, it will empty the 
link but leaving the label from the previous entry visible.


This is not a problem for password policy because cn will always have 
a value, but it might be better to change the else-clause in reset() 
to hide both the link and the label:


  that.link.css('display','none');
  that.label.css('display','none');

2. Optional: The no_link_value seems to be limited to a single value 
only. While it works fine for password policy, I suppose in other 
cases we might want to match multiple values or use some other logic. 
One solution is to put the logic that checks the value inside a method 
that can be overriden by the subclass.




From 52de8b34a6939fb8a06b5a62ee27f1bab369721e Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Thu, 30 Jun 2011 17:38:59 -0400
Subject: [PATCH] entity link for password policy

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

reset() now hides both the link and the label
calucalating  should_link is now a function that can be overloaded.
---
 install/ui/policy.js |   11 -
 install/ui/widget.js |   56 ++
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/install/ui/policy.js b/install/ui/policy.js
index d30abbfdc8522362522fe287598ef9d7380cd2f9..cd0e499e14f4275c8f47806cc36aa9154ddf0c1b 100644
--- a/install/ui/policy.js
+++ b/install/ui/policy.js
@@ -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({
diff --git a/install/ui/widget.js b/install/ui/widget.js
index a56e55250da6c123e29be779ee98e5d90790b58a..5485f0c88cc46a8beb1c5714f919c9b20f6fbfd0 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
-- 
1.7.5.2

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0261-entity-link-for-password-policy

2011-07-01 Thread Endi Sukma Dewata

On 7/1/2011 1:08 PM, Adam Young wrote:




ACK but there's a jslint warning.

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 0261-entity-link-for-password-policy

2011-07-01 Thread Adam Young

On 07/01/2011 03:08 PM, Endi Sukma Dewata wrote:

On 7/1/2011 1:08 PM, Adam Young wrote:




ACK but there's a jslint warning.


Fixed and pushed to master

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 0261-entity-link-for-password-policy

2011-06-30 Thread Adam Young


From a901f18fbd978d7203b705ccbef18be89491d97c Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Thu, 30 Jun 2011 17:38:59 -0400
Subject: [PATCH] entity link for password policy

https://fedorahosted.org/freeipa/ticket/
---
 install/ui/policy.js |   11 +--
 install/ui/widget.js |   50 ++
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/install/ui/policy.js b/install/ui/policy.js
index d30abbfdc8522362522fe287598ef9d7380cd2f9..cd0e499e14f4275c8f47806cc36aa9154ddf0c1b 100644
--- a/install/ui/policy.js
+++ b/install/ui/policy.js
@@ -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({
diff --git a/install/ui/widget.js b/install/ui/widget.js
index c2b13778fca45e6fab6d441cb23dda02f3e2cd6d..d8cec867f0c211ea88e4a182136175720558e4f2 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1722,3 +1722,53 @@ 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.reset = function(record) {
+other_pkey = null;
+if (that.values || that.values.length  0){
+other_pkey = that.values[0];
+should_link =  (other_pkey !== no_link_value);
+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('');
+}
+};
+
+return that;
+};
\ No newline at end of file
-- 
1.7.5.2

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0261-entity-link-for-password-policy

2011-06-30 Thread Endi Sukma Dewata

On 6/30/2011 4:42 PM, Adam Young wrote:




Some issues:

1. Suppose initially you open an entry that contains a value that 
matches no_link_value, it will hide the link and show the label. Then 
suppose you open another entry that has no value, it will empty the link 
but leaving the label from the previous entry visible.


This is not a problem for password policy because cn will always have a 
value, but it might be better to change the else-clause in reset() to 
hide both the link and the label:


  that.link.css('display','none');
  that.label.css('display','none');

2. Optional: The no_link_value seems to be limited to a single value 
only. While it works fine for password policy, I suppose in other cases 
we might want to match multiple values or use some other logic. One 
solution is to put the logic that checks the value inside a method that 
can be overriden by the subclass.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel