feat: Templates persistentes en servidor + Constructor con tabs por tipo de comando
- Templates ahora se guardan en servidor (data/templates.json) disponibles para todos - API CRUD para templates: GET/POST /api/templates, GET/PUT/DELETE /api/templates/[id] - Constructor de comandos rediseñado con tabs: Texto, Feed, Cortar, Pulse, QR, Barcode - Cada tipo de comando tiene su formulario específico con campos relevantes - Eliminado QuickActions (integrado en tabs del constructor) - Mejorada UI de lista de impresoras con renderizado condicional - Agregado data/ a .gitignore (datos de runtime)
This commit is contained in:
@@ -1,21 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
const queue = usePrintQueue()
|
||||
const templates = useTemplates()
|
||||
const toast = useToast()
|
||||
|
||||
const saveDrawerOpen = ref(false)
|
||||
const templateName = ref('')
|
||||
const templateDescription = ref('')
|
||||
const saving = ref(false)
|
||||
|
||||
function saveAsTemplate() {
|
||||
async function saveAsTemplate() {
|
||||
if (!templateName.value.trim()) return
|
||||
templates.saveTemplate(
|
||||
templateName.value.trim(),
|
||||
templateDescription.value.trim(),
|
||||
queue.operations.value as any
|
||||
)
|
||||
templateName.value = ''
|
||||
templateDescription.value = ''
|
||||
saveDrawerOpen.value = false
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const result = await templates.saveTemplate(
|
||||
templateName.value.trim(),
|
||||
templateDescription.value.trim(),
|
||||
queue.operations.value as any
|
||||
)
|
||||
|
||||
if (result) {
|
||||
toast.add({ title: 'Template guardado', color: 'success' })
|
||||
templateName.value = ''
|
||||
templateDescription.value = ''
|
||||
saveDrawerOpen.value = false
|
||||
} else {
|
||||
toast.add({ title: 'Error al guardar template', color: 'error' })
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -101,7 +115,7 @@ function saveAsTemplate() {
|
||||
<UButton variant="ghost" @click="saveDrawerOpen = false">
|
||||
Cancelar
|
||||
</UButton>
|
||||
<UButton color="primary" :disabled="!templateName.trim()" @click="saveAsTemplate">
|
||||
<UButton color="primary" :disabled="!templateName.trim()" :loading="saving" @click="saveAsTemplate">
|
||||
Guardar
|
||||
</UButton>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user