mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Check added when saving macro. Fixed bug when loading macro.
This commit is contained in:
parent
b28632fc2d
commit
922b2bc4f5
4 changed files with 51 additions and 11 deletions
|
|
@ -6,11 +6,11 @@
|
||||||
<div class="macro-item" v-for="(macro, i) in macros.list" :key="i">
|
<div class="macro-item" v-for="(macro, i) in macros.list" :key="i">
|
||||||
<ButtonComp
|
<ButtonComp
|
||||||
variant="dark"
|
variant="dark"
|
||||||
class="w-full"
|
class="overview__macro-button"
|
||||||
size="sm"
|
size="sm"
|
||||||
@click="macroRecorder.open(macro.macroname, macro.name)"
|
@click="macroRecorder.open(macro.macroname, macro.name)"
|
||||||
>
|
>
|
||||||
<IconKeyboard /> {{ macro.name }}
|
<IconKeyboard /> <span>{{ macro.name }}</span>
|
||||||
</ButtonComp>
|
</ButtonComp>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
// TODO
|
// TODO
|
||||||
// - load macro on click
|
|
||||||
// - delete macro
|
// - delete macro
|
||||||
|
|
||||||
import { IconKeyboard } from '@tabler/icons-vue'
|
import { IconKeyboard } from '@tabler/icons-vue'
|
||||||
|
|
@ -77,8 +76,12 @@ const loadMacroList = async () => {
|
||||||
.macro-item {
|
.macro-item {
|
||||||
@apply flex items-center;
|
@apply flex items-center;
|
||||||
|
|
||||||
button {
|
button.overview__macro-button {
|
||||||
@apply w-full;
|
@apply w-full grid grid-cols-[1rem_1fr] justify-items-start;
|
||||||
|
|
||||||
|
span {
|
||||||
|
@apply truncate w-full text-left;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,27 @@
|
||||||
<ValidationErrorDialog />
|
<ValidationErrorDialog />
|
||||||
</template>
|
</template>
|
||||||
</DialogComp>
|
</DialogComp>
|
||||||
|
<DialogComp ref="overwriteDialog">
|
||||||
|
<template #content>
|
||||||
|
<div class="grid gap-2">
|
||||||
|
<h4 class="pr-4">Are you sure you want to overwrite:</h4>
|
||||||
|
<h3 class="mb-2 text-center text-sky-500">{{ macroRecorder.macroName }}</h3>
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<ButtonComp variant="subtle" @click="overwriteDialog.toggleDialog(false)"
|
||||||
|
>No</ButtonComp
|
||||||
|
>
|
||||||
|
<ButtonComp variant="primary" @click="saveMacro()">Yes</ButtonComp>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</DialogComp>
|
||||||
|
|
||||||
<ButtonComp
|
<ButtonComp
|
||||||
v-if="macroRecorder.steps.length > 0"
|
v-if="macroRecorder.steps.length > 0"
|
||||||
:disabled="macroRecorder.state.record || macroRecorder.state.edit"
|
:disabled="macroRecorder.state.record || macroRecorder.state.edit"
|
||||||
variant="success"
|
variant="success"
|
||||||
size="sm"
|
size="sm"
|
||||||
@click="toggleSave()"
|
@click="startCheck()"
|
||||||
>
|
>
|
||||||
<IconDeviceFloppy />
|
<IconDeviceFloppy />
|
||||||
Save
|
Save
|
||||||
|
|
@ -40,6 +54,7 @@ import { onMounted, ref } from 'vue'
|
||||||
const macroRecorder = useMacroRecorderStore()
|
const macroRecorder = useMacroRecorderStore()
|
||||||
|
|
||||||
const errorDialog = ref()
|
const errorDialog = ref()
|
||||||
|
const overwriteDialog = ref()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
macroRecorder.$subscribe((mutation) => {
|
macroRecorder.$subscribe((mutation) => {
|
||||||
|
|
@ -49,7 +64,16 @@ onMounted(() => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const toggleSave = async () => {
|
const startCheck = async () => {
|
||||||
|
const checkResp = await macroRecorder.check()
|
||||||
|
|
||||||
|
if (checkResp) overwriteDialog.value.toggleDialog(true)
|
||||||
|
else saveMacro()
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveMacro = async () => {
|
||||||
|
overwriteDialog.value.toggleDialog(false)
|
||||||
|
|
||||||
const saveResp = await macroRecorder.save()
|
const saveResp = await macroRecorder.save()
|
||||||
|
|
||||||
if (!saveResp) errorDialog.value.toggleDialog(true)
|
if (!saveResp) errorDialog.value.toggleDialog(true)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
id="macro-name"
|
id="macro-name"
|
||||||
type="text"
|
type="text"
|
||||||
@input.prevent="changeName($event.target.value)"
|
@input.prevent="changeName($event.target.value)"
|
||||||
v-model="macroName"
|
:value="macroName"
|
||||||
placeholder="New macro"
|
placeholder="New macro"
|
||||||
/>
|
/>
|
||||||
<div :class="`recording__buttons ${!nameSet || macroRecorder.state.edit ? 'disabled' : ''}`">
|
<div :class="`recording__buttons ${!nameSet || macroRecorder.state.edit ? 'disabled' : ''}`">
|
||||||
|
|
@ -63,7 +63,7 @@ import FixedDelayMenu from '../components/FixedDelayMenu.vue'
|
||||||
|
|
||||||
import { useMacroRecorderStore } from '@/stores/macrorecorder'
|
import { useMacroRecorderStore } from '@/stores/macrorecorder'
|
||||||
import EditDialogs from './EditDialogs.vue'
|
import EditDialogs from './EditDialogs.vue'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, onUpdated, ref } from 'vue'
|
||||||
|
|
||||||
const macroRecorder = useMacroRecorderStore()
|
const macroRecorder = useMacroRecorderStore()
|
||||||
|
|
||||||
|
|
@ -71,7 +71,13 @@ const macroName = computed(() => macroRecorder.macroName)
|
||||||
|
|
||||||
const nameSet = ref(false)
|
const nameSet = ref(false)
|
||||||
|
|
||||||
|
onUpdated(() => {
|
||||||
|
nameSet.value = macroName.value && macroName.value.length > 0
|
||||||
|
})
|
||||||
|
|
||||||
function changeName(name) {
|
function changeName(name) {
|
||||||
|
console.log(name)
|
||||||
|
|
||||||
macroRecorder.changeName(name)
|
macroRecorder.changeName(name)
|
||||||
nameSet.value = name.length > 0
|
nameSet.value = name.length > 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,14 @@ export const useMacroRecorderStore = defineStore('macrorecorder', () => {
|
||||||
if (state.value.edit) resetEdit()
|
if (state.value.edit) resetEdit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const check = async () => {
|
||||||
|
const resp = await axios.post(appUrl() + '/macro/check', {
|
||||||
|
macro: macroName.value,
|
||||||
|
})
|
||||||
|
|
||||||
|
return resp.data
|
||||||
|
}
|
||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
state.value.validationErrors = invalidMacro(steps.value)
|
state.value.validationErrors = invalidMacro(steps.value)
|
||||||
|
|
||||||
|
|
@ -189,8 +197,6 @@ export const useMacroRecorderStore = defineStore('macrorecorder', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const open = async (macroFileName, name) => {
|
const open = async (macroFileName, name) => {
|
||||||
console.log(name)
|
|
||||||
|
|
||||||
const openResp = await axios.post(appUrl() + '/macro/open', {
|
const openResp = await axios.post(appUrl() + '/macro/open', {
|
||||||
macro: macroFileName,
|
macro: macroFileName,
|
||||||
})
|
})
|
||||||
|
|
@ -219,6 +225,7 @@ export const useMacroRecorderStore = defineStore('macrorecorder', () => {
|
||||||
toggleEdit,
|
toggleEdit,
|
||||||
resetEdit,
|
resetEdit,
|
||||||
reset,
|
reset,
|
||||||
|
check,
|
||||||
save,
|
save,
|
||||||
open,
|
open,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue