fix delete_macro
This commit is contained in:
@@ -217,7 +217,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
save_macro: async function () {
|
save_macro: async function () {
|
||||||
if (this.tab == 0 || !this.state.macros[this.tab - 1]) {
|
if (this.tab == 0 || !this.state.macros[this.tab - 1]) {
|
||||||
this.clear_macro();
|
this.load_macro();
|
||||||
this.confirmSave = false;
|
this.confirmSave = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -307,13 +307,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
this.deleteGCode = false;
|
this.deleteGCode = false;
|
||||||
},
|
},
|
||||||
clear_macro: async function () {
|
load_macro: async function () {
|
||||||
if (this.tab == 0 || this.tab > this.state.macros.length) {
|
if (this.tab == 0) {
|
||||||
document.getElementById("macros-name").value = "";
|
document.getElementById("macros-name").value = "";
|
||||||
document.getElementById("macros-color").value = "#ffffff";
|
document.getElementById("macros-color").value = "#ffffff";
|
||||||
this.isChecked = true;
|
this.isChecked = true;
|
||||||
this.fileName = "default";
|
this.fileName = "default";
|
||||||
this.tab = "0";
|
|
||||||
this.newGcode = "";
|
this.newGcode = "";
|
||||||
} else {
|
} else {
|
||||||
const defaultValue = this.state.macros[this.tab - 1];
|
const defaultValue = this.state.macros[this.tab - 1];
|
||||||
@@ -388,7 +387,7 @@ module.exports = {
|
|||||||
console.error("Restore Failed: ", error);
|
console.error("Restore Failed: ", error);
|
||||||
alert("Restore failed");
|
alert("Restore failed");
|
||||||
}
|
}
|
||||||
this.clear_macro();
|
this.load_macro();
|
||||||
},
|
},
|
||||||
add_new_macro: async function () {
|
add_new_macro: async function () {
|
||||||
let length = this.state.macros.length;
|
let length = this.state.macros.length;
|
||||||
@@ -407,6 +406,8 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
this.config.macros = [...this.state.macros];
|
this.config.macros = [...this.state.macros];
|
||||||
this.config.macros.push(newMacros);
|
this.config.macros.push(newMacros);
|
||||||
|
this.tab = this.state.macros.length + 1;
|
||||||
|
this.load_macro();
|
||||||
this.addMacros = false;
|
this.addMacros = false;
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
@@ -418,14 +419,14 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
delete_selected_macro: async function () {
|
delete_selected_macro: async function () {
|
||||||
if (this.tab == 0) {
|
if (this.tab == 0) {
|
||||||
this.clear_macro();
|
this.load_macro();
|
||||||
this.deleteSelected = false;
|
this.deleteSelected = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.config.macros = [...this.state.macros];
|
this.config.macros = [...this.state.macros];
|
||||||
this.config.macros.splice(this.tab - 1, 1);
|
this.config.macros.splice(this.tab - 1, 1);
|
||||||
this.tab--;
|
this.tab--;
|
||||||
this.clear_macro();
|
this.load_macro();
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
this.$dispatch("update");
|
this.$dispatch("update");
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ script#macros-template(type="text/x-template")
|
|||||||
div(style="display:flex;align-items:center;margin-left:30px")
|
div(style="display:flex;align-items:center;margin-left:30px")
|
||||||
h2 Select Macro
|
h2 Select Macro
|
||||||
select(id="macros-select",title="Select a Macro to edit.",selected
|
select(id="macros-select",title="Select a Macro to edit.",selected
|
||||||
v-model="tab",@change="clear_macro",
|
v-model="tab",@change="load_macro",
|
||||||
style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px")
|
style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px")
|
||||||
option( selected='' value='0') Select a Macro
|
option( selected='' value='0') Select a Macro
|
||||||
option(v-for="(index,file) in macros_list", :value="index+1") {{file}}
|
option(v-for="(index,file) in macros_list", :value="index+1") {{file}}
|
||||||
@@ -135,4 +135,4 @@ script#macros-template(type="text/x-template")
|
|||||||
button.pure-button(@click="confirmSave=false") Cancel
|
button.pure-button(@click="confirmSave=false") Cancel
|
||||||
button.pure-button.pure-button-primary(@click="save_macro") Confirm
|
button.pure-button.pure-button-primary(@click="save_macro") Confirm
|
||||||
|
|
||||||
button.submit-macros(title="Cancel Macro",@click="clear_macro",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") Cancel
|
button.submit-macros(title="Cancel Macro",@click="load_macro",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") Cancel
|
||||||
|
|||||||
Reference in New Issue
Block a user