[pve-devel] [PATCH manager 0/1] improve xtermjs settings
Dominik Csapak
d.csapak at proxmox.com
Wed Apr 25 08:12:20 CEST 2018
this patch improves the xtermjs settings button behaviour
i include the diffstat with '-w --histogram' so
that one can see what is actually happening
(there was mostly an indentation shift)
----8<----
diff --git a/www/manager6/window/Settings.js b/www/manager6/window/Settings.js
index acffb01b..ef9dc021 100644
--- a/www/manager6/window/Settings.js
+++ b/www/manager6/window/Settings.js
@@ -31,27 +31,40 @@ Ext.define('PVE.window.Settings', {
me.lookupReference('savedUserName').setValue(username);
var settings = ['fontSize', 'fontFamily', 'letterSpacing', 'lineHeight'];
- var defaultSettings = true;
settings.forEach(function(setting) {
var val = localStorage.getItem('pve-xterm-' + setting);
if (val !== undefined && val !== null) {
var field = me.lookup(setting);
field.setValue(val);
- defaultSettings = false;
+ field.resetOriginalValue();
+ }
+ });
+ },
+
+ set_button_status: function() {
+ var me = this;
+
+ var form = me.lookup('xtermform');
+ var valid = form.isValid();
+ var dirty = form.isDirty();
+
+ var hasvalues = false;
+ var values = form.getValues();
+ Ext.Object.eachValue(values, function(value) {
+ if (value) {
+ hasvalues = true;
+ return false;
}
});
- me.lookup('xtermsave').setDisabled(true);
- me.lookup('xtermreset').setDisabled(defaultSettings);
+ me.lookup('xtermsave').setDisabled(!dirty || !valid);
+ me.lookup('xtermreset').setDisabled(!hasvalues);
},
control: {
- '#xtermjs field': {
- change: function(field) {
- var me = this;
- me.lookup('xtermsave').setDisabled(false);
- me.lookup('xtermreset').setDisabled(false);
- }
+ '#xtermjs form': {
+ dirtychange: 'set_button_status',
+ validitychange: 'set_button_status'
},
'#xtermjs button': {
click: function(button) {
@@ -70,8 +83,9 @@ Ext.define('PVE.window.Settings', {
field.setValue(undefined);
localStorage.removeItem('pve-xterm-' + setting);
}
+ field.resetOriginalValue();
});
- button.setDisabled(true);
+ me.set_button_status();
}
},
'button[name=reset]': {
@@ -232,6 +246,10 @@ Ext.define('PVE.window.Settings', {
width: '50%',
margin: '5',
title: gettext('xterm.js Settings'),
+ items: [{
+ xtype: 'form',
+ reference: 'xtermform',
+ border: false,
layout: {
type: 'vbox',
algin: 'left'
@@ -293,6 +311,7 @@ Ext.define('PVE.window.Settings', {
]
}
]
+ }]
}],
onShow: function() {
---->8----
Dominik Csapak (1):
improve xtermjs settings button behaviour
www/manager6/window/Settings.js | 157 ++++++++++++++++++++++------------------
1 file changed, 88 insertions(+), 69 deletions(-)
--
2.11.0
More information about the pve-devel
mailing list