From fc0ea1b740aa76093e97ad7ac283e2c8520c09f1 Mon Sep 17 00:00:00 2001 From: yiwenliu Date: Sun, 15 Jan 2017 01:05:28 -0800 Subject: [PATCH 1/2] Check if it is always disabled before enabling any editor --- src/editors/array.js | 26 ++++++++++++++------------ src/editors/base64.js | 6 ++++-- src/editors/checkbox.js | 2 +- src/editors/enum.js | 6 ++++-- src/editors/multiple.js | 14 ++++++++------ src/editors/multiselect.js | 2 +- src/editors/object.js | 18 ++++++++++-------- src/editors/select.js | 2 +- src/editors/selectize.js | 2 +- src/editors/string.js | 2 +- src/editors/upload.js | 6 ++++-- 11 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/editors/array.js b/src/editors/array.js index ca05e109d..4327d414d 100644 --- a/src/editors/array.js +++ b/src/editors/array.js @@ -29,20 +29,22 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({ } }, enable: function() { - if(this.add_row_button) this.add_row_button.disabled = false; - if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = false; - if(this.delete_last_row_button) this.delete_last_row_button.disabled = false; - - if(this.rows) { - for(var i=0; i Date: Sun, 15 Jan 2017 03:15:07 -0800 Subject: [PATCH 2/2] If function disable is called with param always_disabled set to true, update flag always_disabled for any editor --- src/editors/array.js | 5 +++-- src/editors/base64.js | 3 ++- src/editors/checkbox.js | 3 ++- src/editors/enum.js | 3 ++- src/editors/multiple.js | 5 +++-- src/editors/multiselect.js | 3 ++- src/editors/object.js | 5 +++-- src/editors/select.js | 3 ++- src/editors/selectize.js | 3 ++- src/editors/string.js | 3 ++- src/editors/upload.js | 3 ++- 11 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/editors/array.js b/src/editors/array.js index 4327d414d..c8ad7492d 100644 --- a/src/editors/array.js +++ b/src/editors/array.js @@ -46,14 +46,15 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({ this._super(); } }, - disable: function() { + disable: function(always_disabled) { + if(always_disabled) this.always_disabled = true; if(this.add_row_button) this.add_row_button.disabled = true; if(this.remove_all_rows_button) this.remove_all_rows_button.disabled = true; if(this.delete_last_row_button) this.delete_last_row_button.disabled = true; if(this.rows) { for(var i=0; i