On 13.3.2014 16:55, Petr Vobornik wrote:
On 7.3.2014 15:34, Petr Vobornik wrote:
checkboxes and radio buttons:
- do not change color on hover when disabled
- are focusable and checkable by keyboard again. This uses a little
   trick where the real checkbox is hidden under the artificial
   checkbox. That way it has the same position and therefore it
   works even in containers with overflow set.

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


Self-NACK.

Breaks Automount Key deletion in ipa/ui/#/e/automountmap/keys/

Fixed in attached patch #551.

Also attaching new version of #550 with CI fixes.
--
Petr Vobornik
From 3b3e032532882cbe42ce69fd6dad6af85acc5c4d Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 13 Mar 2014 17:34:42 +0100
Subject: [PATCH] webui: do not use dom for getting selected automount keys

Old implementation crawled DOM for gathering data from DOM. Such code
is very error prone. Little visual change somewhere else can break it
- as happened in main patch for #4217.

prerequisite for:
https://fedorahosted.org/freeipa/ticket/4217
---
 install/ui/src/freeipa/automount.js | 22 +++++++++++++---------
 install/ui/src/freeipa/facet.js     |  1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/install/ui/src/freeipa/automount.js b/install/ui/src/freeipa/automount.js
index b010a52d43cd43b01c21bdd0e61eda130e39d37c..ca0729beb65648ecb146f27434222db9f9447d3d 100644
--- a/install/ui/src/freeipa/automount.js
+++ b/install/ui/src/freeipa/automount.js
@@ -337,16 +337,20 @@ IPA.automount.key_search_facet = function(spec) {
     that.get_selected_values = function() {
 
         var values = [];
+        var keys = that.table.get_selected_values();
+        var records = that.table.records;
 
-        $('input[name="description"]:checked', that.table.tbody).each(function() {
-            var value = {};
-            $('div', $(this).parent().parent()).each(function() {
-                var div = $(this);
-                var name = div.attr('name');
-                value[name] = div.text();
-            });
-            values.push(value);
-        });
+        if (keys.length === 0 || !records) return values;
+
+        for (var i=0,l=records.length; i<l; i++) {
+            var record = records[i];
+            if (keys.indexOf(record.description[0]) > -1) {
+                values.push({
+                    automountkey: record.automountkey[0],
+                    automountinformation: record.automountinformation[0]
+                });
+            }
+        }
 
         return values;
     };
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 6afc79d61da4d95effcd3189d2d90ee4991dbcec..4d1787145865773fac41d2f3f64b95a3d107a984 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -1827,6 +1827,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
      */
     that.load_records = function(records) {
         that.table.empty();
+        that.table.records = records;
         for (var i=0; i<records.length; i++) {
             that.add_record(records[i]);
         }
-- 
1.8.5.3

From 63e58de1d61c4f8628a5f4c823ed2d07b1ed72c0 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 27 Feb 2014 18:21:05 +0100
Subject: [PATCH] webui-css: improve radio,checkbox keyboard support and color

checkboxes and radio buttons:
- do not change color on hover when disabled
- are focusable and checkable be keyboard again. This uses a little
  trick where the real checkbox is hidden under the artificial
  checkbox. That way it has the same position and therefore it
  works even in containers with overflow set.

https://fedorahosted.org/freeipa/ticket/4217
---
 install/ui/less/forms-override.less | 40 +++++++++++++++++++++++++++++--------
 install/ui/src/freeipa/widget.js    | 19 +++++++++++++-----
 ipatests/test_webui/test_dns.py     |  6 +++---
 ipatests/test_webui/test_host.py    |  8 ++++----
 ipatests/test_webui/test_service.py |  4 ++--
 ipatests/test_webui/ui_driver.py    |  2 +-
 6 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/install/ui/less/forms-override.less b/install/ui/less/forms-override.less
index ac442bb0b60a8cbcbedbdd9fc43ae5193c4256c2..b8c2e5d3542a2599cc246ae25e1e7e080fa2eebd 100644
--- a/install/ui/less/forms-override.less
+++ b/install/ui/less/forms-override.less
@@ -30,9 +30,27 @@
 @checkbox-selected-color: darken(@checkbox-hover-color, 20%);
 
 /* Checkboxes and Radios */
+
+.radio, .checkbox {
+    position: relative;
+    padding: 0;
+}
+
 input[type="checkbox"],
 input[type="radio"] {
-    display: none;
+    display: inline;
+    position: absolute;
+    overflow: hidden;
+    margin:0;
+    padding:0;
+    border:0;
+    outline:0;
+    opacity:0;
+}
+
+input[type="checkbox"]:focus + label:before,
+input[type="radio"]:focus + label:before {
+    outline: thin dotted @checkbox-selected-color;
 }
 
 input[type="checkbox"] + label,
@@ -45,7 +63,7 @@ input[type="radio"] + label {
         .fa;
 
         font-size: 125%;
-        vertical-align: -11%;
+        vertical-align: -7%;
         margin-right: 5px;
     }
 }
@@ -81,12 +99,22 @@ input[type="checkbox"]:disabled + label {
     }
 }
 
