- Create Billet entity: name, position, priceHT, quantity (nullable=unlimited), isGeneratedBillet, hasDefinedExit, notBuyable, type (billet/reservation_brocante/vote), stripeProductId, description, picture (VichUploader), category (ManyToOne CASCADE) - Create BilletDesign entity (OneToOne Event): accentColor, invitationTitle, invitationColor - Billet CRUD: add/edit/delete with access control, Stripe product sync on connected account - Billet reorder: drag & drop with position field, refactored sortable.js for both categories and billets - Ticket designer tab (custom offer only): accent color, invitation title/color, live iframe preview - A4 ticket preview: 4 zones (HG infos+billet, HD affiche, BG association, BD sortie+invitation), fake QR code SVG - Commission calculator JS: live breakdown of E-Ticket fee, Stripe fee (1.5%+0.25EUR), net amount - Sales recap on categories tab: qty sold, total HT, total commissions, total net - DisableProfilerSubscriber: disable web profiler toolbar on preview iframe - CSP: allow self in frame-src and frame-ancestors for preview iframe - Flysystem: dedicated billets.storage for billet images - Upload accept restricted to png/jpeg/webp/gif (no HEIC) - Makefile: add force_sql_dev command - CLAUDE.md: add rule to never modify existing migrations - Consolidate all migrations into single Version20260321111125 - Tests: BilletTest (20), BilletDesignTest (6), DisableProfilerSubscriberTest (5), billet-designer.test.js (7), commission-calculator.test.js (7), AccountControllerTest billet CRUD tests (11) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
function makeSortable(list, itemSelector, idAttr) {
|
|
const reorderUrl = list.dataset.reorderUrl
|
|
if (!reorderUrl) return
|
|
|
|
let dragEl = null
|
|
|
|
list.addEventListener('dragstart', (e) => {
|
|
dragEl = e.target.closest(itemSelector)
|
|
if (dragEl) {
|
|
dragEl.classList.add('opacity-50')
|
|
e.dataTransfer.effectAllowed = 'move'
|
|
}
|
|
})
|
|
|
|
list.addEventListener('dragend', () => {
|
|
if (dragEl) {
|
|
dragEl.classList.remove('opacity-50')
|
|
dragEl = null
|
|
}
|
|
})
|
|
|
|
list.addEventListener('dragover', (e) => {
|
|
e.preventDefault()
|
|
const target = e.target.closest(itemSelector)
|
|
if (target && target !== dragEl) {
|
|
const rect = target.getBoundingClientRect()
|
|
const mid = rect.top + rect.height / 2
|
|
if (e.clientY < mid) {
|
|
target.before(dragEl)
|
|
} else {
|
|
target.after(dragEl)
|
|
}
|
|
}
|
|
})
|
|
|
|
list.addEventListener('drop', (e) => {
|
|
e.preventDefault()
|
|
const items = list.querySelectorAll(itemSelector)
|
|
const order = Array.from(items).map(el => Number.parseInt(el.getAttribute(idAttr), 10))
|
|
|
|
globalThis.fetch(reorderUrl, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(order),
|
|
})
|
|
})
|
|
|
|
list.querySelectorAll(itemSelector).forEach(el => {
|
|
el.setAttribute('draggable', 'true')
|
|
})
|
|
}
|
|
|
|
export function initSortable() {
|
|
const categoriesList = document.getElementById('categories-list')
|
|
if (categoriesList) {
|
|
makeSortable(categoriesList, '[data-id]', 'data-id')
|
|
}
|
|
|
|
document.querySelectorAll('.billets-list').forEach(list => {
|
|
makeSortable(list, '[data-billet-id]', 'data-billet-id')
|
|
})
|
|
}
|