From 7de8d7f2754ff118f88b69e18662fbe6638e3158 Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Tue, 5 May 2026 11:31:49 +0200 Subject: [PATCH] corregida edicion de menus --- CHANGELOG.md | 4 +++ .../create-menu/create-menu.component.css | 35 +++++++++++++++++-- .../create-menu/create-menu.component.html | 8 ++++- .../create-menu/create-menu.component.ts | 32 ++++++++++++++++- ogWebconsole/src/locale/cat.json | 2 +- ogWebconsole/src/locale/en.json | 2 +- ogWebconsole/src/locale/es.json | 2 +- 7 files changed, 78 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ee167..97f4414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [1.5.6] - 2026-05-05 +### Fixed +- Corregida edicion de menus + ## [1.5.5] - 2026-05-04 ### Fixed - Corregida gestion de oglives diff --git a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.css b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.css index c582433..afeacf3 100644 --- a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.css +++ b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.css @@ -32,12 +32,43 @@ gap: 10px; } -.iframe { +.iframe-wrapper { width: 100%; - height: 600px; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + background: #000; +} + +.iframe-wrapper.scroll-view { + height: 600px; + overflow: auto; +} + +.iframe-wrapper.global-view { + aspect-ratio: 4 / 3; + position: relative; + overflow: hidden; +} + +.iframe { + border: none; +} + +.iframe.scroll-view { + width: 1280px; + height: 1024px; + display: block; +} + +.iframe.global-view { + position: absolute; + top: 0; + left: 0; + width: 250%; + height: 250%; + transform: scale(0.4); + transform-origin: 0 0; } .editor-controls { diff --git a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html index 30ee802..b5652e3 100644 --- a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html +++ b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html @@ -64,6 +64,10 @@ } @else if (safeUrl) { + } @@ -73,7 +77,9 @@ @if (isEditingHtml) { } @else if (safeUrl) { - +
+ +
} diff --git a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts index b04f0d3..e9ad1b6 100644 --- a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts +++ b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts @@ -25,6 +25,7 @@ export class CreateMenuComponent implements OnInit { fileContent: string | null = null; isEditingHtml: boolean = false; htmlEditorContent: string = ''; + isGlobalView: boolean = false; constructor( private fb: FormBuilder, @@ -120,8 +121,21 @@ export class CreateMenuComponent implements OnInit { // Ask the backend to compile a preview using this encoded Twig this.dataService.previewMenuTemplate(base64Content).subscribe({ next: (renderedHtml) => { + // Ensure relative paths work in the data URL iframe by injecting a tag + const origin = new URL(this.baseUrl).origin; + const baseTag = ``; + + let finalHtml = renderedHtml; + if (finalHtml.toLowerCase().includes('')) { + finalHtml = finalHtml.replace(//i, `${baseTag}`); + } else if (finalHtml.toLowerCase().includes('')) { + finalHtml = finalHtml.replace(//i, `${baseTag}`); + } else { + finalHtml = `${baseTag}` + finalHtml; + } + // Now encode the definitively rendered HTML to Base64 to populate the iframe preview - const renderedBytes = new TextEncoder().encode(renderedHtml); + const renderedBytes = new TextEncoder().encode(finalHtml); const renderedBinaryStr = Array.from(renderedBytes).map(byte => String.fromCharCode(byte)).join(''); const renderedBase64 = window.btoa(renderedBinaryStr); @@ -149,6 +163,10 @@ export class CreateMenuComponent implements OnInit { this.htmlEditorContent = ''; } + toggleGlobalView(): void { + this.isGlobalView = !this.isGlobalView; + } + ngOnInit() { if (this.data) { this.load() @@ -183,6 +201,18 @@ export class CreateMenuComponent implements OnInit { isDefault: this.menuForm.value.isDefault, }; + // Si el usuario le da a Guardar mientras está editando el HTML (sin haberle dado a Aplicar Cambios), + // guardamos automáticamente lo que haya en el editor de texto. + if (this.isEditingHtml && this.htmlEditorContent) { + try { + const bytes = new TextEncoder().encode(this.htmlEditorContent); + const binaryStr = Array.from(bytes).map(byte => String.fromCharCode(byte)).join(''); + this.fileContent = window.btoa(binaryStr); + } catch (e) { + console.error('Failed to encode HTML content before saving', e); + } + } + if (this.fileContent) { payload.menuHtmlContent = this.fileContent; } diff --git a/ogWebconsole/src/locale/cat.json b/ogWebconsole/src/locale/cat.json index 5654a81..da919ca 100644 --- a/ogWebconsole/src/locale/cat.json +++ b/ogWebconsole/src/locale/cat.json @@ -105,7 +105,7 @@ "busyEquipments": "Equips Ocupats", "buttonAccept": "Acceptar", "buttonAdd": "Afegir", - "buttonApplyChanges": "Aplicar Canvis", + "buttonApplyChanges": "Previsualitzar", "buttonCancel": "Cancel·lar", "buttonCancelEdit": "Cancel·lar Edició", "buttonCancelEn": "Cancel·lar", diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json index c25157c..1245fae 100644 --- a/ogWebconsole/src/locale/en.json +++ b/ogWebconsole/src/locale/en.json @@ -105,7 +105,7 @@ "busyEquipments": "Busy Equipment", "buttonAccept": "Accept", "buttonAdd": "Add", - "buttonApplyChanges": "Apply Changes", + "buttonApplyChanges": "Preview", "buttonCancel": "Cancel", "buttonCancelEdit": "Cancel Edit", "buttonCancelEn": "Cancel", diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json index 4c5da57..7d23dc5 100644 --- a/ogWebconsole/src/locale/es.json +++ b/ogWebconsole/src/locale/es.json @@ -105,7 +105,7 @@ "busyEquipments": "Equipos Ocupados", "buttonAccept": "Aceptar", "buttonAdd": "Añadir", - "buttonApplyChanges": "Aplicar Cambios", + "buttonApplyChanges": "Previsualizar", "buttonCancel": "Cancelar", "buttonCancelEdit": "Cancelar Edición", "buttonCancelEn": "Cancelar", -- 2.40.1