fix delete_macro
This commit is contained in:
@@ -217,7 +217,7 @@ module.exports = {
|
||||
},
|
||||
save_macro: async function () {
|
||||
if (this.tab == 0 || !this.state.macros[this.tab - 1]) {
|
||||
this.clear_macro();
|
||||
this.load_macro();
|
||||
this.confirmSave = false;
|
||||
return;
|
||||
}
|
||||
@@ -307,13 +307,12 @@ module.exports = {
|
||||
}
|
||||
this.deleteGCode = false;
|
||||
},
|
||||
clear_macro: async function () {
|
||||
if (this.tab == 0 || this.tab > this.state.macros.length) {
|
||||
load_macro: async function () {
|
||||
if (this.tab == 0) {
|
||||
document.getElementById("macros-name").value = "";
|
||||
document.getElementById("macros-color").value = "#ffffff";
|
||||
this.isChecked = true;
|
||||
this.fileName = "default";
|
||||
this.tab = "0";
|
||||
this.newGcode = "";
|
||||
} else {
|
||||
const defaultValue = this.state.macros[this.tab - 1];
|
||||
@@ -388,7 +387,7 @@ module.exports = {
|
||||
console.error("Restore Failed: ", error);
|
||||
alert("Restore failed");
|
||||
}
|
||||
this.clear_macro();
|
||||
this.load_macro();
|
||||
},
|
||||
add_new_macro: async function () {
|
||||
let length = this.state.macros.length;
|
||||
@@ -407,6 +406,8 @@ module.exports = {
|
||||
};
|
||||
this.config.macros = [...this.state.macros];
|
||||
this.config.macros.push(newMacros);
|
||||
this.tab = this.state.macros.length + 1;
|
||||
this.load_macro();
|
||||
this.addMacros = false;
|
||||
try {
|
||||
await api.put("config/save", this.config);
|
||||
@@ -418,14 +419,14 @@ module.exports = {
|
||||
},
|
||||
delete_selected_macro: async function () {
|
||||
if (this.tab == 0) {
|
||||
this.clear_macro();
|
||||
this.load_macro();
|
||||
this.deleteSelected = false;
|
||||
return;
|
||||
}
|
||||
this.config.macros = [...this.state.macros];
|
||||
this.config.macros.splice(this.tab - 1, 1);
|
||||
this.tab--;
|
||||
this.clear_macro();
|
||||
this.load_macro();
|
||||
try {
|
||||
await api.put("config/save", this.config);
|
||||
this.$dispatch("update");
|
||||
|
||||
@@ -82,7 +82,7 @@ script#macros-template(type="text/x-template")
|
||||
div(style="display:flex;align-items:center;margin-left:30px")
|
||||
h2 Select Macro
|
||||
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")
|
||||
option( selected='' value='0') Select a Macro
|
||||
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.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