+input[type="radio"]:disabled:checked + label,
+input[type="checkbox"]:disabled:checked + label {
+    color: @checkbox-color;
+
+    &:before,
+    &:hover:before {
+        color: @checkbox-color;
+    }
+}
+
 input[type="checkbox"] + label:before {
-    content: "@{fa-var-square-o} ";
+    content: @fa-var-square-o;
 }
 
 input[type="checkbox"]:checked + label:before {
-    content: "@{fa-var-check-square-o} ";
+    content: @fa-var-check-square-o;
     color: @checkbox-selected-color;
 }
 
@@ -99,10 +127,6 @@ input[type="radio"]:checked + label:before {
     color: @checkbox-selected-color;
 }
 
-input[type="radio"]:disabled + label {
-    color: @checkbox-disabled-color;
-}
-
 .form-horizontal {
 
     .controls {
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 6ee61c6583509301d0aa98f64fefa14d5d27f5ea..f3b6c97d7a3a0e9b6e793bf9109e0d65b58f98b7 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1166,6 +1166,10 @@ IPA.option_widget_base = function(spec, that) {
         var id = that._option_next_id + input_name;
         var enabled = that.enabled && option.enabled;
 
+        var opt_cont = $('<span/>', {
+            "class": that.intput_type
+        }).appendTo(container);
+
         option.input_node = $('<input/>', {
             id: id,
             type: that.input_type,
@@ -1174,13 +1178,13 @@ IPA.option_widget_base = function(spec, that) {
             value: option.value,
             title: option.tooltip || that.tooltip,
             change: that.on_input_change
-        }).appendTo(container);
+        }).appendTo(opt_cont);
 
         option.label_node =  $('<label/>', {
             html: option.label || '',
             title: option.tooltip || that.tooltip,
             'for': id
-        }).appendTo(container);
+        }).appendTo(opt_cont);
 
         that.new_option_id();
     };
