mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'feat/screenshot-forma' into 'mod/presupuesto_admin'
add downloadPreviewImage function to download image as png from the current shape selected See merge request jjimenez/safekat!468
This commit is contained in:
@ -206,6 +206,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_bn_shape" class="draw-shapes"></div>
|
<div id="pv_bn_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -284,6 +287,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_bnhq_shape" class="draw-shapes"></div>
|
<div id="pv_bnhq_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -362,6 +368,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_color_shape" class="draw-shapes"></div>
|
<div id="pv_color_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -440,6 +449,10 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="pv_colorhq_shape" class="draw-shapes"></div>
|
<div id="pv_colorhq_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -516,6 +529,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
|
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -593,6 +609,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
|
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -671,6 +690,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_guardas_shape" class="draw-shapes"></div>
|
<div id="pv_guardas_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -752,6 +774,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewCubierta") ?></h6>
|
<h6><?= lang("Presupuestos.previewCubierta") ?></h6>
|
||||||
|
|
||||||
<div id="pv-cubierta-container">
|
<div id="pv-cubierta-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_cubierta_shape" class="draw-shapes"></div>
|
<div id="pv_cubierta_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -817,6 +842,9 @@
|
|||||||
<h6><?= lang("Presupuestos.previewConfiguracionEsquemaCubierta") ?></h6>
|
<h6><?= lang("Presupuestos.previewConfiguracionEsquemaCubierta") ?></h6>
|
||||||
|
|
||||||
<div id="shape-container">
|
<div id="shape-container">
|
||||||
|
<div class="d-flex align-items-stretch justify-content-end">
|
||||||
|
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
|
||||||
|
</div>
|
||||||
<div id="pv_ec_shape" class="draw-shapes"></div>
|
<div id="pv_ec_shape" class="draw-shapes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -983,5 +1011,3 @@ $('#tab-pv-sobrecubierta').on( "click", function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,7 @@ class PresupuestoAdminEdit {
|
|||||||
sessionStorage.removeItem('message');
|
sessionStorage.removeItem('message');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.downloadPreviewImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#cargarPresupuesto() {
|
#cargarPresupuesto() {
|
||||||
@ -257,6 +258,37 @@ class PresupuestoAdminEdit {
|
|||||||
showBreadCrumbSaveButton(true);
|
showBreadCrumbSaveButton(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
downloadPreviewImage() {
|
||||||
|
$(document).on("click", ".download-shape", (event) => {
|
||||||
|
let parentDiv = $(event.currentTarget).parent().parent();
|
||||||
|
let shapeSvgElQuery = $(parentDiv).find("svg");
|
||||||
|
let shapeSvgEl = shapeSvgElQuery[0];
|
||||||
|
const filename = shapeSvgElQuery.parent().attr("id") ?? "image"
|
||||||
|
const serializer = new XMLSerializer();
|
||||||
|
const svgData = serializer.serializeToString(shapeSvgEl);
|
||||||
|
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' });
|
||||||
|
const svgUrl = URL.createObjectURL(svgBlob);
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = () => {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = img.width;
|
||||||
|
canvas.height = img.height;
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
const pngUrl = canvas.toDataURL('image/png');
|
||||||
|
const downloadLink = document.createElement('a');
|
||||||
|
downloadLink.href = pngUrl;
|
||||||
|
downloadLink.download = filename ?? '.png';
|
||||||
|
document.body.appendChild(downloadLink);
|
||||||
|
downloadLink.click();
|
||||||
|
document.body.removeChild(downloadLink);
|
||||||
|
|
||||||
|
URL.revokeObjectURL(svgUrl);
|
||||||
|
};
|
||||||
|
|
||||||
|
img.src = svgUrl;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user