Skip to content

Commit

Permalink
Restrict min/max percent DMX values in editor (#937)
Browse files Browse the repository at this point in the history
Applies to default and highlight values.
  • Loading branch information
fxedel committed Jul 8, 2019
1 parent 2b6e86b commit 97c51e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions ui/components/editor-channel-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
<app-property-input-entity
v-model="channel.defaultValue"
:schema-property="properties.channel.defaultValue"
:max-number="dmxMax"
:min-number="0"
:max-number="(typeof channel.defaultValue) === `string` ? 100 : dmxMax"
class="wide"
name="defaultValue" />
</app-labeled-input>
Expand Down Expand Up @@ -187,7 +188,8 @@
<app-property-input-entity
v-model="channel.highlightValue"
:schema-property="properties.channel.highlightValue"
:max-number="dmxMax"
:min-number="0"
:max-number="(typeof channel.highlightValue) === `string` ? 100 : dmxMax"
class="wide"
name="highlightValue" />
</app-labeled-input>
Expand Down
12 changes: 7 additions & 5 deletions ui/components/property-input-entity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
v-model="selectedNumber"
:schema-property="units[selectedUnit].numberSchema"
:required="true"
:maximum="selectedUnitIsNumber && maxNumber !== null ? maxNumber : `invalid`"
:minimum="minNumber !== null ? minNumber : `invalid`"
:maximum="maxNumber !== null ? maxNumber : `invalid`"
:name="name ? `${name}-number` : null"
@focus.native="onFocus"
@blur.native="onBlur($event)" />
Expand Down Expand Up @@ -110,6 +111,11 @@ export default {
required: false,
default: ``
},
minNumber: {
type: Number,
required: false,
default: null
},
maxNumber: {
type: Number,
required: false,
Expand Down Expand Up @@ -189,10 +195,6 @@ export default {
hasNumber() {
return hasNumber(this.selectedUnit, this.enumValues);
},
selectedUnitIsNumber() {
const selectedUnitObj = this.properties.units[this.selectedUnit];
return selectedUnitObj && !(`pattern` in selectedUnitObj);
},
selectedNumber: {
get() {
if (typeof this.value !== `string`) {
Expand Down

0 comments on commit 97c51e1

Please sign in to comment.