bugfix: add warning when saving a empty preset

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej 2021-01-23 23:05:58 +01:00
parent bce06f0e1b
commit d786d88348

View File

@ -112,6 +112,11 @@
></v-textarea>
</v-col>
</v-row>
<v-row v-if="dialog.boolInvalidMin">
<v-col class="py-0">
<v-alert dense text type="error">You have to set minimum a target temperature or a custom gcode.</v-alert>
</v-col>
</v-row>
<v-row class="mt-3">
<v-col class="text-center">
<v-btn
@ -202,6 +207,7 @@
name: "",
gcode: "",
index: null,
boolInvalidMin: false,
values: {},
},
rules: {
@ -248,6 +254,7 @@
this.dialog.index = null
this.dialog.name = ""
this.dialog.gcode = ""
this.dialog.boolInvalidMin = false
this.dialog.values = {}
for(const heater of this["printer/getHeaters"]) {
@ -274,7 +281,14 @@
this.dialog.bool = true
},
savePreset() {
if (this.dialog.valid) {
let setValues = 0
for (const key of Object.keys(this.dialog.values)) {
if (this.dialog.values[key].bool) setValues++
}
if (this.dialog.gcode.length) setValues++
if (setValues === 0) this.dialog.boolInvalidMin = true
else if (this.dialog.valid) {
for (const key of Object.keys(this.dialog.values)) {
this.dialog.values[key].value = parseInt(this.dialog.values[key].value)
}