On 02/04/2011 02:02 PM, Adam Young wrote:
On 02/04/2011 01:50 PM, Adam Young wrote:


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
NACK. I don't like the way the whole page moves. I have a slighly better approach.


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
This uses visibility instead of display for the css, which keeps the page from expanding and contracting.
From 723fd8f40ee5dbf6ec863c566fffcebde4d2327a Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 4 Feb 2011 13:49:56 -0500
Subject: [PATCH] target section undo
 adds an undo link for the whole target section, incase the user changes the target type

---
 install/ui/aci.js |   64 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index 036731237ee8a0f3bd80957520e9ee9ca546bf21..0fa89d1d9eb19c6ed8114187c6d0b004bdecdaa9 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -249,6 +249,33 @@ IPA.target_section = function(spec) {
                      'aci_by_filter' ];
     var inputs = ['input', 'select', 'textarea'];
 
+    function create_undo(container) {
+        $('<span/>', {
+            name: 'target-undo',
+            style: 'visibility: hidden;',
+            'class': 'ui-state-highlight ui-corner-all undo',
+            html: 'undo',
+            click: function(){
+                that.reset();
+            }
+        }).appendTo(container);
+    };
+
+    function get_undo() {
+        return $('span[name="target-undo"]', that.container);
+    };
+
+    function show_undo() {
+        var undo = get_undo();
+        undo.css('visibility', 'visible');
+    };
+
+    function hide_undo() {
+        var undo = get_undo();
+        undo.css('visibility', 'hidden');
+    };
+
+
     function disable_inputs() {
         for (var g = 0; g < groupings.length; g += 1 ){
             for (var t = 0 ; t < inputs.length; t += 1){
@@ -369,6 +396,9 @@ IPA.target_section = function(spec) {
     }
 
     that.create = function(container) {
+        if (that.undo) {
+            create_undo(container);
+        }
         var dl =  $('<dl/>', {
             'class': 'aci-target'
         }).appendTo(container);
@@ -378,27 +408,17 @@ IPA.target_section = function(spec) {
         display_group_target(dl);
         display_type_target(dl);
 
-        $('#aci_by_filter', dl).click(function() {
-            disable_inputs();
-            enable_by(groupings[3]);
-        });
 
-        $('#aci_by_type', dl).click(function() {
-            disable_inputs();
-            enable_by(groupings[0]);
-        });
+        for (var g = 0 ; g <  groupings.length; g += 1){
 
-        $('#aci_by_query', dl).click(function() {
-            disable_inputs();
-            enable_by(groupings[1]);
-        });
-
-        $('#aci_by_group', dl).click(function() {
-            disable_inputs();
-            enable_by(groupings[2]);
-        });
-
-        $('#aci_by_type', dl).click();
+            $('#'+groupings[g], dl).click(function() {
+                show_undo();
+                disable_inputs();
+                enable_by(this.id);
+            });
+        }
+        disable_inputs();
+        enable_by(groupings[0]);
     };
 
     that.setup = function(container) {
@@ -447,6 +467,7 @@ IPA.target_section = function(spec) {
         } else {
             alert('permission with invalid target specification');
         }
+        hide_undo();
     }
 
     that.load = function(record) {
@@ -461,7 +482,7 @@ IPA.target_section = function(spec) {
 
         set_aci_type(that.record);
         that.attribute_table.object_type = that.record.type;
-
+        hide_undo();
         that.section_reset();
     };
 
@@ -491,6 +512,7 @@ IPA.target_section = function(spec) {
 
         var record_type = $("input[name='aci_type']:checked").attr('id');
 
+
         if (record_type === 'aci_by_group') {
             record.targetgroup = that.group_select.save()[0];
 
@@ -566,7 +588,7 @@ IPA.entity_factories.permission = function() {
                   IPA.stanza({name:'identity', label:'Identity'}).
                       input({name: 'cn', 'read_only': true})).
               section(IPA.rights_section()).
-              section(IPA.target_section({name: 'target', label: 'Target'})));
+              section(IPA.target_section({name: 'target', label: 'Target',undo: true})));
 
 };
 
-- 
1.7.3.5

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

Reply via email to