Make ssh_widget not-editable if attr is readonly

https://fedorahosted.org/freeipa/ticket/3800
This commit is contained in:
Petr Vobornik 2013-06-28 16:50:52 +02:00
parent 69394bab5a
commit ff6f958d96
2 changed files with 24 additions and 11 deletions

View File

@ -53,6 +53,10 @@ body {
height: 100%; height: 100%;
} }
textarea[readonly] {
color: Gray;
}
.network-activity-indicator { .network-activity-indicator {
visibility: hidden; visibility: hidden;
width: 16px; width: 16px;

View File

@ -3796,6 +3796,8 @@ IPA.sshkey_widget = function(spec) {
that.create_edit_dialog = function() { that.create_edit_dialog = function() {
var writable = that.is_writable();
var dialog = IPA.dialog({ var dialog = IPA.dialog({
name: 'sshkey-edit-dialog', name: 'sshkey-edit-dialog',
title: '@i18n:objects.sshkeystore.set_dialog_title', title: '@i18n:objects.sshkeystore.set_dialog_title',
@ -3805,19 +3807,26 @@ IPA.sshkey_widget = function(spec) {
dialog.message = text.get('@i18n:objects.sshkeystore.set_dialog_help'); dialog.message = text.get('@i18n:objects.sshkeystore.set_dialog_help');
dialog.create_button({ if (writable) {
name: 'update', dialog.create_button({
label: '@i18n:buttons.set', name: 'update',
click: function() { label: '@i18n:buttons.set',
var value = dialog.textarea.val(); click: function() {
that.set_user_value(value); var value = dialog.textarea.val();
dialog.close(); that.set_user_value(value);
} dialog.close();
}); }
});
}
var label = '@i18n:buttons.cancel';
if (!writable) {
label = '@i18n:buttons.close';
}
dialog.create_button({ dialog.create_button({
name: 'cancel', name: 'cancel',
label: '@i18n:buttons.cancel', label: label,
click: function() { click: function() {
dialog.close(); dialog.close();
} }
@ -3829,7 +3838,7 @@ IPA.sshkey_widget = function(spec) {
dialog.textarea = $('<textarea/>', { dialog.textarea = $('<textarea/>', {
'class': 'certificate', 'class': 'certificate',
readonly: that.read_only, readonly: !writable,
disabled: !that.enabled disabled: !that.enabled
}).appendTo(dialog.container); }).appendTo(dialog.container);