@solidpepper/solidpepper-soliddesigner 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-C9bBywd4.mjs +618 -0
  2. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-C9bBywd4.mjs.map +1 -0
  3. package/fesm2022/{solidpepper-solidpepper-soliddesigner-image-utils-BZ877qA2.mjs → solidpepper-solidpepper-soliddesigner-image-utils-CAk9N60P.mjs} +2 -2
  4. package/fesm2022/{solidpepper-solidpepper-soliddesigner-image-utils-BZ877qA2.mjs.map → solidpepper-solidpepper-soliddesigner-image-utils-CAk9N60P.mjs.map} +1 -1
  5. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CX9XUnS3.mjs +1219 -0
  6. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CX9XUnS3.mjs.map +1 -0
  7. package/fesm2022/{solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-DNuvMIlh.mjs → solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-C0NEE_3w.mjs} +3107 -593
  8. package/fesm2022/solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-C0NEE_3w.mjs.map +1 -0
  9. package/fesm2022/solidpepper-solidpepper-soliddesigner.mjs +1 -1
  10. package/index.d.ts +40 -3
  11. package/package.json +1 -1
  12. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-CJ4Uve9q.mjs +0 -152
  13. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-CJ4Uve9q.mjs.map +0 -1
  14. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CSVxODUW.mjs +0 -771
  15. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CSVxODUW.mjs.map +0 -1
  16. package/fesm2022/solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-DNuvMIlh.mjs.map +0 -1
