From f8cd8e72a195b8cc46a4929dc2d9c462b111de5f Mon Sep 17 00:00:00 2001 From: alekseybobkov Date: Thu, 12 Nov 2015 21:56:56 -0800 Subject: [PATCH] Minor improvement in the Inspector --- .../assets/ui/js/inspector.editor.base.js | 2 +- .../assets/ui/js/inspector.editor.checkbox.js | 8 +++++ .../assets/ui/js/inspector.editor.dropdown.js | 34 +++++++++++++++++-- .../ui/js/inspector.editor.stringlist.js | 2 ++ .../assets/ui/js/inspector.editor.text.js | 12 +++++++ .../system/assets/ui/js/inspector.engine.js | 11 ++++++ .../system/assets/ui/js/inspector.surface.js | 4 +-- modules/system/assets/ui/less/inspector.less | 6 ++++ modules/system/assets/ui/storm-min.js | 33 ++++++++++++++---- modules/system/assets/ui/storm.css | 1 + 10 files changed, 101 insertions(+), 12 deletions(-) diff --git a/modules/system/assets/ui/js/inspector.editor.base.js b/modules/system/assets/ui/js/inspector.editor.base.js index 5bdf6dfbe..c0f0cd9f0 100644 --- a/modules/system/assets/ui/js/inspector.editor.base.js +++ b/modules/system/assets/ui/js/inspector.editor.base.js @@ -118,7 +118,7 @@ BaseEditor.prototype.isEmptyValue = function(value) { return value === undefined || value === null - || $.isEmptyObject(value) + || (typeof value == 'object' && $.isEmptyObject(value) ) || (typeof value == 'string' && $.trim(value).length === 0) || (Object.prototype.toString.call(value) === '[object Array]' && value.length === 0) } diff --git a/modules/system/assets/ui/js/inspector.editor.checkbox.js b/modules/system/assets/ui/js/inspector.editor.checkbox.js index b842e7045..fa924c551 100644 --- a/modules/system/assets/ui/js/inspector.editor.checkbox.js +++ b/modules/system/assets/ui/js/inspector.editor.checkbox.js @@ -78,6 +78,14 @@ this.getInput().checked = this.normalizeCheckedValue(value) } + CheckboxEditor.prototype.isEmptyValue = function(value) { + if (value === 0 || value === '0' || value === 'false') { + return true + } + + return BaseProto.isEmptyValue.call(this, value) + } + CheckboxEditor.prototype.registerHandlers = function() { var input = this.getInput() diff --git a/modules/system/assets/ui/js/inspector.editor.dropdown.js b/modules/system/assets/ui/js/inspector.editor.dropdown.js index 02fd3eec7..776ec0408 100644 --- a/modules/system/assets/ui/js/inspector.editor.dropdown.js +++ b/modules/system/assets/ui/js/inspector.editor.dropdown.js @@ -135,6 +135,24 @@ return false } + DropdownEditor.prototype.normalizeValue = function(value) { + if (!this.propertyDefinition.booleanValues) { + return value + } + + var str = String(value) + + if (str.length === 0) { + return '' + } + + if (str === 'true') { + return true + } + + return false + } + // // Event handlers // @@ -148,7 +166,7 @@ DropdownEditor.prototype.onSelectionChange = function() { var select = this.getSelect() - this.inspector.setPropertyValue(this.propertyDefinition.property, select.value, this.initialization) + this.inspector.setPropertyValue(this.propertyDefinition.property, this.normalizeValue(select.value), this.initialization) } DropdownEditor.prototype.onInspectorPropertyChanged = function(property, value) { @@ -191,12 +209,24 @@ var select = this.getSelect() if (select) { - return select.value + return this.normalizeValue(select.value) } return undefined } + DropdownEditor.prototype.isEmptyValue = function(value) { + if (this.propertyDefinition.booleanValues) { + if (value === '') { + return true + } + + return false + } + + return BaseProto.isEmptyValue.call(this, value) + } + // // Disposing // diff --git a/modules/system/assets/ui/js/inspector.editor.stringlist.js b/modules/system/assets/ui/js/inspector.editor.stringlist.js index 2779e750c..2dd009201 100644 --- a/modules/system/assets/ui/js/inspector.editor.stringlist.js +++ b/modules/system/assets/ui/js/inspector.editor.stringlist.js @@ -65,6 +65,8 @@ } $textarea.focus() + + this.configureComment(popup) } StringListEditor.prototype.handleSubmit = function($form) { diff --git a/modules/system/assets/ui/js/inspector.editor.text.js b/modules/system/assets/ui/js/inspector.editor.text.js index 28dc74026..9a6a6d6b8 100644 --- a/modules/system/assets/ui/js/inspector.editor.text.js +++ b/modules/system/assets/ui/js/inspector.editor.text.js @@ -46,6 +46,7 @@ \