Skip to content

Commit

Permalink
Merge pull request #853 from OpenC3/value_widget_verify_num_params
Browse files Browse the repository at this point in the history
fix value widget num parameters check
  • Loading branch information
ryanmelt authored Oct 2, 2023
2 parents 8d18dc8 + 1bde8d6 commit 88e94fd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
:widget-index="0"
/>
<value-widget
:parameters="parameters"
:parameters="valueParameters"
:settings="[...settings]"
:line="line"
:lineNumber="lineNumber"
Expand All @@ -56,6 +56,16 @@ export default {
// so create an array with the label text in the first position
return [this.parameters[2] + ':']
},
valueParameters() {
return [
this.parameters[0],
this.parameters[1],
this.parameters[2],
this.parameters[3],
this.parameters[4],
// Skip 5 which used to be the alignment of all the widgets together (left, split, right)
]
},
},
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export default {
},
created() {
this.valueParameters = this.parameters.slice(0, 3)
this.valueParameters.push(this.parameters[4])
if (this.parameters[4] != undefined) {
this.valueParameters.push(this.parameters[4])
}
if (this.parameters[5] != undefined) {
this.valueParameters.push(this.parameters[5])
}
if (this.parameters.length > 3) {
this.description = this.parameters[3]
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ export default {
},
},
created() {
this.verifyNumParams('VALUE', 3, 3, 'VALUE <TARGET> <PACKET> <ITEM>') // TYPE, WIDTH
this.verifyNumParams(
'VALUE',
3,
5,
'VALUE <TARGET> <PACKET> <ITEM> <TYPE> <WIDTH>',
)
// Note: TYPE is parameters[3]
// This works because NaN selects the default width
this.setWidth(
parseInt(this.parameters[4]) + INPUT_PADDING,
'ch',
this.width
this.width,
)
},
}
Expand Down

0 comments on commit 88e94fd

Please sign in to comment.