diff --git a/src/client/app/widgets/switchers/state.js b/src/client/app/widgets/switchers/state.js index 17ab4bcb..b52bdc1f 100644 --- a/src/client/app/widgets/switchers/state.js +++ b/src/client/app/widgets/switchers/state.js @@ -27,6 +27,9 @@ class State extends Widget { '- widget id `string`', '- `array` of widget id strings' ]}, + saveLabel: {type: 'string', value: 'Save', help: 'Label for save button'}, + loadLabel: {type: 'string', value: 'Load', help: 'Label for load button'}, + horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display buttons horizontally'}, }, ['_value', 'default', 'value']) @@ -39,12 +42,13 @@ class State extends Widget { this._isSwitcher = true - this.saveButton = new Push({props: {...pushDefaults, type: 'push', label: 'save'}, parent: this, container: true}) - this.loadButton = new Push({props: {...pushDefaults, type: 'push', label: 'load'}, parent: this, container: true}) + if (this.getProp('horizontal')) this.widget.classList.add('horizontal') - this.saveButton.container.classList.add('not-editable') - this.loadButton.container.classList.add('not-editable') - this.loadButton.container.classList.add('disabled') + this.saveButton = new Push({props: {...pushDefaults, type: 'push', label: this.getProp('saveLabel')}, parent: this, container: true}) + this.loadButton = new Push({props: {...pushDefaults, type: 'push', label: this.getProp('loadLabel')}, parent: this, container: true}) + + this.saveButton.container.classList.add('not-editable', 'value') + this.loadButton.container.classList.add('not-editable', 'value', 'disabled') this.widget.appendChild(this.saveButton.container) this.widget.appendChild(this.loadButton.container) @@ -65,12 +69,15 @@ class State extends Widget { save() { - var filter + var filter = (widget)=>{ + return !widget._isSwitcher + } + if (this.filter) { var containers = this.filter.map(x=>widgetManager.getWidgetById(x)).reduce((a,b)=>a.concat(b), []) if (!containers.length) return filter = (widget)=>{ - return !widget.isSwitcher && containers.some(x=>x.contains(widget) || x === widget) + return !widget._isSwitcher && containers.some(x=>x.contains(widget) || x === widget) } } diff --git a/src/scss/widgets/switch.scss b/src/scss/widgets/switch.scss index dd281913..87a37867 100644 --- a/src/scss/widgets/switch.scss +++ b/src/scss/widgets/switch.scss @@ -208,6 +208,16 @@ } .state-container { + .push-container { + border:0; + } + .toggle { + height: 100%; + z-index: 1; + &:before { + box-shadow: none; + } + } .disabled { opacity: 0.65; pointer-events: none;