feat(templates-points-controle): Ajoute la gestion et l'application de modèles de points de contrôle aux produits.

This commit is contained in:
Serreau Jovann
2026-02-06 18:04:13 +01:00
parent 65e3045cbc
commit 38f8762efe
14 changed files with 448 additions and 13 deletions

View File

@@ -14,6 +14,7 @@ import PlaningLogestics from "./libs/PlaningLogestics.js";
import {SortableReorder} from "./libs/SortableReorder.js";
import { StripeCommissionCalculator } from "./libs/StripeCommissionCalculator.js";
import { ProductAddOption } from "./libs/ProductAddOption.js";
import { TemplateApply } from "./libs/TemplateApply.js";
import { LeafletMap } from "./tools/LeafletMap.js";
// --- CONFIGURATION SENTRY ---
@@ -45,6 +46,7 @@ const registerCustomElements = () => {
{ name: 'crm-editor', class: CrmEditor, extends: 'textarea' },
{ name: 'stripe-commission-calculator', class: StripeCommissionCalculator, extends: 'div' },
{ name: 'product-add-option', class: ProductAddOption, extends: 'button' },
{ name: 'template-apply', class: TemplateApply, extends: 'button' },
{ name: 'leaflet-map', class: LeafletMap }
];

View File

@@ -0,0 +1,26 @@
export class TemplateApply extends HTMLButtonElement {
constructor() {
super();
this.addEventListener('click', this.apply.bind(this));
}
apply() {
const selectorId = this.getAttribute('data-selector');
const urlPattern = this.getAttribute('data-url-pattern');
const selector = document.querySelector(selectorId);
if (!selector) return;
const templateId = selector.value;
if (!templateId) return;
if (!confirm('Appliquer ce modèle ? Cela ajoutera les points de contrôle au produit.')) return;
const form = document.createElement('form');
form.method = 'POST';
form.action = urlPattern.replace('TEMPLATE_ID', templateId);
document.body.appendChild(form);
form.submit();
}
}