From a8406059595c6fa561f6fedf85429ecd94b7f6cd Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Thu, 11 Jan 2024 23:48:25 +0530 Subject: [PATCH] wrote func for event handling for save button --- src/js/macros.js | 6 +----- src/pug/templates/macros.pug | 16 ++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/js/macros.js b/src/js/macros.js index f17a1b1..30ddb35 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -48,19 +48,16 @@ module.exports = { const file = this.state.selected; this.$broadcast("gcode-load", file); this.$broadcast("gcode-line", this.state.line); - this.newGCode[this.tab-1] = ""; + this.newGCode[this.currentTab] = ""; }, upload: function (e) { - console.log('54'); const files = e.target.files || e.dataTransfer.files; if (!files.length) { return; } const file = files[0]; - console.log(file); const extension = file.name.split(".").pop(); - console.log(extension); switch (extension.toLowerCase()) { case "nc": case "ngc": @@ -72,7 +69,6 @@ module.exports = { alert(`Unsupported file type: ${extension}`); return; } - console.log("file: ",file); SvelteComponents.showDialog("Upload", { file, onComplete: () => { diff --git a/src/pug/templates/macros.pug b/src/pug/templates/macros.pug index 5080634..f700605 100644 --- a/src/pug/templates/macros.pug +++ b/src/pug/templates/macros.pug @@ -77,7 +77,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=0;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=0; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -107,7 +107,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=1;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=1; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -137,7 +137,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=2;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=2; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -167,7 +167,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=3;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=3; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -197,7 +197,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=4;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=4; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -227,7 +227,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=5;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=5; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -257,7 +257,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=6;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=6; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel @@ -287,7 +287,7 @@ script#macros-template(type="text/x-template") .gcodeContainer textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode") gcode-viewer(v-if="state.selected !== 'default'") - button.submit-macros(title="Save Macros",v-on:click="currentTab=7;confirmSave=true", + button.submit-macros(title="Save Macros",@click="()=>{currentTab=7; confirmSave=true}", style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save button.submit-macros(title="Cancel Macros",@click="cancelMacros", style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel