bug fix in file_delete

This commit is contained in:
sanjayk03-dev
2024-04-08 11:49:42 +05:30
parent 00fac25f24
commit 15c0da4336
2 changed files with 11 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ module.exports = {
macrosName: "", macrosName: "",
isChecked: false, isChecked: false,
macroFoundName: "", macroFoundName: "",
macroFoundGcode: "",
fileName: "default", fileName: "default",
newGcode: "", newGcode: "",
}; };
@@ -124,6 +125,8 @@ module.exports = {
removeFromList: async function () { removeFromList: async function () {
this.config.macros_list = [...this.state.macros_list]; this.config.macros_list = [...this.state.macros_list];
this.config.macros_list = this.config.macros_list.filter(item => item.file_name != this.fileName); this.config.macros_list = this.config.macros_list.filter(item => item.file_name != this.fileName);
this.config.macros = [...this.state.macros];
this.config.macros.filter(item => item.file_name == this.fileName).forEach(item => (item.file_name = "default"));
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
this.$dispatch("update"); this.$dispatch("update");
@@ -267,7 +270,8 @@ module.exports = {
); );
if (macro_with_filename) { if (macro_with_filename) {
this.deleteGCode = false; this.deleteGCode = false;
this.macroFoundName = macro_with_filename.file_name; this.macroFoundName = macro_with_filename.name;
this.macroFoundGcode = macro_with_filename.file_name;
this.macroFound = true; this.macroFound = true;
} else { } else {
this.delete_current(); this.delete_current();
@@ -280,6 +284,8 @@ module.exports = {
); );
if (macro_with_filename.length != 0) { if (macro_with_filename.length != 0) {
this.macroFound = false; this.macroFound = false;
this.macroFoundName = "";
this.macroFoundGcode = "";
macro_with_filename.forEach(item => (item.file_name = "default")); macro_with_filename.forEach(item => (item.file_name = "default"));
} }
if (filename == "default") { if (filename == "default") {

View File

@@ -13,7 +13,9 @@ script#macros-template(type="text/x-template")
h3(slot="header") Alert h3(slot="header") Alert
div(slot="body") div(slot="body")
p p
| The file is currently being used by a macro | The file
strong {{macroFoundGcode}}
| is currently being used by a macro
strong {{macroFoundName}} strong {{macroFoundName}}
| . You need to re-select a file for the macro. | . You need to re-select a file for the macro.
div(slot="footer") div(slot="footer")