@@ -1557,6 +1561,10 @@ IPA.standalone_option = function(spec, container, label) {
 
     spec.type = spec.type || 'checkbox';
 
+    var opt_cont = $('<span/>', {
+        'class': spec.type
+    });
+
     var input = $('<input/>', spec);
 
     if (!label) {
@@ -1571,11 +1579,12 @@ IPA.standalone_option = function(spec, container, label) {
     });
 
     if (container) {
-        input.appendTo(container);
-        label_el.appendTo(container);
+        input.appendTo(opt_cont);
+        label_el.appendTo(opt_cont);
+        opt_cont.appendTo(container);
     }
 
-    return [input, label_el];
+    return [input, label_el, opt_cont];
 };
 
 /**
diff --git a/ipatests/test_webui/test_dns.py b/ipatests/test_webui/test_dns.py
index c832190d39c23fc5b90884439779341c448cd099..dbcb2622e692d2b7bdec2155f9f3ac65a8506dc5 100644
--- a/ipatests/test_webui/test_dns.py
+++ b/ipatests/test_webui/test_dns.py
@@ -37,10 +37,10 @@ ZONE_DATA = {
         ('textbox', 'idnsname', ZONE_PKEY),
         ('textbox', 'idnssoamname', 'ns'),
         ('textbox', 'ip_address', '192.168.1.1'),
-        ('checkbox', 'force', ''),
+        ('checkbox', 'force', 'checked'),
     ],
     'mod': [
-        ('checkbox', 'idnsallowsyncptr', ''),
+        ('checkbox', 'idnsallowsyncptr', 'checked'),
     ],
 }
 
@@ -63,7 +63,7 @@ RECORD_MOD_DATA = {
 
 CONFIG_MOD_DATA = {
     'mod': [
-        ('checkbox', 'idnsallowsyncptr', ''),
+        ('checkbox', 'idnsallowsyncptr', 'checked'),
     ],
 }
 
diff --git a/ipatests/test_webui/test_host.py b/ipatests/test_webui/test_host.py
index 09200061bffaaef6af14cc860037af8293494b77..055224a0dfb62a423319411026adfc7c2825094b 100644
--- a/ipatests/test_webui/test_host.py
+++ b/ipatests/test_webui/test_host.py
@@ -61,14 +61,14 @@ class host_tasks(UI_driver):
             ]
             if ip:
                 add_data.append(('textbox', 'ip_address', ip))
-            add_data.append(('checkbox', 'force', ''))
+            add_data.append(('checkbox', 'force', None))
             del_data = [
-                ('checkbox', 'updatedns', '')
+                ('checkbox', 'updatedns', None)
             ]
         else:
             add_data = [
                 ('textbox', 'fqdn', '%s.%s' % (host, domain)),
-                ('checkbox', 'force', ''),
+                ('checkbox', 'force', None),
             ]
             del_data = None
 
@@ -204,7 +204,7 @@ class test_host(host_tasks):
         http://www.freeipa.org/page/V3/Kerberos_Flags
         """
         name = 'ipakrbokasdelegate'
-        mod = {'mod': [('checkbox', name, '')]}
+        mod = {'mod': [('checkbox', name, None)]}
         checked = ['checked']
 
         self.init_app()
diff --git a/ipatests/test_webui/test_service.py b/ipatests/test_webui/test_service.py
index d2e7ad77297b2dff03aa6ee262db0dbfc34230da..8ed2e15b5acb200c3aa5ef5a11bb557f39e5f39c 100644
--- a/ipatests/test_webui/test_service.py
+++ b/ipatests/test_webui/test_service.py
@@ -41,7 +41,7 @@ class sevice_tasks(UI_driver):
                 ('combobox', 'host', host)
             ],
             'mod': [
-                ('checkbox', 'ipakrbokasdelegate', ''),
+                ('checkbox', 'ipakrbokasdelegate', None),
             ],
         }
 
@@ -177,7 +177,7 @@ class test_service(sevice_tasks):
         """
         pkey = self.get_http_pkey()
         name = 'ipakrbokasdelegate'
-        mod = {'mod': [('checkbox', name, '')]}
+        mod = {'mod': [('checkbox', name, None)]}
         checked = ['checked']
 
         self.init_app()
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index a416658ed1b4d7c964f9681f956f87d793bca1c6..f0b9b4362de24b2a95ccd3e15b2b0b9c3241cbed 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1005,7 +1005,7 @@ class UI_driver(object):
             elif widget_type == 'radio':
                 self.check_option(key, val, parent)
             elif widget_type == 'checkbox':
-                self.check_option(key, parent=parent)
+                self.check_option(key, val, parent=parent)
             elif widget_type == 'selectbox':
                 self.select('select[name=%s]' % key, val, parent)
             elif widget_type == 'combobox':
-- 
1.8.5.3

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

Reply via email to