On 07/29/2013 02:21 PM, Ana Krivokapic wrote:
On 07/29/2013 11:45 AM, Petr Vobornik wrote:
              dialog.textarea = $('<textarea/>', {
                  'class': 'certificate',
-                readonly: that.read_only,
+                readonly: !writable,
                  disabled: !that.enabled
              }).appendTo(dialog.container);

I suggest setting the 'disabled' attribute on the text area in case it's not
writable:

     disabled: !that.enabled || !writable

That way, when the user opens the dialog, the textarea is greyed out and it is
immediately clear that it is not editable.


I agree that we should distinguish the look of readonly textarea, but 'disabled' attribute is not the right one for the task. Disabled inputs have(at least in FF) behavior which we don't want for readonly:
 * they are not fucusable
 * user can't select(copy) text

I've added new css style to create the distinction.

Updated patch attached.
--
Petr Vobornik
From 1c30d3fac02050c90dcf401c5b8e28300d307006 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 28 Jun 2013 16:50:52 +0200
Subject: [PATCH] Make ssh_widget not-editable if attr is readonly

https://fedorahosted.org/freeipa/ticket/3800
---
 install/ui/ipa.css               |  4 ++++
 install/ui/src/freeipa/widget.js | 31 ++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index ad3d1aa1f8f8898ad8dff8f8ecc175238fad1181..26df94095c442fd90374033d870b58592531298f 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -53,6 +53,10 @@ body {
     height: 100%;
 }
 
+textarea[readonly] {
+    color: Gray;
+}
+
 .network-activity-indicator {
     visibility: hidden;
     width: 16px;
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 27e32e2b06f0cf30590036f7f7a4094127c5b7e1..d42b2008d61eff455843701b725ee1863b9cc01b 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -3803,6 +3803,8 @@ IPA.sshkey_widget = function(spec) {
 
     that.create_edit_dialog = function() {
 
+        var writable = that.is_writable();
+
         var dialog = IPA.dialog({
             name: 'sshkey-edit-dialog',
             title: '@i18n:objects.sshkeystore.set_dialog_title',
@@ -3812,19 +3814,26 @@ IPA.sshkey_widget = function(spec) {
 
         dialog.message = text.get('@i18n:objects.sshkeystore.set_dialog_help');
 
-        dialog.create_button({
-            name: 'update',
-            label: '@i18n:buttons.set',
-            click: function() {
-                var value = dialog.textarea.val();
-                that.set_user_value(value);
-                dialog.close();
-            }
-        });
+        if (writable) {
+            dialog.create_button({
+                name: 'update',
+                label: '@i18n:buttons.set',
+                click: function() {
+                    var value = dialog.textarea.val();
+                    that.set_user_value(value);
+                    dialog.close();
+                }
+            });
+        }
+
+        var label = '@i18n:buttons.cancel';
+        if (!writable) {
+            label = '@i18n:buttons.close';
+        }
 
         dialog.create_button({
             name: 'cancel',
-            label: '@i18n:buttons.cancel',
+            label: label,
             click: function() {
                 dialog.close();
             }
@@ -3836,7 +3845,7 @@ IPA.sshkey_widget = function(spec) {
 
             dialog.textarea = $('<textarea/>', {
                 'class': 'certificate',
-                readonly: that.read_only,
+                readonly: !writable,
                 disabled: !that.enabled
             }).appendTo(dialog.container);
 
-- 
1.8.3.1

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

Reply via email to