@@ -0,0 +1,1219 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, signal, computed, effect, Input, Component } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i2 from '@ngx-translate/core';
6
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
7
+ import { from, concatMap, toArray } from 'rxjs';
8
+ import { spIconFolder, spIconGrid, spIconPlus, spIconTrash, spIconClose, spIconChevronDown, spIconChevronRight, SpIconComponent } from '@solidpepper/solidpepper-icons';
9
+ import { SpButtonComponent, SpBadgeComponent, SpCheckboxComponent, SpFloatingWindowComponent, SpContextMenuComponent, SpIconButtonComponent } from '@solidpepper/solidpepper-component';
10
+ import { A as AppParamsService, a as AssetsService, M as ModalService, S as SaveService, D as DocumentService, P as PageContextMenuComponent, C as ConfirmDeleteModalComponent } from './solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-C0NEE_3w.mjs';
11
+
12
+ class PageGridModalComponent {
13
+ filterBySection(sectionGuid) {
14
+ this.activeSectionFilter.set(sectionGuid);
15
+ }
16
+ trackByGlobalIndex(index, item) {
17
+ return item.page?.documentPageGuid || item.globalIndex;
18
+ }
19
+ getSectionIndex(page) {
20
+ const sections = this.sections();
21
+ if (!sections || sections.length === 0)
22
+ return 0;
23
+ const secGuid = page?.documentSectionGuid || page?.sectionGuid;
24
+ if (!secGuid)
25
+ return 0;
26
+ const idx = sections.findIndex((s) => s.guid === secGuid);
27
+ return idx !== -1 ? idx : 0;
28
+ }
29
+ getSectionColorClass(page) {
30
+ const sections = this.sections();
31
+ if (!sections || sections.length <= 1) {
32
+ return 'section-border-gray';
33
+ }
34
+ const sIdx = this.getSectionIndex(page);
35
+ if (sIdx === 0) {
36
+ return 'section-border-gray';
37
+ }
38
+ const colorIdx = ((sIdx - 1) % 7) + 1;
39
+ return `section-border-${colorIdx}`;
40
+ }
41
+ getSectionColor(sectionIndex) {
42
+ const sections = this.sections();
43
+ if (!sections || sections.length <= 1 || sectionIndex === 0) {
44
+ return 'oklch(var(--bc) / 0.22)';
45
+ }
46
+ const colors = [
47
+ 'oklch(var(--bc) / 0.22)',
48
+ '#3b82f6', // 1: Blue
49
+ '#10b981', // 2: Emerald Green
50
+ '#8b5cf6', // 3: Violet / Purple
51
+ '#f59e0b', // 4: Amber / Orange
52
+ '#f43f5e', // 5: Rose / Red
53
+ '#06b6d4', // 6: Cyan
54
+ '#6366f1', // 7: Indigo
55
+ ];
56
+ const colorIdx = ((sectionIndex - 1) % 7) + 1;
57
+ return colors[colorIdx];
58
+ }
59
+ getSectionName(page) {
60
+ const sections = this.sections();
61
+ if (!sections || sections.length === 0)
62
+ return '';
63
+ const secGuid = page?.documentSectionGuid || page?.sectionGuid;
64
+ if (!secGuid)
65
+ return '';
66
+ const sec = sections.find((s) => s.guid === secGuid);
67
+ return sec ? sec.name : '';
68
+ }
69
+ getSectionPageCount(sectionGuid) {
70
+ return this.pages().filter((p) => p.documentSectionGuid === sectionGuid || p.sectionGuid === sectionGuid).length;
71
+ }
72
+ scrollToSection(sectionGuid) {
73
+ this.filterBySection(sectionGuid);
74
+ const pages = this.pages();
75
+ const firstIdx = pages.findIndex((p) => p.documentSectionGuid === sectionGuid || p.sectionGuid === sectionGuid);
76
+ if (firstIdx !== -1) {
77
+ const el = document.getElementById(`page-card-${firstIdx}`);
78
+ if (el) {
79
+ el.scrollIntoView({ behavior: 'smooth', block: 'center' });
80
+ }
81
+ }
82
+ }
83
+ openSectionPickerForSelected(event) {
84
+ const items = (this.sections() || []).map((sec) => ({
85
+ id: sec.guid,
86
+ label: sec.name,
87
+ icon: spIconFolder,
88
+ action: () => {
89
+ this.sectionPickerVisible = false;
90
+ this.moveSelectedPagesToSection(sec.guid);
91
+ },
92
+ }));
93
+ this.sectionPickerItems = items;
94
+ this.sectionPickerPosition = { x: event.clientX, y: event.clientY };
95
+ this.sectionPickerVisible = true;
96
+ }
97
+ moveSelectedPagesToSection(targetSectionGuid) {
98
+ const pages = this.pages();
99
+ const selectedIndices = Array.from(this.selectedPageIndices()).sort((a, b) => a - b);
100
+ const pagesToMove = selectedIndices
101
+ .map((i) => pages[i])
102
+ .filter((p) => {
103
+ const sec = p?.documentSectionGuid || p?.sectionGuid;
104
+ return sec !== targetSectionGuid;
105
+ });
106
+ if (pagesToMove.length === 0)
107
+ return;
108
+ this.isLoading.set(true);
109
+ from(pagesToMove)
110
+ .pipe(concatMap((p) => this.assetsService.moveDocumentPageToSection(p.documentPageGuid, targetSectionGuid)), toArray())
111
+ .subscribe({
112
+ next: () => {
113
+ this.selectedPageIndices.set(new Set());
114
+ this.refreshPages();
115
+ },
116
+ error: (err) => {
117
+ console.error('Error moving selected pages to section', err);
118
+ this.isLoading.set(false);
119
+ },
120
+ });
121
+ }
122
+ constructor() {
123
+ this.appParams = inject(AppParamsService);
124
+ this.assetsService = inject(AssetsService);
125
+ this.modalService = inject(ModalService);
126
+ this.saveService = inject(SaveService);
127
+ this.translate = inject(TranslateService);
128
+ this.documentService = inject(DocumentService);
129
+ this.spIconGrid = spIconGrid;
130
+ this.spIconPlus = spIconPlus;
131
+ this.spIconTrash = spIconTrash;
132
+ this.spIconClose = spIconClose;
133
+ this.spIconChevronDown = spIconChevronDown;
134
+ this.spIconChevronRight = spIconChevronRight;
135
+ this.spIconFolder = spIconFolder;
136
+ this.isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
137
+ this.pages = signal([], ...(ngDevMode ? [{ debugName: "pages" }] : []));
138
+ this.sections = computed(() => this.appParams.documentSections(), ...(ngDevMode ? [{ debugName: "sections" }] : []));
139
+ this.hasSections = computed(() => {
140
+ const s = this.sections();
141
+ return s && s.length > 0;
142
+ }, ...(ngDevMode ? [{ debugName: "hasSections" }] : []));
143
+ this.hasMultipleSections = computed(() => {
144
+ const s = this.sections();
145
+ return s && s.length > 1;
146
+ }, ...(ngDevMode ? [{ debugName: "hasMultipleSections" }] : []));
147
+ this.activeSectionFilter = signal(null, ...(ngDevMode ? [{ debugName: "activeSectionFilter" }] : []));
148
+ this.displayedPages = computed(() => {
149
+ const all = this.pages();
150
+ const filter = this.activeSectionFilter();
151
+ if (!filter) {
152
+ return all.map((page, index) => ({ page, globalIndex: index }));
153
+ }
154
+ return all
155
+ .map((page, index) => ({ page, globalIndex: index }))
156
+ .filter((item) => item.page.documentSectionGuid === filter ||
157
+ item.page.sectionGuid === filter);
158
+ }, ...(ngDevMode ? [{ debugName: "displayedPages" }] : []));
159
+ this.needsLeadingSpacer = computed(() => {
160
+ const list = this.displayedPages();
161
+ if (list.length === 0)
162
+ return true;
163
+ const first = list[0];
164
+ if (first.globalIndex === 0)
165
+ return true;
166
+ return (first.globalIndex + 1) % 2 !== 0;
167
+ }, ...(ngDevMode ? [{ debugName: "needsLeadingSpacer" }] : []));
168
+ this.sectionPickerVisible = false;
169
+ this.sectionPickerPosition = { x: 0, y: 0 };
170
+ this.sectionPickerItems = [];
171
+ this.pageAspectRatio = computed(() => {
172
+ const props = this.documentService.properties();
173
+ if (!props.width || !props.height)
174
+ return '210 / 297';
175
+ return `${props.width} / ${props.height}`;
176
+ }, ...(ngDevMode ? [{ debugName: "pageAspectRatio" }] : []));
177
+ this.currentPageIndex = computed(() => {
178
+ const guid = this.appParams.pageGuid();
179
+ const pages = this.pages();
180
+ return pages.findIndex((p) => p.documentPageGuid === guid);
181
+ }, ...(ngDevMode ? [{ debugName: "currentPageIndex" }] : []));
182
+ this.selectedPageIndices = signal(new Set(), ...(ngDevMode ? [{ debugName: "selectedPageIndices" }] : []));
183
+ this.selectedCount = computed(() => this.selectedPageIndices().size, ...(ngDevMode ? [{ debugName: "selectedCount" }] : []));
184
+ this.canSelectAll = computed(() => {
185
+ const displayed = this.displayedPages();
186
+ if (displayed.length === 0)
187
+ return false;
188
+ const selected = this.selectedPageIndices();
189
+ return displayed.some((item) => !selected.has(item.globalIndex));
190
+ }, ...(ngDevMode ? [{ debugName: "canSelectAll" }] : []));
191
+ this.canDeleteSelected = computed(() => {
192
+ const count = this.selectedCount();
193
+ return count > 0 && count < this.pages().length;
194
+ }, ...(ngDevMode ? [{ debugName: "canDeleteSelected" }] : []));
195
+ this.pageCacheBusters = signal({}, ...(ngDevMode ? [{ debugName: "pageCacheBusters" }] : []));
196
+ this.sessionBuster = `s=${Date.now()}`;
197
+ this.pageImageUrls = computed(() => {
198
+ const busters = this.pageCacheBusters();
199
+ return this.pages().map((p) => {
200
+ const baseUrl = p.publicationTemplateThumbnail || p.publicationTemplateUrl;
201
+ if (!baseUrl)
202
+ return '';
203
+ const guid = p.documentPageGuid;
204
+ const buster = busters[guid] || this.sessionBuster;
205
+ const separator = baseUrl.includes('?') ? '&' : '?';
206
+ return `${baseUrl}${separator}${buster}`;
207
+ });
208
+ }, ...(ngDevMode ? [{ debugName: "pageImageUrls" }] : []));
209
+ this.dragSourceIndex = null;
210
+ this.dragOverIndex = signal(null, ...(ngDevMode ? [{ debugName: "dragOverIndex" }] : []));
211
+ this.dropSide = signal(null, ...(ngDevMode ? [{ debugName: "dropSide" }] : []));
212
+ this.dragOverSectionGuid = signal(null, ...(ngDevMode ? [{ debugName: "dragOverSectionGuid" }] : []));
213
+ this.contextMenuVisible = false;
214
+ this.contextMenuPosition = { x: 0, y: 0 };
215
+ this.contextMenuPageIndex = null;
216
+ this.currentPageSectionGuid = computed(() => {
217
+ const pageIdx = this.contextMenuPageIndex;
218
+ if (pageIdx === null)
219
+ return null;
220
+ const page = this.pages()[pageIdx];
221
+ if (!page)
222
+ return null;
223
+ return page.documentSectionGuid || page.sectionGuid || null;
224
+ }, ...(ngDevMode ? [{ debugName: "currentPageSectionGuid" }] : []));
225
+ // Delete confirmation state
226
+ this.showDeleteConfirm = signal(false, ...(ngDevMode ? [{ debugName: "showDeleteConfirm" }] : []));
227
+ this.isBatchDelete = signal(false, ...(ngDevMode ? [{ debugName: "isBatchDelete" }] : []));
228
+ this.deleteIndex = null;
229
+ this.deleteModalTitle = computed(() => {
230
+ return this.isBatchDelete()
231
+ ? this.translate.instant('GLOBAL.PAGES.DELETE_MULTIPLE_CONFIRM_TITLE')
232
+ : this.translate.instant('GLOBAL.PAGES.DELETE_CONFIRM_TITLE');
233
+ }, ...(ngDevMode ? [{ debugName: "deleteModalTitle" }] : []));
234
+ this.deleteModalMessage = computed(() => {
235
+ return this.isBatchDelete()
236
+ ? this.translate.instant('GLOBAL.PAGES.DELETE_MULTIPLE_CONFIRM_MSG', {
237
+ count: this.selectedCount(),
238
+ })
239
+ : this.translate.instant('GLOBAL.PAGES.DELETE_CONFIRM_MSG');
240
+ }, ...(ngDevMode ? [{ debugName: "deleteModalMessage" }] : []));
241
+ effect(() => {
242
+ const params = this.appParams.params();
243
+ const docData = params.documentData;
244
+ if (docData && Array.isArray(docData)) {
245
+ this.pages.set([...docData]);
246
+ }
247
+ });
248
+ effect(() => {
249
+ const pulse = this.saveService.saveSuccessPulse();
250
+ const pulseCount = typeof pulse === 'object' ? pulse.count : pulse;
251
+ const currentPage = this.pages()[this.currentPageIndex()];
252
+ if (currentPage && pulseCount > 0) {
253
+ const activeGuid = currentPage.documentPageGuid;
254
+ this.pageCacheBusters.update((map) => ({
255
+ ...map,
256
+ [activeGuid]: `t=${pulseCount}`,
257
+ }));
258
+ }
259
+ });
260
+ }
261
+ ngOnInit() { }
262
+ togglePageSelection(index) {
263
+ this.selectedPageIndices.update((set) => {
264
+ const next = new Set(set);
265
+ if (next.has(index)) {
266
+ next.delete(index);
267
+ }
268
+ else {
269
+ next.add(index);
270
+ }
271
+ return next;
272
+ });
273
+ }
274
+ selectAll() {
275
+ const displayed = this.displayedPages();
276
+ this.selectedPageIndices.update((set) => {
277
+ const next = new Set(set);
278
+ for (const item of displayed) {
279
+ next.add(item.globalIndex);
280
+ }
281
+ return next;
282
+ });
283
+ }
284
+ deselectAll() {
285
+ this.selectedPageIndices.set(new Set());
286
+ }
287
+ deleteSelectedPages() {
288
+ if (!this.canDeleteSelected())
289
+ return;
290
+ this.isBatchDelete.set(true);
291
+ this.showDeleteConfirm.set(true);
292
+ }
293
+ addPage() {
294
+ const guid = this.appParams.guid;
295
+ if (!guid)
296
+ return;
297
+ this.isLoading.set(true);
298
+ const filter = this.activeSectionFilter();
299
+ let targetSection = filter || undefined;
300
+ if (!targetSection) {
301
+ const pages = this.pages();
302
+ const lastPage = pages.length > 0 ? pages[pages.length - 1] : null;
303
+ targetSection = lastPage
304
+ ? (lastPage.documentSectionGuid || lastPage.sectionGuid)
305
+ : undefined;
306
+ }
307
+ const sizeParams = this.getPageSizeParams();
308
+ this.assetsService
309
+ .addDocumentPage(guid, undefined, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
310
+ .subscribe((newPage) => {
311
+ if (newPage) {
312
+ this.refreshPages();
313
+ }
314
+ else {
315
+ this.isLoading.set(false);
316
+ }
317
+ });
318
+ }
319
+ addPageToSection(sectionGuid, sectionPages) {
320
+ const guid = this.appParams.guid;
321
+ if (!guid)
322
+ return;
323
+ this.isLoading.set(true);
324
+ const lastPage = sectionPages && sectionPages.length > 0
325
+ ? sectionPages[sectionPages.length - 1]
326
+ : null;
327
+ const targetPosition = lastPage ? lastPage.globalIndex + 2 : undefined;
328
+ const sizeParams = this.getPageSizeParams();
329
+ this.assetsService
330
+ .addDocumentPage(guid, targetPosition, sectionGuid, sizeParams.width, sizeParams.height, sizeParams.viewBox)
331
+ .subscribe((newPage) => {
332
+ if (newPage) {
333
+ this.refreshPages();
334
+ }
335
+ else {
336
+ this.isLoading.set(false);
337
+ }
338
+ });
339
+ }
340
+ addPageBefore(index) {
341
+ const guid = this.appParams.guid;
342
+ if (!guid)
343
+ return;
344
+ const page = this.pages()[index];
345
+ const targetSection = page
346
+ ? (page.documentSectionGuid || page.sectionGuid)
347
+ : undefined;
348
+ const sizeParams = this.getPageSizeParams();
349
+ this.isLoading.set(true);
350
+ this.assetsService
351
+ .addDocumentPage(guid, index + 1, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
352
+ .subscribe((newPage) => {
353
+ if (newPage) {
354
+ this.refreshPages();
355
+ }
356
+ else {
357
+ this.isLoading.set(false);
358
+ }
359
+ });
360
+ }
361
+ addPageAfter(index) {
362
+ const guid = this.appParams.guid;
363
+ if (!guid)
364
+ return;
365
+ const page = this.pages()[index];
366
+ const targetSection = page
367
+ ? (page.documentSectionGuid || page.sectionGuid)
368
+ : undefined;
369
+ const sizeParams = this.getPageSizeParams();
370
+ this.isLoading.set(true);
371
+ this.assetsService
372
+ .addDocumentPage(guid, index + 2, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
373
+ .subscribe((newPage) => {
374
+ if (newPage) {
375
+ this.refreshPages();
376
+ }
377
+ else {
378
+ this.isLoading.set(false);
379
+ }
380
+ });
381
+ }
382
+ getPageSizeParams() {
383
+ const props = this.documentService?.properties?.();
384
+ if (props && props.width && props.height) {
385
+ return {
386
+ width: props.width,
387
+ height: props.height,
388
+ viewBox: props.viewBox || `0 0 ${props.width} ${props.height}`,
389
+ };
390
+ }
391
+ return {};
392
+ }
393
+ duplicatePage(index) {
394
+ const guid = this.appParams.guid;
395
+ const page = this.pages()[index];
396
+ if (!guid || !page)
397
+ return;
398
+ this.isLoading.set(true);
399
+ this.assetsService
400
+ .duplicateDocumentPage(guid, page.documentPageGuid)
401
+ .subscribe((newPage) => {
402
+ if (newPage) {
403
+ this.refreshPages();
404
+ }
405
+ else {
406
+ this.isLoading.set(false);
407
+ }
408
+ });
409
+ }
410
+ deletePage(index) {
411
+ this.isBatchDelete.set(false);
412
+ this.deleteIndex = index;
413
+ this.showDeleteConfirm.set(true);
414
+ }
415
+ confirmDelete() {
416
+ const guid = this.appParams.guid;
417
+ if (!guid) {
418
+ this.cancelDelete();
419
+ return;
420
+ }
421
+ if (this.isBatchDelete()) {
422
+ if (!this.canDeleteSelected()) {
423
+ this.cancelDelete();
424
+ return;
425
+ }
426
+ const pagesList = this.pages();
427
+ const guidsToDelete = Array.from(this.selectedPageIndices())
428
+ .map((i) => pagesList[i]?.documentPageGuid)
429
+ .filter((g) => !!g);
430
+ if (guidsToDelete.length === 0) {
431
+ this.cancelDelete();
432
+ return;
433
+ }
434
+ this.isLoading.set(true);
435
+ from(guidsToDelete)
436
+ .pipe(concatMap((pageGuid) => this.assetsService.deleteDocumentPage(guid, pageGuid)), toArray())
437
+ .subscribe({
438
+ next: () => {
439
+ this.selectedPageIndices.set(new Set());
440
+ this.refreshPages();
441
+ },
442
+ error: () => {
443
+ this.isLoading.set(false);
444
+ },
445
+ });
446
+ this.cancelDelete();
447
+ return;
448
+ }
449
+ if (this.deleteIndex === null)
450
+ return;
451
+ const index = this.deleteIndex;
452
+ const page = this.pages()[index];
453
+ if (!page) {
454
+ this.cancelDelete();
455
+ return;
456
+ }
457
+ this.isLoading.set(true);
458
+ this.assetsService
459
+ .deleteDocumentPage(guid, page.documentPageGuid)
460
+ .subscribe((result) => {
461
+ if (result) {
462
+ this.selectedPageIndices.update((set) => {
463
+ const next = new Set(set);
464
+ next.delete(index);
465
+ return next;
466
+ });
467
+ this.refreshPages();
468
+ }
469
+ else {
470
+ this.isLoading.set(false);
471
+ }
472
+ });
473
+ this.cancelDelete();
474
+ }
475
+ cancelDelete() {
476
+ this.showDeleteConfirm.set(false);
477
+ this.deleteIndex = null;
478
+ this.isBatchDelete.set(false);
479
+ }
480
+ refreshPages() {
481
+ const guid = this.appParams.guid;
482
+ if (!guid)
483
+ return;
484
+ this.assetsService.getSVGDocumentPages(guid).subscribe((response) => {
485
+ if (response && response.template) {
486
+ this.appParams.setParams({
487
+ documentData: [...response.template],
488
+ documentSections: response.sections || response.Sections || [],
489
+ });
490
+ }
491
+ this.selectedPageIndices.set(new Set());
492
+ this.isLoading.set(false);
493
+ });
494
+ }
495
+ close() {
496
+ this.modalService.close();
497
+ }
498
+ goToPage(index) {
499
+ if (this.onPageSelect) {
500
+ this.onPageSelect(index);
501
+ }
502
+ this.close();
503
+ }
504
+ movePageToSection(pageIndex, targetSectionGuid) {
505
+ const page = this.pages()[pageIndex];
506
+ if (!page)
507
+ return;
508
+ const currentSecGuid = page.documentSectionGuid || page.sectionGuid;
509
+ if (currentSecGuid === targetSectionGuid)
510
+ return;
511
+ const guid = this.appParams.guid;
512
+ if (!guid)
513
+ return;
514
+ const pages = this.pages();
515
+ const sections = this.sections();
516
+ const targetSecIdx = sections.findIndex((s) => s.guid === targetSectionGuid);
517
+ const pagesInTarget = pages.filter((p) => (p.documentSectionGuid === targetSectionGuid || p.sectionGuid === targetSectionGuid) &&
518
+ p.documentPageGuid !== page.documentPageGuid);
519
+ let insertionIndex = 0;
520
+ if (pagesInTarget.length > 0) {
521
+ const lastTargetPage = pagesInTarget[pagesInTarget.length - 1];
522
+ insertionIndex = pages.indexOf(lastTargetPage) + 1;
523
+ }
524
+ else {
525
+ if (targetSecIdx > 0) {
526
+ for (let i = targetSecIdx - 1; i >= 0; i--) {
527
+ const prevSec = sections[i];
528
+ const lastPageOfPrev = [...pages].reverse().find((p) => (p.documentSectionGuid === prevSec.guid || p.sectionGuid === prevSec.guid) &&
529
+ p.documentPageGuid !== page.documentPageGuid);
530
+ if (lastPageOfPrev) {
531
+ insertionIndex = pages.indexOf(lastPageOfPrev) + 1;
532
+ break;
533
+ }
534
+ }
535
+ }
536
+ }
537
+ if (pageIndex < insertionIndex) {
538
+ insertionIndex--;
539
+ }
540
+ const newPageIdForApi = Math.max(1, insertionIndex + 1);
541
+ this.isLoading.set(true);
542
+ this.assetsService
543
+ .moveDocumentPage(guid, page.documentPageGuid, newPageIdForApi, targetSectionGuid)
544
+ .subscribe({
545
+ next: (result) => {
546
+ if (result) {
547
+ this.refreshPages();
548
+ }
549
+ else {
550
+ this.assetsService
551
+ .moveDocumentPageToSection(page.documentPageGuid, targetSectionGuid)
552
+ .subscribe(() => this.refreshPages());
553
+ }
554
+ },
555
+ error: () => {
556
+ this.assetsService
557
+ .moveDocumentPageToSection(page.documentPageGuid, targetSectionGuid)
558
+ .subscribe(() => this.refreshPages());
559
+ },
560
+ });
561
+ }
562
+ // ---- Drag & Drop ----
563
+ onDragStart(event, index) {
564
+ this.dragSourceIndex = index;
565
+ if (event.dataTransfer) {
566
+ event.dataTransfer.effectAllowed = 'move';
567
+ }
568
+ }
569
+ onDragOver(event, index) {
570
+ event.preventDefault();
571
+ this.dragOverIndex.set(index);
572
+ const rect = event.currentTarget.getBoundingClientRect();
573
+ const midX = rect.left + rect.width / 2;
574
+ this.dropSide.set(event.clientX < midX ? 'before' : 'after');
575
+ if (event.dataTransfer) {
576
+ event.dataTransfer.dropEffect = 'move';
577
+ }
578
+ }
579
+ onDragLeave() {
580
+ this.dragOverIndex.set(null);
581
+ this.dropSide.set(null);
582
+ }
583
+ onDragEnd() {
584
+ this.dragSourceIndex = null;
585
+ this.dragOverIndex.set(null);
586
+ this.dropSide.set(null);
587
+ this.dragOverSectionGuid.set(null);
588
+ }
589
+ onDrop(event, targetIndex, targetSectionGuid) {
590
+ event.preventDefault();
591
+ event.stopPropagation();
592
+ const side = this.dropSide();
593
+ this.dragOverIndex.set(null);
594
+ this.dropSide.set(null);
595
+ this.dragOverSectionGuid.set(null);
596
+ if (this.dragSourceIndex === null)
597
+ return;
598
+ const source = this.dragSourceIndex;
599
+ let actualTargetIndex = targetIndex;
600
+ if (side === 'after') {
601
+ actualTargetIndex++;
602
+ }
603
+ const previousPages = this.pages();
604
+ const draggedPage = previousPages[source];
605
+ if (!draggedPage) {
606
+ this.dragSourceIndex = null;
607
+ return;
608
+ }
609
+ const sourceSectionGuid = draggedPage.documentSectionGuid || draggedPage.sectionGuid;
610
+ const targetPage = previousPages[targetIndex];
611
+ const resolvedTargetSectionGuid = targetSectionGuid ||
612
+ (targetPage
613
+ ? targetPage.documentSectionGuid || targetPage.sectionGuid
614
+ : undefined);
615
+ const isSectionChange = !!resolvedTargetSectionGuid &&
616
+ resolvedTargetSectionGuid !== sourceSectionGuid;
617
+ if (!isSectionChange &&
618
+ (actualTargetIndex === source || actualTargetIndex === source + 1)) {
619
+ this.dragSourceIndex = null;
620
+ return;
621
+ }
622
+ const guid = this.appParams.guid;
623
+ if (!guid)
624
+ return;
625
+ const draggedPageGuid = draggedPage.documentPageGuid;
626
+ let insertionIndex = actualTargetIndex;
627
+ if (source < actualTargetIndex) {
628
+ insertionIndex--;
629
+ }
630
+ const newPageIdForApi = insertionIndex + 1;
631
+ // Optimistic local update
632
+ this.pages.update((p) => {
633
+ const copy = [...p];
634
+ const [moved] = copy.splice(source, 1);
635
+ if (resolvedTargetSectionGuid) {
636
+ moved.documentSectionGuid = resolvedTargetSectionGuid;
637
+ moved.sectionGuid = resolvedTargetSectionGuid;
638
+ }
639
+ copy.splice(insertionIndex, 0, moved);
640
+ return copy;
641
+ });
642
+ this.isLoading.set(true);
643
+ this.assetsService
644
+ .moveDocumentPage(guid, draggedPageGuid, newPageIdForApi, resolvedTargetSectionGuid)
645
+ .subscribe({
646
+ next: (result) => {
647
+ if (result) {
648
+ this.refreshPages();
649
+ }
650
+ else {
651
+ this.pages.set(previousPages);
652
+ this.isLoading.set(false);
653
+ }
654
+ },
655
+ error: () => {
656
+ this.pages.set(previousPages);
657
+ this.isLoading.set(false);
658
+ },
659
+ });
660
+ this.dragSourceIndex = null;
661
+ }
662
+ onEmptySectionDragOver(event, sectionGuid) {
663
+ event.preventDefault();
664
+ if (event.dataTransfer) {
665
+ event.dataTransfer.dropEffect = 'move';
666
+ }
667
+ this.dragOverSectionGuid.set(sectionGuid);
668
+ }
669
+ onEmptySectionDrop(event, targetSectionGuid) {
670
+ event.preventDefault();
671
+ event.stopPropagation();
672
+ this.dragOverIndex.set(null);
673
+ this.dropSide.set(null);
674
+ this.dragOverSectionGuid.set(null);
675
+ if (this.dragSourceIndex === null)
676
+ return;
677
+ const source = this.dragSourceIndex;
678
+ this.movePageToSection(source, targetSectionGuid);
679
+ this.dragSourceIndex = null;
680
+ }
681
+ // ---- Context Menu ----
682
+ onPageContextMenu(event, index) {
683
+ event.preventDefault();
684
+ event.stopPropagation();
685
+ this.contextMenuPosition = { x: event.clientX, y: event.clientY };
686
+ this.contextMenuPageIndex = index;
687
+ this.contextMenuVisible = true;
688
+ }
689
+ onContextMenuAction(event) {
690
+ switch (event.action) {
691
+ case 'open':
692
+ this.goToPage(event.index);
693
+ break;
694
+ case 'insert-before':
695
+ this.addPageBefore(event.index);
696
+ break;
697
+ case 'insert-after':
698
+ this.addPageAfter(event.index);
699
+ break;
700
+ case 'duplicate':
701
+ this.duplicatePage(event.index);
702
+ break;
703
+ case 'delete':
704
+ this.deletePage(event.index);
705
+ break;
706
+ case 'move-to-section':
707
+ if (event.sectionGuid) {
708
+ this.movePageToSection(event.index, event.sectionGuid);
709
+ }
710
+ break;
711
+ }
712
+ this.contextMenuVisible = false;
713
+ }
714
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
715
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.12", type: PageGridModalComponent, isStandalone: true, selector: "app-page-grid-modal", inputs: { onPageSelect: "onPageSelect" }, ngImport: i0, template: `
716
+ <sp-floating-window
717
+ [title]="'GLOBAL.PAGES.GRID_VIEW' | translate"
718
+ [icon]="spIconGrid"
719
+ [isOpen]="true"
720
+ [initialWidth]="840"
721
+ [initialHeight]="580"
722
+ [minWidth]="420"
723
+ [minHeight]="300"
724
+ [centerOnOpen]="true"
725
+ [maximizable]="true"
726
+ [zIndex]="2000"
727
+ (closed)="close()"
728
+ >
729
+ <!-- Section Switcher & Quick Drop Bar (if multiple sections exist) -->
730
+ <div
731
+ *ngIf="hasMultipleSections()"
732
+ class="page-grid-section-nav px-4 py-2 bg-base-200/50 border-b border-base-300 flex items-center gap-2 overflow-x-auto select-none shrink-0"
733
+ >
734
+ <span class="text-xs font-semibold text-base-content/60 flex items-center gap-1 shrink-0 mr-1">
735
+ <sp-icon [icon]="spIconFolder" [size]="13"></sp-icon>
736
+ <span>{{ 'GLOBAL.SECTIONS.TITLE' | translate }}:</span>
737
+ </span>
738
+
739
+ <!-- Chip "Tout" en premier -->
740
+ <button
741
+ type="button"
742
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
743
+ [class.bg-primary]="activeSectionFilter() === null"
744
+ [class.text-primary-content]="activeSectionFilter() === null"
745
+ [class.border-primary]="activeSectionFilter() === null"
746
+ [class.shadow-xs]="activeSectionFilter() === null"
747
+ [class.bg-base-100]="activeSectionFilter() !== null"
748
+ [class.border-base-300]="activeSectionFilter() !== null"
749
+ [class.text-base-content]="activeSectionFilter() !== null"
750
+ (click)="filterBySection(null)"
751
+ >
752
+ <span>{{ 'GLOBAL.SECTIONS.ALL' | translate }}</span>
753
+ <span
754
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
755
+ [class.bg-primary-content/20]="activeSectionFilter() === null"
756
+ [class.bg-base-200]="activeSectionFilter() !== null"
757
+ >
758
+ {{ pages().length }}
759
+ </span>
760
+ </button>
761
+
762
+ <!-- Les autres sections ensuite -->
763
+ <button
764
+ *ngFor="let sec of sections(); let sIdx = index"
765
+ type="button"
766
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
767
+ [class.bg-primary]="activeSectionFilter() === sec.guid"
768
+ [class.text-primary-content]="activeSectionFilter() === sec.guid"
769
+ [class.border-primary]="activeSectionFilter() === sec.guid"
770
+ [class.shadow-xs]="activeSectionFilter() === sec.guid"
771
+ [class.bg-base-100]="activeSectionFilter() !== sec.guid"
772
+ [class.text-base-content]="activeSectionFilter() !== sec.guid"
773
+ [style.border-color]="activeSectionFilter() !== sec.guid ? getSectionColor(sIdx) : null"
774
+ [class.!border-primary]="dragOverSectionGuid() === sec.guid"
775
+ [class.!bg-primary/20]="dragOverSectionGuid() === sec.guid"
776
+ (click)="filterBySection(sec.guid)"
777
+ (dragover)="onEmptySectionDragOver($event, sec.guid)"
778
+ (dragleave)="dragOverSectionGuid.set(null)"
779
+ (drop)="onEmptySectionDrop($event, sec.guid)"
780
+ [title]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
781
+ >
782
+ <span
783
+ class="w-2 h-2 rounded-full shrink-0"
784
+ [style.background-color]="getSectionColor(sIdx)"
785
+ ></span>
786
+ <span class="truncate max-w-[130px]">{{ sec.name }}</span>
787
+ <span
788
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
789
+ [class.bg-primary-content/20]="activeSectionFilter() === sec.guid"
790
+ [class.bg-base-200]="activeSectionFilter() !== sec.guid"
791
+ >
792
+ {{ getSectionPageCount(sec.guid) }}
793
+ </span>
794
+ </button>
795
+ </div>
796
+
797
+ <!-- Scrollable content area inside floating window body -->
798
+ <div class="page-grid-scroll-container">
799
+ <div class="page-grid-content">
800
+ <!-- Emplacement Page 0 non affichée pour décaler la couverture (page 1) à droite -->
801
+ <div *ngIf="needsLeadingSpacer()" class="page-grid-item page-placeholder"></div>
802
+
803
+ <div
804
+ *ngFor="let item of displayedPages(); trackBy: trackByGlobalIndex"
805
+ [id]="'page-card-' + item.globalIndex"
806
+ class="page-grid-item"
807
+ [class.page-cover]="item.globalIndex === 0"
808
+ [class.page-left]="item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 0"
809
+ [class.page-right]="item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 1"
810
+ [ngClass]="getSectionColorClass(item.page)"
811
+ [class.active]="item.globalIndex === currentPageIndex()"
812
+ [class.selected]="selectedPageIndices().has(item.globalIndex)"
813
+ [class.drag-before]="dragOverIndex() === item.globalIndex && dropSide() === 'before'"
814
+ [class.drag-after]="dragOverIndex() === item.globalIndex && dropSide() === 'after'"
815
+ draggable="true"
816
+ (dragstart)="onDragStart($event, item.globalIndex)"
817
+ (dragover)="onDragOver($event, item.globalIndex)"
818
+ (dragleave)="onDragLeave()"
819
+ (drop)="onDrop($event, item.globalIndex, item.page.documentSectionGuid || item.page.sectionGuid)"
820
+ (dragend)="onDragEnd()"
821
+ (click)="goToPage(item.globalIndex)"
822
+ (contextmenu)="onPageContextMenu($event, item.globalIndex)"
823
+ >
824
+ <!-- Selection Checkbox -->
825
+ <div
826
+ class="page-select-checkbox-container"
827
+ (click)="$event.stopPropagation()"
828
+ >
829
+ <sp-checkbox
830
+ [checked]="selectedPageIndices().has(item.globalIndex)"
831
+ size="sm"
832
+ (checkedChange)="togglePageSelection(item.globalIndex)"
833
+ ></sp-checkbox>
834
+ </div>
835
+
836
+ <!-- Page Thumbnail -->
837
+ <div class="page-thumb-wrapper" [style.aspect-ratio]="pageAspectRatio()">
838
+ <img
839
+ [src]="pageImageUrls()[item.globalIndex]"
840
+ class="page-image"
841
+ [alt]="'GLOBAL.PAGES.PAGE_NAME' | translate: { number: item.globalIndex + 1 }"
842
+ loading="lazy"
843
+ />
844
+ </div>
845
+
846
+ <!-- Page Number -->
847
+ <div class="page-number">{{ item.globalIndex + 1 }}</div>
848
+ </div>
849
+
850
+ <!-- Empty state when section has 0 pages -->
851
+ <div
852
+ *ngIf="displayedPages().length === 0"
853
+ class="w-full py-12 flex flex-col items-center justify-center text-base-content/40 border-2 border-dashed border-base-300 rounded-xl my-4 gap-2"
854
+ >
855
+ <sp-icon [icon]="spIconFolder" [size]="32" class="opacity-40"></sp-icon>
856
+ <span class="text-xs font-medium">{{ 'GLOBAL.SECTIONS.NO_PAGES' | translate }}</span>
857
+ </div>
858
+
859
+ <!-- Add Page Card -->
860
+ <div class="page-grid-item page-grid-item-add" (click)="addPage()">
861
+ <div class="page-thumb-wrapper page-add-wrapper" [style.aspect-ratio]="pageAspectRatio()">
862
+ <sp-icon [icon]="spIconPlus" [size]="28" class="text-base-content/40"></sp-icon>
863
+ </div>
864
+ <div class="page-number">{{ 'GLOBAL.PAGES.ADD_PAGE' | translate }}</div>
865
+ </div>
866
+ </div>
867
+ </div>
868
+
869
+ <!-- Selection action bar docked at the bottom of the window -->
870
+ <div *ngIf="selectedCount() > 0" class="page-grid-selection-bar">
871
+ <div class="selection-bar-left flex items-center gap-2">
872
+ <sp-badge variant="primary" size="xs">
873
+ {{
874
+ 'GLOBAL.PAGES.SELECTED_COUNT'
875
+ | translate: { count: selectedCount() }
876
+ }}
877
+ </sp-badge>
878
+ <sp-button
879
+ *ngIf="canSelectAll()"
880
+ variant="ghost"
881
+ size="xs"
882
+ [tooltip]="'GLOBAL.PAGES.SELECT_ALL' | translate"
883
+ (clicked)="selectAll()"
884
+ >
885
+ {{ 'GLOBAL.PAGES.SELECT_ALL' | translate }}
886
+ </sp-button>
887
+ <sp-button
888
+ variant="secondary"
889
+ size="xs"
890
+ [tooltip]="'GLOBAL.PAGES.DESELECT_ALL' | translate"
891
+ (clicked)="deselectAll()"
892
+ >
893
+ {{ 'GLOBAL.PAGES.DESELECT_ALL' | translate }}
894
+ </sp-button>
895
+ </div>
896
+
897
+ <div class="selection-bar-right flex items-center gap-2">
898
+ <!-- Move to Section button -->
899
+ <sp-button
900
+ *ngIf="hasMultipleSections()"
901
+ variant="secondary"
902
+ size="xs"
903
+ [tooltip]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
904
+ (clicked)="openSectionPickerForSelected($event)"
905
+ >
906
+ <sp-icon prefix [icon]="spIconFolder" [size]="13"></sp-icon>
907
+ {{ 'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate }}
908
+ </sp-button>
909
+
910
+ <sp-button
911
+ *ngIf="canDeleteSelected()"
912
+ variant="danger"
913
+ size="xs"
914
+ [tooltip]="'GLOBAL.PAGES.DELETE_SELECTED' | translate"
915
+ (clicked)="deleteSelectedPages()"
916
+ >
917
+ <sp-icon prefix [icon]="spIconTrash" [size]="13"></sp-icon>
918
+ {{ 'GLOBAL.PAGES.DELETE_SELECTED' | translate }}
919
+ </sp-button>
920
+ </div>
921
+ </div>
922
+
923
+ <!-- Loading overlay inside floating window -->
924
+ <div *ngIf="isLoading()" class="page-grid-loader">
925
+ <span class="loading loading-spinner loading-lg text-primary"></span>
926
+ </div>
927
+ </sp-floating-window>
928
+
929
+ <app-page-context-menu
930
+ [visible]="contextMenuVisible"
931
+ [position]="contextMenuPosition"
932
+ [pageIndex]="contextMenuPageIndex"
933
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
934
+ [sections]="sections()"
935
+ [currentPageSectionGuid]="currentPageSectionGuid()"
936
+ (action)="onContextMenuAction($event)"
937
+ (closeMenu)="contextMenuVisible = false"
938
+ ></app-page-context-menu>
939
+
940
+ <!-- Standalone Section Picker Context Menu -->
941
+ <sp-context-menu
942
+ [items]="sectionPickerItems"
943
+ [visible]="sectionPickerVisible"
944
+ [position]="sectionPickerPosition"
945
+ (closeMenu)="sectionPickerVisible = false"
946
+ ></sp-context-menu>
947
+
948
+ <!-- Delete Confirmation Modal -->
949
+ <app-confirm-delete-modal
950
+ *ngIf="showDeleteConfirm()"
951
+ [title]="deleteModalTitle()"
952
+ [message]="deleteModalMessage()"
953
+ (confirm)="confirmDelete()"
954
+ (cancel)="cancelDelete()"
955
+ ></app-confirm-delete-modal>
956
+ `, isInline: true, styles: [":host{display:contents}.page-grid-section-nav{scrollbar-width:thin}.page-grid-section-nav::-webkit-scrollbar{height:4px}.section-nav-chip:hover{border-color:oklch(var(--p));transform:translateY(-1px)}.page-grid-scroll-container{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px 20px 32px}.page-grid-selection-bar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;background-color:oklch(var(--b2));border-top:1px solid oklch(var(--b3));flex-shrink:0;-webkit-user-select:none;user-select:none;box-sizing:border-box}.selection-bar-left,.selection-bar-right{display:flex;align-items:center;gap:8px}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;column-gap:16px;row-gap:20px}.page-grid-item{background-color:oklch(var(--b1));border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:8px;width:140px;border:2px solid oklch(var(--bc) / .22);align-items:center;cursor:pointer;box-sizing:border-box;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease;position:relative;-webkit-user-select:none;user-select:none}.page-grid-item.section-border-gray{border-color:oklch(var(--bc) / .22)}.page-grid-item.section-border-1{border-color:#3b82f6}.page-grid-item.section-border-2{border-color:#10b981}.page-grid-item.section-border-3{border-color:#8b5cf6}.page-grid-item.section-border-4{border-color:#f59e0b}.page-grid-item.section-border-5{border-color:#f43f5e}.page-grid-item.section-border-6{border-color:#06b6d4}.page-grid-item.section-border-7{border-color:#6366f1}.page-grid-item:hover{transform:translateY(-2px);box-shadow:0 4px 12px #00000026;z-index:5}.page-grid-item.active{box-shadow:0 0 0 2px oklch(var(--p));background-color:oklch(var(--p) / .05);z-index:6}.page-grid-item.active .page-number{color:oklch(var(--p));font-weight:700}.page-grid-item.selected{border-color:oklch(var(--p))!important;box-shadow:0 0 0 2px oklch(var(--p))}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:oklch(var(--p));z-index:100;opacity:0;transition:opacity .2s;border-radius:2px}.page-grid-item.drag-before:before{left:-4px;opacity:1}.page-grid-item.drag-after:after{right:-4px;opacity:1}.page-grid-item.page-placeholder{visibility:hidden!important;pointer-events:none!important;border:none!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:0!important;min-height:0!important}.page-grid-item.page-cover{border-radius:8px;border:1px solid oklch(var(--b3));padding:8px}.page-grid-item.page-cover .page-thumb-wrapper{border-radius:4px}.page-grid-item.page-left{border-top-right-radius:0!important;border-bottom-right-radius:0!important;border-right:none!important;padding-right:0!important}.page-grid-item.page-left .page-thumb-wrapper{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.page-grid-item.page-right{margin-left:-16px;border-top-left-radius:0!important;border-bottom-left-radius:0!important;border-left:none!important;padding-left:0!important}.page-grid-item.page-right .page-thumb-wrapper{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.page-grid-item.page-right:hover,.page-grid-item.page-right.active{border-left:1px solid oklch(var(--p))!important;margin-left:-17px}.page-thumb-wrapper{width:100%;display:flex;align-items:center;justify-content:center;background-color:oklch(var(--b2));border-radius:4px;overflow:hidden}.page-image{width:100%;height:100%;object-fit:contain}.page-number{font-size:11px;font-weight:600;color:oklch(var(--bc));text-align:center}.page-select-checkbox-container{position:absolute;top:6px;left:6px;z-index:10;opacity:0;transition:opacity .15s ease}.page-grid-item:hover .page-select-checkbox-container,.page-grid-item.selected .page-select-checkbox-container{opacity:1}.page-grid-item-add{border-style:dashed}.page-grid-item-add:hover{background-color:oklch(var(--b2) / .5);border-color:oklch(var(--p))}.page-grid-item-add .page-add-wrapper{border:1px dashed oklch(var(--b3));background:oklch(var(--b1))}.page-grid-loader{position:absolute;inset:0;background:#0006;-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:inherit}.page-grid-scroll-container::-webkit-scrollbar{width:6px;height:6px;background:transparent}.page-grid-scroll-container::-webkit-scrollbar-thumb{border-radius:10px;background:oklch(var(--bc) / .25)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "component", type: SpIconComponent, selector: "sp-icon", inputs: ["icon", "name", "size", "color", "fill", "strokeWidth", "class", "ariaLabel"] }, { kind: "component", type: SpButtonComponent, selector: "sp-button", inputs: ["variant", "size", "type", "disabled", "loading", "active", "tooltip", "customClass", "fullWidth", "showTextWhileLoading"], outputs: ["clicked"] }, { kind: "component", type: SpBadgeComponent, selector: "sp-badge", inputs: ["variant", "size", "dot", "roundedFull", "customClass"] }, { kind: "component", type: SpCheckboxComponent, selector: "sp-checkbox", inputs: ["checked", "disabled", "label", "size"], outputs: ["checkedChange", "changed"] }, { kind: "component", type: SpFloatingWindowComponent, selector: "sp-floating-window", inputs: ["title", "icon", "maximizable", "startMaximized", "initialX", "initialY", "initialWidth", "initialHeight", "minWidth", "minHeight", "zIndex", "centerOnOpen", "isOpen"], outputs: ["closed", "positionChange", "sizeChange", "maximizedChange"] }, { kind: "component", type: SpContextMenuComponent, selector: "sp-context-menu", inputs: ["items", "visible", "position", "customClass", "minWidth"], outputs: ["closeMenu", "itemSelected"] }, { kind: "component", type: PageContextMenuComponent, selector: "app-page-context-menu", inputs: ["visible", "position", "pageIndex", "isCurrentPage", "sections", "currentPageSectionGuid"], outputs: ["action", "closeMenu"] }, { kind: "component", type: ConfirmDeleteModalComponent, selector: "app-confirm-delete-modal", inputs: ["title", "message"], outputs: ["confirm", "cancel"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }] }); }
957
+ }
958
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, decorators: [{
959
+ type: Component,
960
+ args: [{ selector: 'app-page-grid-modal', standalone: true, imports: [
961
+ CommonModule,
962
+ TranslateModule,
963
+ SpIconComponent,
964
+ SpButtonComponent,
965
+ SpIconButtonComponent,
966
+ SpBadgeComponent,
967
+ SpCheckboxComponent,
968
+ SpFloatingWindowComponent,
969
+ SpContextMenuComponent,
970
+ PageContextMenuComponent,
971
+ ConfirmDeleteModalComponent,
972
+ ], template: `
973
+ <sp-floating-window
974
+ [title]="'GLOBAL.PAGES.GRID_VIEW' | translate"
975
+ [icon]="spIconGrid"
976
+ [isOpen]="true"
977
+ [initialWidth]="840"
978
+ [initialHeight]="580"
979
+ [minWidth]="420"
980
+ [minHeight]="300"
981
+ [centerOnOpen]="true"
982
+ [maximizable]="true"
983
+ [zIndex]="2000"
984
+ (closed)="close()"
985
+ >
986
+ <!-- Section Switcher & Quick Drop Bar (if multiple sections exist) -->
987
+ <div
988
+ *ngIf="hasMultipleSections()"
989
+ class="page-grid-section-nav px-4 py-2 bg-base-200/50 border-b border-base-300 flex items-center gap-2 overflow-x-auto select-none shrink-0"
990
+ >
991
+ <span class="text-xs font-semibold text-base-content/60 flex items-center gap-1 shrink-0 mr-1">
992
+ <sp-icon [icon]="spIconFolder" [size]="13"></sp-icon>
993
+ <span>{{ 'GLOBAL.SECTIONS.TITLE' | translate }}:</span>
994
+ </span>
995
+
996
+ <!-- Chip "Tout" en premier -->
997
+ <button
998
+ type="button"
999
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
1000
+ [class.bg-primary]="activeSectionFilter() === null"
1001
+ [class.text-primary-content]="activeSectionFilter() === null"
1002
+ [class.border-primary]="activeSectionFilter() === null"
1003
+ [class.shadow-xs]="activeSectionFilter() === null"
1004
+ [class.bg-base-100]="activeSectionFilter() !== null"
1005
+ [class.border-base-300]="activeSectionFilter() !== null"
1006
+ [class.text-base-content]="activeSectionFilter() !== null"
1007
+ (click)="filterBySection(null)"
1008
+ >
1009
+ <span>{{ 'GLOBAL.SECTIONS.ALL' | translate }}</span>
1010
+ <span
1011
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
1012
+ [class.bg-primary-content/20]="activeSectionFilter() === null"
1013
+ [class.bg-base-200]="activeSectionFilter() !== null"
1014
+ >
1015
+ {{ pages().length }}
1016
+ </span>
1017
+ </button>
1018
+
1019
+ <!-- Les autres sections ensuite -->
1020
+ <button
1021
+ *ngFor="let sec of sections(); let sIdx = index"
1022
+ type="button"
1023
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
1024
+ [class.bg-primary]="activeSectionFilter() === sec.guid"
1025
+ [class.text-primary-content]="activeSectionFilter() === sec.guid"
1026
+ [class.border-primary]="activeSectionFilter() === sec.guid"
1027
+ [class.shadow-xs]="activeSectionFilter() === sec.guid"
1028
+ [class.bg-base-100]="activeSectionFilter() !== sec.guid"
1029
+ [class.text-base-content]="activeSectionFilter() !== sec.guid"
1030
+ [style.border-color]="activeSectionFilter() !== sec.guid ? getSectionColor(sIdx) : null"
1031
+ [class.!border-primary]="dragOverSectionGuid() === sec.guid"
1032
+ [class.!bg-primary/20]="dragOverSectionGuid() === sec.guid"
1033
+ (click)="filterBySection(sec.guid)"
1034
+ (dragover)="onEmptySectionDragOver($event, sec.guid)"
1035
+ (dragleave)="dragOverSectionGuid.set(null)"
1036
+ (drop)="onEmptySectionDrop($event, sec.guid)"
1037
+ [title]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
1038
+ >
1039
+ <span
1040
+ class="w-2 h-2 rounded-full shrink-0"
1041
+ [style.background-color]="getSectionColor(sIdx)"
1042
+ ></span>
1043
+ <span class="truncate max-w-[130px]">{{ sec.name }}</span>
1044
+ <span
1045
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
1046
+ [class.bg-primary-content/20]="activeSectionFilter() === sec.guid"
1047
+ [class.bg-base-200]="activeSectionFilter() !== sec.guid"
1048
+ >
1049
+ {{ getSectionPageCount(sec.guid) }}
1050
+ </span>
1051
+ </button>
1052
+ </div>
1053
+
1054
+ <!-- Scrollable content area inside floating window body -->
1055
+ <div class="page-grid-scroll-container">
1056
+ <div class="page-grid-content">
1057
+ <!-- Emplacement Page 0 non affichée pour décaler la couverture (page 1) à droite -->
1058
+ <div *ngIf="needsLeadingSpacer()" class="page-grid-item page-placeholder"></div>
1059
+
1060
+ <div
1061
+ *ngFor="let item of displayedPages(); trackBy: trackByGlobalIndex"
1062
+ [id]="'page-card-' + item.globalIndex"
1063
+ class="page-grid-item"
1064
+ [class.page-cover]="item.globalIndex === 0"
1065
+ [class.page-left]="item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 0"
1066
+ [class.page-right]="item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 1"
1067
+ [ngClass]="getSectionColorClass(item.page)"
1068
+ [class.active]="item.globalIndex === currentPageIndex()"
1069
+ [class.selected]="selectedPageIndices().has(item.globalIndex)"
1070
+ [class.drag-before]="dragOverIndex() === item.globalIndex && dropSide() === 'before'"
1071
+ [class.drag-after]="dragOverIndex() === item.globalIndex && dropSide() === 'after'"
1072
+ draggable="true"
1073
+ (dragstart)="onDragStart($event, item.globalIndex)"
1074
+ (dragover)="onDragOver($event, item.globalIndex)"
1075
+ (dragleave)="onDragLeave()"
1076
+ (drop)="onDrop($event, item.globalIndex, item.page.documentSectionGuid || item.page.sectionGuid)"
1077
+ (dragend)="onDragEnd()"
1078
+ (click)="goToPage(item.globalIndex)"
1079
+ (contextmenu)="onPageContextMenu($event, item.globalIndex)"
1080
+ >
1081
+ <!-- Selection Checkbox -->
1082
+ <div
1083
+ class="page-select-checkbox-container"
1084
+ (click)="$event.stopPropagation()"
1085
+ >
1086
+ <sp-checkbox
1087
+ [checked]="selectedPageIndices().has(item.globalIndex)"
1088
+ size="sm"
1089
+ (checkedChange)="togglePageSelection(item.globalIndex)"
1090
+ ></sp-checkbox>
1091
+ </div>
1092
+
1093
+ <!-- Page Thumbnail -->
1094
+ <div class="page-thumb-wrapper" [style.aspect-ratio]="pageAspectRatio()">
1095
+ <img
1096
+ [src]="pageImageUrls()[item.globalIndex]"
1097
+ class="page-image"
1098
+ [alt]="'GLOBAL.PAGES.PAGE_NAME' | translate: { number: item.globalIndex + 1 }"
1099
+ loading="lazy"
1100
+ />
1101
+ </div>
1102
+
1103
+ <!-- Page Number -->
1104
+ <div class="page-number">{{ item.globalIndex + 1 }}</div>
1105
+ </div>
1106
+
1107
+ <!-- Empty state when section has 0 pages -->
1108
+ <div
1109
+ *ngIf="displayedPages().length === 0"
1110
+ class="w-full py-12 flex flex-col items-center justify-center text-base-content/40 border-2 border-dashed border-base-300 rounded-xl my-4 gap-2"
1111
+ >
1112
+ <sp-icon [icon]="spIconFolder" [size]="32" class="opacity-40"></sp-icon>
1113
+ <span class="text-xs font-medium">{{ 'GLOBAL.SECTIONS.NO_PAGES' | translate }}</span>
1114
+ </div>
1115
+
1116
+ <!-- Add Page Card -->
1117
+ <div class="page-grid-item page-grid-item-add" (click)="addPage()">
1118
+ <div class="page-thumb-wrapper page-add-wrapper" [style.aspect-ratio]="pageAspectRatio()">
1119
+ <sp-icon [icon]="spIconPlus" [size]="28" class="text-base-content/40"></sp-icon>
1120
+ </div>
1121
+ <div class="page-number">{{ 'GLOBAL.PAGES.ADD_PAGE' | translate }}</div>
1122
+ </div>
1123
+ </div>
1124
+ </div>
1125
+
1126
+ <!-- Selection action bar docked at the bottom of the window -->
1127
+ <div *ngIf="selectedCount() > 0" class="page-grid-selection-bar">
1128
+ <div class="selection-bar-left flex items-center gap-2">
1129
+ <sp-badge variant="primary" size="xs">
1130
+ {{
1131
+ 'GLOBAL.PAGES.SELECTED_COUNT'
1132
+ | translate: { count: selectedCount() }
1133
+ }}
1134
+ </sp-badge>
1135
+ <sp-button
1136
+ *ngIf="canSelectAll()"
1137
+ variant="ghost"
1138
+ size="xs"
1139
+ [tooltip]="'GLOBAL.PAGES.SELECT_ALL' | translate"
1140
+ (clicked)="selectAll()"
1141
+ >
1142
+ {{ 'GLOBAL.PAGES.SELECT_ALL' | translate }}
1143
+ </sp-button>
1144
+ <sp-button
1145
+ variant="secondary"
1146
+ size="xs"
1147
+ [tooltip]="'GLOBAL.PAGES.DESELECT_ALL' | translate"
1148
+ (clicked)="deselectAll()"
1149
+ >
1150
+ {{ 'GLOBAL.PAGES.DESELECT_ALL' | translate }}
1151
+ </sp-button>
1152
+ </div>
1153
+
1154
+ <div class="selection-bar-right flex items-center gap-2">
1155
+ <!-- Move to Section button -->
1156
+ <sp-button
1157
+ *ngIf="hasMultipleSections()"
1158
+ variant="secondary"
1159
+ size="xs"
1160
+ [tooltip]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
1161
+ (clicked)="openSectionPickerForSelected($event)"
1162
+ >
1163
+ <sp-icon prefix [icon]="spIconFolder" [size]="13"></sp-icon>
1164
+ {{ 'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate }}
1165
+ </sp-button>
1166
+
1167
+ <sp-button
1168
+ *ngIf="canDeleteSelected()"
1169
+ variant="danger"
1170
+ size="xs"
1171
+ [tooltip]="'GLOBAL.PAGES.DELETE_SELECTED' | translate"
1172
+ (clicked)="deleteSelectedPages()"
1173
+ >
1174
+ <sp-icon prefix [icon]="spIconTrash" [size]="13"></sp-icon>
1175
+ {{ 'GLOBAL.PAGES.DELETE_SELECTED' | translate }}
1176
+ </sp-button>
1177
+ </div>
1178
+ </div>
1179
+
1180
+ <!-- Loading overlay inside floating window -->
1181
+ <div *ngIf="isLoading()" class="page-grid-loader">
1182
+ <span class="loading loading-spinner loading-lg text-primary"></span>
1183
+ </div>
1184
+ </sp-floating-window>
1185
+
1186
+ <app-page-context-menu
1187
+ [visible]="contextMenuVisible"
1188
+ [position]="contextMenuPosition"
1189
+ [pageIndex]="contextMenuPageIndex"
1190
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
1191
+ [sections]="sections()"
1192
+ [currentPageSectionGuid]="currentPageSectionGuid()"
1193
+ (action)="onContextMenuAction($event)"
1194
+ (closeMenu)="contextMenuVisible = false"
1195
+ ></app-page-context-menu>
1196
+
1197
+ <!-- Standalone Section Picker Context Menu -->
1198
+ <sp-context-menu
1199
+ [items]="sectionPickerItems"
1200
+ [visible]="sectionPickerVisible"
1201
+ [position]="sectionPickerPosition"
1202
+ (closeMenu)="sectionPickerVisible = false"
1203
+ ></sp-context-menu>
1204
+
1205
+ <!-- Delete Confirmation Modal -->
1206
+ <app-confirm-delete-modal
1207
+ *ngIf="showDeleteConfirm()"
1208
+ [title]="deleteModalTitle()"
1209
+ [message]="deleteModalMessage()"
1210
+ (confirm)="confirmDelete()"
1211
+ (cancel)="cancelDelete()"
1212
+ ></app-confirm-delete-modal>
1213
+ `, styles: [":host{display:contents}.page-grid-section-nav{scrollbar-width:thin}.page-grid-section-nav::-webkit-scrollbar{height:4px}.section-nav-chip:hover{border-color:oklch(var(--p));transform:translateY(-1px)}.page-grid-scroll-container{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px 20px 32px}.page-grid-selection-bar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;background-color:oklch(var(--b2));border-top:1px solid oklch(var(--b3));flex-shrink:0;-webkit-user-select:none;user-select:none;box-sizing:border-box}.selection-bar-left,.selection-bar-right{display:flex;align-items:center;gap:8px}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;column-gap:16px;row-gap:20px}.page-grid-item{background-color:oklch(var(--b1));border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:8px;width:140px;border:2px solid oklch(var(--bc) / .22);align-items:center;cursor:pointer;box-sizing:border-box;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease;position:relative;-webkit-user-select:none;user-select:none}.page-grid-item.section-border-gray{border-color:oklch(var(--bc) / .22)}.page-grid-item.section-border-1{border-color:#3b82f6}.page-grid-item.section-border-2{border-color:#10b981}.page-grid-item.section-border-3{border-color:#8b5cf6}.page-grid-item.section-border-4{border-color:#f59e0b}.page-grid-item.section-border-5{border-color:#f43f5e}.page-grid-item.section-border-6{border-color:#06b6d4}.page-grid-item.section-border-7{border-color:#6366f1}.page-grid-item:hover{transform:translateY(-2px);box-shadow:0 4px 12px #00000026;z-index:5}.page-grid-item.active{box-shadow:0 0 0 2px oklch(var(--p));background-color:oklch(var(--p) / .05);z-index:6}.page-grid-item.active .page-number{color:oklch(var(--p));font-weight:700}.page-grid-item.selected{border-color:oklch(var(--p))!important;box-shadow:0 0 0 2px oklch(var(--p))}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:oklch(var(--p));z-index:100;opacity:0;transition:opacity .2s;border-radius:2px}.page-grid-item.drag-before:before{left:-4px;opacity:1}.page-grid-item.drag-after:after{right:-4px;opacity:1}.page-grid-item.page-placeholder{visibility:hidden!important;pointer-events:none!important;border:none!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:0!important;min-height:0!important}.page-grid-item.page-cover{border-radius:8px;border:1px solid oklch(var(--b3));padding:8px}.page-grid-item.page-cover .page-thumb-wrapper{border-radius:4px}.page-grid-item.page-left{border-top-right-radius:0!important;border-bottom-right-radius:0!important;border-right:none!important;padding-right:0!important}.page-grid-item.page-left .page-thumb-wrapper{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.page-grid-item.page-right{margin-left:-16px;border-top-left-radius:0!important;border-bottom-left-radius:0!important;border-left:none!important;padding-left:0!important}.page-grid-item.page-right .page-thumb-wrapper{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.page-grid-item.page-right:hover,.page-grid-item.page-right.active{border-left:1px solid oklch(var(--p))!important;margin-left:-17px}.page-thumb-wrapper{width:100%;display:flex;align-items:center;justify-content:center;background-color:oklch(var(--b2));border-radius:4px;overflow:hidden}.page-image{width:100%;height:100%;object-fit:contain}.page-number{font-size:11px;font-weight:600;color:oklch(var(--bc));text-align:center}.page-select-checkbox-container{position:absolute;top:6px;left:6px;z-index:10;opacity:0;transition:opacity .15s ease}.page-grid-item:hover .page-select-checkbox-container,.page-grid-item.selected .page-select-checkbox-container{opacity:1}.page-grid-item-add{border-style:dashed}.page-grid-item-add:hover{background-color:oklch(var(--b2) / .5);border-color:oklch(var(--p))}.page-grid-item-add .page-add-wrapper{border:1px dashed oklch(var(--b3));background:oklch(var(--b1))}.page-grid-loader{position:absolute;inset:0;background:#0006;-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:inherit}.page-grid-scroll-container::-webkit-scrollbar{width:6px;height:6px;background:transparent}.page-grid-scroll-container::-webkit-scrollbar-thumb{border-radius:10px;background:oklch(var(--bc) / .25)}\n"] }]
1214
+ }], ctorParameters: () => [], propDecorators: { onPageSelect: [{
1215
+ type: Input
1216
+ }] } });
1217
+
1218
+ export { PageGridModalComponent };
1219
+ //# sourceMappingURL=solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CX9XUnS3.mjs.map