@isaiahiroko/tilmart-ngx-apps-admin 0.2.0

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 (75) hide show
  1. package/README.md +9 -0
  2. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-articles.module-OeLRnPwN.mjs +154 -0
  3. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-articles.module-OeLRnPwN.mjs.map +1 -0
  4. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-audit.module-C9gvw8X2.mjs +84 -0
  5. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-audit.module-C9gvw8X2.mjs.map +1 -0
  6. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-baskets.module-_lHPl1dT.mjs +294 -0
  7. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-baskets.module-_lHPl1dT.mjs.map +1 -0
  8. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-Bvx2tVOi.mjs +224 -0
  9. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-Bvx2tVOi.mjs.map +1 -0
  10. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-claims.module-Ccsd8Yx3.mjs +106 -0
  11. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-claims.module-Ccsd8Yx3.mjs.map +1 -0
  12. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-compatibility-rules.module-xN-JUWwp.mjs +261 -0
  13. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-compatibility-rules.module-xN-JUWwp.mjs.map +1 -0
  14. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-content.module-DLdKAUqc.mjs +365 -0
  15. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-content.module-DLdKAUqc.mjs.map +1 -0
  16. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-CQNCSlsd.mjs +106 -0
  17. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-CQNCSlsd.mjs.map +1 -0
  18. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-customers.module-12XdV9zo.mjs +106 -0
  19. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-customers.module-12XdV9zo.mjs.map +1 -0
  20. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-data-quality.module-Bfgh3zE5.mjs +286 -0
  21. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-data-quality.module-Bfgh3zE5.mjs.map +1 -0
  22. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-data-requests.module-C6tPNlup.mjs +104 -0
  23. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-data-requests.module-C6tPNlup.mjs.map +1 -0
  24. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-disputes.module-DmUoAS0Z.mjs +73 -0
  25. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-disputes.module-DmUoAS0Z.mjs.map +1 -0
  26. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-homepage.module-BZ3UmxE3.mjs +404 -0
  27. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-homepage.module-BZ3UmxE3.mjs.map +1 -0
  28. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-inbox.module-BZDTa1L-.mjs +290 -0
  29. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-inbox.module-BZDTa1L-.mjs.map +1 -0
  30. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-macros.module-BO4bdER2.mjs +112 -0
  31. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-macros.module-BO4bdER2.mjs.map +1 -0
  32. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-moderation.module-CZOCrias.mjs +116 -0
  33. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-moderation.module-CZOCrias.mjs.map +1 -0
  34. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-navigation.module-DoKzzRgn.mjs +281 -0
  35. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-navigation.module-DoKzzRgn.mjs.map +1 -0
  36. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-order-board.module-DIOjhptn.mjs +115 -0
  37. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-order-board.module-DIOjhptn.mjs.map +1 -0
  38. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-Ddw49QW0.mjs +185 -0
  39. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-Ddw49QW0.mjs.map +1 -0
  40. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payments.module-BhqAtTZs.mjs +106 -0
  41. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payments.module-BhqAtTZs.mjs.map +1 -0
  42. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payouts.module-CoiscPIZ.mjs +70 -0
  43. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payouts.module-CoiscPIZ.mjs.map +1 -0
  44. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-procurement.module-qXW-g0pf.mjs +274 -0
  45. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-procurement.module-qXW-g0pf.mjs.map +1 -0
  46. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-DG9uTDqX.mjs +106 -0
  47. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-DG9uTDqX.mjs.map +1 -0
  48. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-queues.module-K-zYYVFy.mjs +84 -0
  49. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-queues.module-K-zYYVFy.mjs.map +1 -0
  50. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-Hm2dO_bC.mjs +106 -0
  51. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-Hm2dO_bC.mjs.map +1 -0
  52. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-referrals.module-QLNhuh7q.mjs +106 -0
  53. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-referrals.module-QLNhuh7q.mjs.map +1 -0
  54. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-DBZov0We.mjs +104 -0
  55. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-DBZov0We.mjs.map +1 -0
  56. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-returns.module-Bd2gdo6_.mjs +106 -0
  57. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-returns.module-Bd2gdo6_.mjs.map +1 -0
  58. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-rich-editor.module-DW9Gy_QQ.mjs +81 -0
  59. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-rich-editor.module-DW9Gy_QQ.mjs.map +1 -0
  60. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-BkVY06ci.mjs +105 -0
  61. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-BkVY06ci.mjs.map +1 -0
  62. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-settings.module-DKeZTldO.mjs +222 -0
  63. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-settings.module-DKeZTldO.mjs.map +1 -0
  64. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-shipments.module-XuaOKr8v.mjs +150 -0
  65. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-shipments.module-XuaOKr8v.mjs.map +1 -0
  66. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-DYiAkF7E.mjs +107 -0
  67. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-DYiAkF7E.mjs.map +1 -0
  68. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-trace.module-Pwr-82Rc.mjs +92 -0
  69. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-trace.module-Pwr-82Rc.mjs.map +1 -0
  70. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-users.module-Bx_7fI2g.mjs +111 -0
  71. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-users.module-Bx_7fI2g.mjs.map +1 -0
  72. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin.mjs +475 -0
  73. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin.mjs.map +1 -0
  74. package/package.json +34 -0
  75. package/types/isaiahiroko-tilmart-ngx-apps-admin.d.ts +32 -0
@@ -0,0 +1,281 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, NgModule } from '@angular/core';
3
+ import * as i1$2 from '@angular/router';
4
+ import { RouterModule } from '@angular/router';
5
+ import { BaseDirective, using, notify, SharedModule } from '@thescaffold/ngx-core';
6
+ import * as i1$1 from '@thescaffold/ngx-ui';
7
+ import { ElementsModule } from '@thescaffold/ngx-ui';
8
+ import { takeUntil, firstValueFrom } from 'rxjs';
9
+ import * as i2 from '@angular/common';
10
+ import * as i1 from '@angular/forms';
11
+
12
+ const LOCATIONS = [
13
+ 'header_primary',
14
+ 'header_secondary',
15
+ 'footer',
16
+ 'mobile_drawer',
17
+ 'utility_bar',
18
+ ];
19
+ // P6.12, CMS-03 — the ops navigation editor. Menus (one per location) and
20
+ // their items: label, url, nesting (`parentId`), schedule and order. The
21
+ // storefront shell consumes `header_primary` (P6.12 shell wiring).
22
+ class NavigationComponent extends BaseDirective {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.menuSource = this.apiService.on('apps/commerce/navigation-menu');
26
+ this.itemSource = this.apiService.on('apps/commerce/navigation-item');
27
+ this.locations = LOCATIONS;
28
+ this.loading = true;
29
+ this.menus = [];
30
+ this.items = [];
31
+ this.newMenuLocation = LOCATIONS[0];
32
+ this.newMenuName = '';
33
+ this.itemModel = this.blankItem();
34
+ this.dragIndex = null;
35
+ this.init = () => {
36
+ this.load();
37
+ };
38
+ }
39
+ get topLevel() {
40
+ return this.items
41
+ .filter((i) => !i.parentId)
42
+ .sort((a, b) => a.position - b.position);
43
+ }
44
+ childrenOf(parentId) {
45
+ return this.items
46
+ .filter((i) => i.parentId === parentId)
47
+ .sort((a, b) => a.position - b.position);
48
+ }
49
+ get parentOptions() {
50
+ // Only top-level items can be parents (one level of nesting).
51
+ return this.items.filter((i) => !i.parentId && i.id !== this.editingItem?.id);
52
+ }
53
+ load() {
54
+ this.loading = true;
55
+ this.menuSource
56
+ .getMany({ perPage: 100 })
57
+ .pipe(takeUntil(this.$))
58
+ .subscribe(using((res) => {
59
+ this.menus = (res?.data ?? []).sort((a, b) => String(a.location).localeCompare(String(b.location)));
60
+ this.loading = false;
61
+ if (this.selected) {
62
+ this.selected = this.menus.find((m) => m.id === this.selected.id);
63
+ }
64
+ }));
65
+ }
66
+ async createMenu() {
67
+ const name = this.newMenuName.trim();
68
+ if (!name)
69
+ return;
70
+ try {
71
+ const res = await firstValueFrom(this.menuSource.create({
72
+ location: this.newMenuLocation,
73
+ name,
74
+ enabled: true,
75
+ }));
76
+ this.newMenuName = '';
77
+ notify('Menu created.', undefined, 'success');
78
+ this.load();
79
+ if (res?.data?.id)
80
+ setTimeout(() => this.select({ ...res.data }), 200);
81
+ }
82
+ catch {
83
+ notify('Could not create the menu.', undefined, 'error');
84
+ }
85
+ }
86
+ select(menu) {
87
+ this.selected = menu;
88
+ this.editingItem = undefined;
89
+ this.loadItems();
90
+ }
91
+ async deleteMenu() {
92
+ if (!this.selected)
93
+ return;
94
+ try {
95
+ await firstValueFrom(this.menuSource.remove(this.selected.id));
96
+ this.selected = undefined;
97
+ this.items = [];
98
+ notify('Menu deleted.', undefined, 'success');
99
+ this.load();
100
+ }
101
+ catch {
102
+ notify('Could not delete the menu.', undefined, 'error');
103
+ }
104
+ }
105
+ loadItems() {
106
+ if (!this.selected)
107
+ return;
108
+ this.itemSource
109
+ .getMany({ menuId: this.selected.id, perPage: 200 })
110
+ .pipe(takeUntil(this.$))
111
+ .subscribe(using((res) => {
112
+ this.items = (res?.data ?? []).filter((i) => i.menuId === this.selected.id);
113
+ }));
114
+ }
115
+ async addItem() {
116
+ if (!this.selected)
117
+ return;
118
+ try {
119
+ await firstValueFrom(this.itemSource.create({
120
+ menuId: this.selected.id,
121
+ label: 'New link',
122
+ url: '/',
123
+ position: this.topLevel.length,
124
+ enabled: true,
125
+ }));
126
+ this.loadItems();
127
+ }
128
+ catch {
129
+ notify('Could not add the item.', undefined, 'error');
130
+ }
131
+ }
132
+ editItem(item) {
133
+ this.editingItem = item;
134
+ this.itemModel = {
135
+ label: item.label,
136
+ url: typeof item.url === 'string' ? item.url : '',
137
+ parentId: item.parentId ?? '',
138
+ icon: item.icon ?? '',
139
+ openInNewTab: !!item.openInNewTab,
140
+ startsAt: this.toLocal(item.startsAt),
141
+ endsAt: this.toLocal(item.endsAt),
142
+ };
143
+ }
144
+ cancelItemEdit() {
145
+ this.editingItem = undefined;
146
+ this.itemModel = this.blankItem();
147
+ }
148
+ async saveItem() {
149
+ if (!this.editingItem)
150
+ return;
151
+ try {
152
+ await firstValueFrom(this.itemSource.update(this.editingItem.id, {
153
+ label: this.itemModel.label.trim() || 'Link',
154
+ url: this.itemModel.url.trim() || '/',
155
+ parentId: this.itemModel.parentId || null,
156
+ icon: this.itemModel.icon.trim() || undefined,
157
+ openInNewTab: this.itemModel.openInNewTab,
158
+ startsAt: this.itemModel.startsAt ? new Date(this.itemModel.startsAt).toISOString() : null,
159
+ endsAt: this.itemModel.endsAt ? new Date(this.itemModel.endsAt).toISOString() : null,
160
+ }));
161
+ notify('Item saved.', undefined, 'success');
162
+ this.cancelItemEdit();
163
+ this.loadItems();
164
+ }
165
+ catch {
166
+ notify('Could not save the item.', undefined, 'error');
167
+ }
168
+ }
169
+ async toggleItem(item) {
170
+ const next = !item.enabled;
171
+ try {
172
+ await firstValueFrom(this.itemSource.update(item.id, { enabled: next }));
173
+ item.enabled = next;
174
+ }
175
+ catch {
176
+ notify('Could not update the item.', undefined, 'error');
177
+ }
178
+ }
179
+ async removeItem(item) {
180
+ try {
181
+ // Detach any children first so they don't dangle.
182
+ await Promise.all(this.childrenOf(item.id).map((child) => firstValueFrom(this.itemSource.update(child.id, { parentId: null }))));
183
+ await firstValueFrom(this.itemSource.remove(item.id));
184
+ this.items = this.items.filter((i) => i.id !== item.id);
185
+ if (this.editingItem?.id === item.id)
186
+ this.cancelItemEdit();
187
+ notify('Item removed.', undefined, 'success');
188
+ }
189
+ catch {
190
+ notify('Could not remove the item.', undefined, 'error');
191
+ }
192
+ }
193
+ onDragStart(index) {
194
+ this.dragIndex = index;
195
+ }
196
+ onDragOver(event) {
197
+ event.preventDefault();
198
+ }
199
+ onDrop(targetIndex) {
200
+ if (this.dragIndex === null || this.dragIndex === targetIndex)
201
+ return;
202
+ const ordered = this.topLevel;
203
+ const [moved] = ordered.splice(this.dragIndex, 1);
204
+ ordered.splice(targetIndex, 0, moved);
205
+ this.dragIndex = null;
206
+ void this.persistOrder(ordered);
207
+ }
208
+ moveItem(index, dir) {
209
+ const ordered = this.topLevel;
210
+ const target = index + dir;
211
+ if (target < 0 || target >= ordered.length)
212
+ return;
213
+ [ordered[index], ordered[target]] = [ordered[target], ordered[index]];
214
+ void this.persistOrder(ordered);
215
+ }
216
+ async persistOrder(ordered) {
217
+ const changed = [];
218
+ ordered.forEach((item, i) => {
219
+ if (item.position !== i) {
220
+ item.position = i;
221
+ changed.push(item);
222
+ }
223
+ });
224
+ try {
225
+ await Promise.all(changed.map((item) => firstValueFrom(this.itemSource.update(item.id, { position: item.position }))));
226
+ }
227
+ catch {
228
+ notify('Could not save the new order.', undefined, 'error');
229
+ this.loadItems();
230
+ }
231
+ }
232
+ blankItem() {
233
+ return {
234
+ label: '',
235
+ url: '',
236
+ parentId: '',
237
+ icon: '',
238
+ openInNewTab: false,
239
+ startsAt: '',
240
+ endsAt: '',
241
+ };
242
+ }
243
+ toLocal(iso) {
244
+ if (!iso)
245
+ return '';
246
+ const d = new Date(iso);
247
+ if (Number.isNaN(d.getTime()))
248
+ return '';
249
+ const pad = (n) => String(n).padStart(2, '0');
250
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
251
+ }
252
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: NavigationComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
253
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: NavigationComponent, isStandalone: false, selector: "x-navigation", usesInheritance: true, ngImport: i0, template: "<div class=\"x-nav-head\">\n <div class=\"x-nav-title\">Navigation</div>\n <div class=\"x-nav-sub\">Storefront menus \u2014 the shell consumes the <code>header_primary</code> menu.</div>\n</div>\n\n@if (loading) {\n <x-element-loader></x-element-loader>\n} @else {\n <div class=\"x-nav-layout\">\n <aside class=\"x-nav-list\">\n <div class=\"x-nav-new\">\n <select [(ngModel)]=\"newMenuLocation\">\n @for (l of locations; track l) { <option [value]=\"l\">{{ l }}</option> }\n </select>\n <input type=\"text\" placeholder=\"Menu name\" [(ngModel)]=\"newMenuName\" />\n <button type=\"button\" (click)=\"createMenu()\">Add menu</button>\n </div>\n @for (m of menus; track m.id) {\n <button\n type=\"button\"\n class=\"x-nav-list-item\"\n [class.x-nav-list-active]=\"selected?.id === m.id\"\n (click)=\"select(m)\"\n >\n <span class=\"x-nav-list-title\">{{ m.name }}</span>\n <span class=\"x-nav-list-meta\">{{ m.location }}</span>\n </button>\n } @empty {\n <div class=\"x-nav-empty\">No menus yet.</div>\n }\n </aside>\n\n <section class=\"x-nav-editor\">\n @if (!selected) {\n <div class=\"x-nav-empty\">Pick a menu, or add one.</div>\n } @else {\n <div class=\"x-nav-editor-head\">\n <span>{{ selected.name }} \u2014 <code>{{ selected.location }}</code></span>\n <span>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"addItem()\">Add link</button>\n <button type=\"button\" class=\"x-nav-btn x-nav-danger\" (click)=\"deleteMenu()\">Delete menu</button>\n </span>\n </div>\n\n @if (!topLevel.length) {\n <div class=\"x-nav-empty\">No links yet.</div>\n } @else {\n <div class=\"x-nav-items\">\n @for (item of topLevel; track item.id; let i = $index) {\n <div\n class=\"x-nav-item\"\n [class.x-nav-item-off]=\"!item.enabled\"\n draggable=\"true\"\n (dragstart)=\"onDragStart(i)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop(i)\"\n >\n <div class=\"x-nav-item-row\">\n <span class=\"x-nav-grip\">\u283F</span>\n <div class=\"x-nav-order\">\n <button type=\"button\" (click)=\"moveItem(i, -1)\" [disabled]=\"i === 0\">\u25B2</button>\n <button type=\"button\" (click)=\"moveItem(i, 1)\" [disabled]=\"i === topLevel.length - 1\">\u25BC</button>\n </div>\n <span class=\"x-nav-item-label\">{{ item.label }}</span>\n <span class=\"x-nav-item-url\">{{ item.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(item)\">{{ item.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(item)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(item)\">Delete</button>\n </span>\n </div>\n\n @for (child of childrenOf(item.id); track child.id) {\n <div class=\"x-nav-child\" [class.x-nav-item-off]=\"!child.enabled\">\n <span class=\"x-nav-child-label\">\u21B3 {{ child.label }}</span>\n <span class=\"x-nav-item-url\">{{ child.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(child)\">{{ child.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(child)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(child)\">Delete</button>\n </span>\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (editingItem) {\n <ng-container *ngTemplateOutlet=\"itemForm\"></ng-container>\n }\n }\n </section>\n </div>\n}\n\n<ng-template #itemForm>\n <div class=\"x-nav-form\">\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Label<input type=\"text\" [(ngModel)]=\"itemModel.label\" /></label>\n <label class=\"x-nav-f\">URL<input type=\"text\" [(ngModel)]=\"itemModel.url\" placeholder=\"/c/solar-panels\" /></label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">\n Parent\n <select [(ngModel)]=\"itemModel.parentId\">\n <option value=\"\">\u2014 top level \u2014</option>\n @for (p of parentOptions; track p.id) { <option [value]=\"p.id\">{{ p.label }}</option> }\n </select>\n </label>\n <label class=\"x-nav-f\">Icon<input type=\"text\" [(ngModel)]=\"itemModel.icon\" /></label>\n <label class=\"x-nav-f x-nav-check\">\n <input type=\"checkbox\" [(ngModel)]=\"itemModel.openInNewTab\" /> New tab\n </label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Starts<input type=\"datetime-local\" [(ngModel)]=\"itemModel.startsAt\" /></label>\n <label class=\"x-nav-f\">Ends<input type=\"datetime-local\" [(ngModel)]=\"itemModel.endsAt\" /></label>\n </div>\n <div class=\"x-nav-form-actions\">\n <button type=\"button\" class=\"x-nav-btn x-nav-btn-primary\" (click)=\"saveItem()\">Save link</button>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"cancelItemEdit()\">Cancel</button>\n </div>\n </div>\n</ng-template>\n\n<style>\n .x-nav-head { margin-bottom: 20px; }\n .x-nav-title { font-size: 24px; font-weight: 800; color: var(--color-text); }\n .x-nav-sub { font-size: 13.5px; color: var(--color-text-muted); margin-top: 2px; }\n .x-nav-sub code, .x-nav-editor-head code { font-family: var(--font-mono); font-size: 12px; }\n .x-nav-empty { font-size: 14px; color: var(--color-text-muted); padding: 12px 0; }\n .x-nav-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }\n .x-nav-list { display: flex; flex-direction: column; gap: 6px; }\n .x-nav-new { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }\n .x-nav-new select, .x-nav-new input, .x-nav-f input, .x-nav-f select {\n border: 1px solid var(--color-border); border-radius: var(--radius-md);\n padding: 6px 10px; font-size: 13px; background: var(--color-surface); color: var(--color-text);\n }\n .x-nav-new button, .x-nav-btn {\n border: 1px solid var(--color-border); background: transparent; border-radius: var(--radius-md);\n padding: 6px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted);\n }\n .x-nav-btn-primary { border-color: var(--color-accent); color: var(--color-accent-hover); }\n .x-nav-danger { color: var(--color-danger, #c0362c); }\n .x-nav-list-item {\n text-align: left; border: 1px solid var(--color-border); border-radius: var(--radius-md);\n background: var(--color-surface); padding: 8px 10px; cursor: pointer;\n display: flex; flex-direction: column; gap: 2px;\n }\n .x-nav-list-active { border-color: var(--color-accent); }\n .x-nav-list-title { font-size: 13px; font-weight: 700; color: var(--color-text); }\n .x-nav-list-meta { font-size: 11px; color: var(--color-text-muted); }\n .x-nav-editor { min-width: 0; }\n .x-nav-editor-head {\n display: flex; justify-content: space-between; align-items: center;\n font-size: 13px; font-weight: 700; color: var(--color-text); margin-bottom: 12px;\n }\n .x-nav-editor-head button { margin-left: 6px; }\n .x-nav-items { display: flex; flex-direction: column; gap: 8px; }\n .x-nav-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 10px 12px; }\n .x-nav-item-off { opacity: 0.5; }\n .x-nav-item-row, .x-nav-child { display: flex; align-items: center; gap: 10px; }\n .x-nav-child { padding: 6px 0 0 28px; font-size: 12.5px; }\n .x-nav-grip { cursor: grab; color: var(--color-text-muted); }\n .x-nav-order { display: flex; flex-direction: column; }\n .x-nav-order button { border: 0; background: transparent; cursor: pointer; color: var(--color-text-muted); font-size: 10px; line-height: 1.1; padding: 1px 3px; }\n .x-nav-order button:disabled { opacity: 0.3; }\n .x-nav-item-label, .x-nav-child-label { font-weight: 700; font-size: 13px; }\n .x-nav-item-url { font-size: 11.5px; color: var(--color-text-muted); font-family: var(--font-mono); flex: 1; }\n .x-nav-item-actions { display: flex; gap: 8px; align-items: center; }\n .x-nav-toggle { border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: transparent; padding: 3px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted); }\n .x-nav-link { border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--color-accent-hover); }\n .x-nav-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 10px; }\n .x-nav-f { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 11.5px; color: var(--color-text-muted); font-weight: 700; }\n .x-nav-check { flex-direction: row; align-items: center; gap: 6px; }\n .x-nav-f-row { display: flex; gap: 10px; }\n .x-nav-form-actions { display: flex; gap: 8px; }\n</style>\n", styles: [".x-nav-head{margin-bottom:20px}.x-nav-title{font-size:24px;font-weight:800;color:var(--color-text)}.x-nav-sub{font-size:13.5px;color:var(--color-text-muted);margin-top:2px}.x-nav-sub code,.x-nav-editor-head code{font-family:var(--font-mono);font-size:12px}.x-nav-empty{font-size:14px;color:var(--color-text-muted);padding:12px 0}.x-nav-layout{display:grid;grid-template-columns:240px 1fr;gap:20px;align-items:start}.x-nav-list{display:flex;flex-direction:column;gap:6px}.x-nav-new{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}.x-nav-new select,.x-nav-new input,.x-nav-f input,.x-nav-f select{border:1px solid var(--color-border);border-radius:var(--radius-md);padding:6px 10px;font-size:13px;background:var(--color-surface);color:var(--color-text)}.x-nav-new button,.x-nav-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-md);padding:6px 14px;font-size:12.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted)}.x-nav-btn-primary{border-color:var(--color-accent);color:var(--color-accent-hover)}.x-nav-danger{color:var(--color-danger, #c0362c)}.x-nav-list-item{text-align:left;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);padding:8px 10px;cursor:pointer;display:flex;flex-direction:column;gap:2px}.x-nav-list-active{border-color:var(--color-accent)}.x-nav-list-title{font-size:13px;font-weight:700;color:var(--color-text)}.x-nav-list-meta{font-size:11px;color:var(--color-text-muted)}.x-nav-editor{min-width:0}.x-nav-editor-head{display:flex;justify-content:space-between;align-items:center;font-size:13px;font-weight:700;color:var(--color-text);margin-bottom:12px}.x-nav-editor-head button{margin-left:6px}.x-nav-items{display:flex;flex-direction:column;gap:8px}.x-nav-item{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:10px 12px}.x-nav-item-off{opacity:.5}.x-nav-item-row,.x-nav-child{display:flex;align-items:center;gap:10px}.x-nav-child{padding:6px 0 0 28px;font-size:12.5px}.x-nav-grip{cursor:grab;color:var(--color-text-muted)}.x-nav-order{display:flex;flex-direction:column}.x-nav-order button{border:0;background:transparent;cursor:pointer;color:var(--color-text-muted);font-size:10px;line-height:1.1;padding:1px 3px}.x-nav-order button:disabled{opacity:.3}.x-nav-item-label,.x-nav-child-label{font-weight:700;font-size:13px}.x-nav-item-url{font-size:11.5px;color:var(--color-text-muted);font-family:var(--font-mono);flex:1}.x-nav-item-actions{display:flex;gap:8px;align-items:center}.x-nav-toggle{border:1px solid var(--color-border);border-radius:var(--radius-sm);background:transparent;padding:3px 10px;font-size:11.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted)}.x-nav-link{border:0;background:transparent;cursor:pointer;font-size:12px;font-weight:700;color:var(--color-accent-hover)}.x-nav-form{margin-top:12px;padding-top:12px;border-top:1px solid var(--color-border);display:flex;flex-direction:column;gap:10px}.x-nav-f{display:flex;flex-direction:column;gap:4px;flex:1;font-size:11.5px;color:var(--color-text-muted);font-weight:700}.x-nav-check{flex-direction:row;align-items:center;gap:6px}.x-nav-f-row{display:flex;gap:10px}.x-nav-form-actions{display:flex;gap:8px}\n"], dependencies: [{ kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i1$1.LoaderComponent, selector: "x-element-loader", inputs: ["data"] }] }); }
254
+ }
255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: NavigationComponent, decorators: [{
256
+ type: Component,
257
+ args: [{ standalone: false, selector: 'x-navigation', template: "<div class=\"x-nav-head\">\n <div class=\"x-nav-title\">Navigation</div>\n <div class=\"x-nav-sub\">Storefront menus \u2014 the shell consumes the <code>header_primary</code> menu.</div>\n</div>\n\n@if (loading) {\n <x-element-loader></x-element-loader>\n} @else {\n <div class=\"x-nav-layout\">\n <aside class=\"x-nav-list\">\n <div class=\"x-nav-new\">\n <select [(ngModel)]=\"newMenuLocation\">\n @for (l of locations; track l) { <option [value]=\"l\">{{ l }}</option> }\n </select>\n <input type=\"text\" placeholder=\"Menu name\" [(ngModel)]=\"newMenuName\" />\n <button type=\"button\" (click)=\"createMenu()\">Add menu</button>\n </div>\n @for (m of menus; track m.id) {\n <button\n type=\"button\"\n class=\"x-nav-list-item\"\n [class.x-nav-list-active]=\"selected?.id === m.id\"\n (click)=\"select(m)\"\n >\n <span class=\"x-nav-list-title\">{{ m.name }}</span>\n <span class=\"x-nav-list-meta\">{{ m.location }}</span>\n </button>\n } @empty {\n <div class=\"x-nav-empty\">No menus yet.</div>\n }\n </aside>\n\n <section class=\"x-nav-editor\">\n @if (!selected) {\n <div class=\"x-nav-empty\">Pick a menu, or add one.</div>\n } @else {\n <div class=\"x-nav-editor-head\">\n <span>{{ selected.name }} \u2014 <code>{{ selected.location }}</code></span>\n <span>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"addItem()\">Add link</button>\n <button type=\"button\" class=\"x-nav-btn x-nav-danger\" (click)=\"deleteMenu()\">Delete menu</button>\n </span>\n </div>\n\n @if (!topLevel.length) {\n <div class=\"x-nav-empty\">No links yet.</div>\n } @else {\n <div class=\"x-nav-items\">\n @for (item of topLevel; track item.id; let i = $index) {\n <div\n class=\"x-nav-item\"\n [class.x-nav-item-off]=\"!item.enabled\"\n draggable=\"true\"\n (dragstart)=\"onDragStart(i)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop(i)\"\n >\n <div class=\"x-nav-item-row\">\n <span class=\"x-nav-grip\">\u283F</span>\n <div class=\"x-nav-order\">\n <button type=\"button\" (click)=\"moveItem(i, -1)\" [disabled]=\"i === 0\">\u25B2</button>\n <button type=\"button\" (click)=\"moveItem(i, 1)\" [disabled]=\"i === topLevel.length - 1\">\u25BC</button>\n </div>\n <span class=\"x-nav-item-label\">{{ item.label }}</span>\n <span class=\"x-nav-item-url\">{{ item.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(item)\">{{ item.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(item)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(item)\">Delete</button>\n </span>\n </div>\n\n @for (child of childrenOf(item.id); track child.id) {\n <div class=\"x-nav-child\" [class.x-nav-item-off]=\"!child.enabled\">\n <span class=\"x-nav-child-label\">\u21B3 {{ child.label }}</span>\n <span class=\"x-nav-item-url\">{{ child.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(child)\">{{ child.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(child)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(child)\">Delete</button>\n </span>\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (editingItem) {\n <ng-container *ngTemplateOutlet=\"itemForm\"></ng-container>\n }\n }\n </section>\n </div>\n}\n\n<ng-template #itemForm>\n <div class=\"x-nav-form\">\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Label<input type=\"text\" [(ngModel)]=\"itemModel.label\" /></label>\n <label class=\"x-nav-f\">URL<input type=\"text\" [(ngModel)]=\"itemModel.url\" placeholder=\"/c/solar-panels\" /></label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">\n Parent\n <select [(ngModel)]=\"itemModel.parentId\">\n <option value=\"\">\u2014 top level \u2014</option>\n @for (p of parentOptions; track p.id) { <option [value]=\"p.id\">{{ p.label }}</option> }\n </select>\n </label>\n <label class=\"x-nav-f\">Icon<input type=\"text\" [(ngModel)]=\"itemModel.icon\" /></label>\n <label class=\"x-nav-f x-nav-check\">\n <input type=\"checkbox\" [(ngModel)]=\"itemModel.openInNewTab\" /> New tab\n </label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Starts<input type=\"datetime-local\" [(ngModel)]=\"itemModel.startsAt\" /></label>\n <label class=\"x-nav-f\">Ends<input type=\"datetime-local\" [(ngModel)]=\"itemModel.endsAt\" /></label>\n </div>\n <div class=\"x-nav-form-actions\">\n <button type=\"button\" class=\"x-nav-btn x-nav-btn-primary\" (click)=\"saveItem()\">Save link</button>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"cancelItemEdit()\">Cancel</button>\n </div>\n </div>\n</ng-template>\n\n<style>\n .x-nav-head { margin-bottom: 20px; }\n .x-nav-title { font-size: 24px; font-weight: 800; color: var(--color-text); }\n .x-nav-sub { font-size: 13.5px; color: var(--color-text-muted); margin-top: 2px; }\n .x-nav-sub code, .x-nav-editor-head code { font-family: var(--font-mono); font-size: 12px; }\n .x-nav-empty { font-size: 14px; color: var(--color-text-muted); padding: 12px 0; }\n .x-nav-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }\n .x-nav-list { display: flex; flex-direction: column; gap: 6px; }\n .x-nav-new { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }\n .x-nav-new select, .x-nav-new input, .x-nav-f input, .x-nav-f select {\n border: 1px solid var(--color-border); border-radius: var(--radius-md);\n padding: 6px 10px; font-size: 13px; background: var(--color-surface); color: var(--color-text);\n }\n .x-nav-new button, .x-nav-btn {\n border: 1px solid var(--color-border); background: transparent; border-radius: var(--radius-md);\n padding: 6px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted);\n }\n .x-nav-btn-primary { border-color: var(--color-accent); color: var(--color-accent-hover); }\n .x-nav-danger { color: var(--color-danger, #c0362c); }\n .x-nav-list-item {\n text-align: left; border: 1px solid var(--color-border); border-radius: var(--radius-md);\n background: var(--color-surface); padding: 8px 10px; cursor: pointer;\n display: flex; flex-direction: column; gap: 2px;\n }\n .x-nav-list-active { border-color: var(--color-accent); }\n .x-nav-list-title { font-size: 13px; font-weight: 700; color: var(--color-text); }\n .x-nav-list-meta { font-size: 11px; color: var(--color-text-muted); }\n .x-nav-editor { min-width: 0; }\n .x-nav-editor-head {\n display: flex; justify-content: space-between; align-items: center;\n font-size: 13px; font-weight: 700; color: var(--color-text); margin-bottom: 12px;\n }\n .x-nav-editor-head button { margin-left: 6px; }\n .x-nav-items { display: flex; flex-direction: column; gap: 8px; }\n .x-nav-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 10px 12px; }\n .x-nav-item-off { opacity: 0.5; }\n .x-nav-item-row, .x-nav-child { display: flex; align-items: center; gap: 10px; }\n .x-nav-child { padding: 6px 0 0 28px; font-size: 12.5px; }\n .x-nav-grip { cursor: grab; color: var(--color-text-muted); }\n .x-nav-order { display: flex; flex-direction: column; }\n .x-nav-order button { border: 0; background: transparent; cursor: pointer; color: var(--color-text-muted); font-size: 10px; line-height: 1.1; padding: 1px 3px; }\n .x-nav-order button:disabled { opacity: 0.3; }\n .x-nav-item-label, .x-nav-child-label { font-weight: 700; font-size: 13px; }\n .x-nav-item-url { font-size: 11.5px; color: var(--color-text-muted); font-family: var(--font-mono); flex: 1; }\n .x-nav-item-actions { display: flex; gap: 8px; align-items: center; }\n .x-nav-toggle { border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: transparent; padding: 3px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted); }\n .x-nav-link { border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--color-accent-hover); }\n .x-nav-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 10px; }\n .x-nav-f { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 11.5px; color: var(--color-text-muted); font-weight: 700; }\n .x-nav-check { flex-direction: row; align-items: center; gap: 6px; }\n .x-nav-f-row { display: flex; gap: 10px; }\n .x-nav-form-actions { display: flex; gap: 8px; }\n</style>\n" }]
258
+ }] });
259
+
260
+ class NavigationModule {
261
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: NavigationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
262
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.16", ngImport: i0, type: NavigationModule, declarations: [NavigationComponent], imports: [SharedModule,
263
+ ElementsModule, i1$2.RouterModule] }); }
264
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: NavigationModule, imports: [SharedModule,
265
+ ElementsModule,
266
+ RouterModule.forChild([{ path: '', component: NavigationComponent }])] }); }
267
+ }
268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: NavigationModule, decorators: [{
269
+ type: NgModule,
270
+ args: [{
271
+ declarations: [NavigationComponent],
272
+ imports: [
273
+ SharedModule,
274
+ ElementsModule,
275
+ RouterModule.forChild([{ path: '', component: NavigationComponent }]),
276
+ ],
277
+ }]
278
+ }] });
279
+
280
+ export { NavigationModule };
281
+ //# sourceMappingURL=isaiahiroko-tilmart-ngx-apps-admin-navigation.module-DoKzzRgn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isaiahiroko-tilmart-ngx-apps-admin-navigation.module-DoKzzRgn.mjs","sources":["../../../projects/admin/src/lib/pages/navigation/navigation.component.ts","../../../projects/admin/src/lib/pages/navigation/navigation.component.html","../../../projects/admin/src/lib/pages/navigation/navigation.module.ts"],"sourcesContent":["import { Component } from '@angular/core';\nimport { BaseDirective, notify, using } from '@thescaffold/ngx-core';\nimport { firstValueFrom, takeUntil } from 'rxjs';\n\ninterface MenuVm {\n id: string;\n location: string;\n name: string;\n enabled: boolean;\n}\n\ninterface ItemVm {\n id: string;\n menuId: string;\n label: string;\n url: string;\n position: number;\n parentId?: string;\n icon?: string;\n openInNewTab: boolean;\n startsAt?: string;\n endsAt?: string;\n enabled: boolean;\n}\n\nconst LOCATIONS = [\n 'header_primary',\n 'header_secondary',\n 'footer',\n 'mobile_drawer',\n 'utility_bar',\n];\n\n// P6.12, CMS-03 — the ops navigation editor. Menus (one per location) and\n// their items: label, url, nesting (`parentId`), schedule and order. The\n// storefront shell consumes `header_primary` (P6.12 shell wiring).\n@Component({\n standalone: false,\n selector: 'x-navigation',\n templateUrl: './navigation.component.html',\n})\nexport class NavigationComponent extends BaseDirective {\n private readonly menuSource = this.apiService.on('apps/commerce/navigation-menu');\n private readonly itemSource = this.apiService.on('apps/commerce/navigation-item');\n\n readonly locations = LOCATIONS;\n\n loading = true;\n menus: MenuVm[] = [];\n selected?: MenuVm;\n items: ItemVm[] = [];\n\n newMenuLocation = LOCATIONS[0];\n newMenuName = '';\n\n editingItem?: ItemVm;\n itemModel: {\n label: string;\n url: string;\n parentId: string;\n icon: string;\n openInNewTab: boolean;\n startsAt: string;\n endsAt: string;\n } = this.blankItem();\n\n private dragIndex: number | null = null;\n\n override init = () => {\n this.load();\n };\n\n get topLevel(): ItemVm[] {\n return this.items\n .filter((i) => !i.parentId)\n .sort((a, b) => a.position - b.position);\n }\n\n childrenOf(parentId: string): ItemVm[] {\n return this.items\n .filter((i) => i.parentId === parentId)\n .sort((a, b) => a.position - b.position);\n }\n\n get parentOptions(): ItemVm[] {\n // Only top-level items can be parents (one level of nesting).\n return this.items.filter((i) => !i.parentId && i.id !== this.editingItem?.id);\n }\n\n load(): void {\n this.loading = true;\n this.menuSource\n .getMany({ perPage: 100 } as any)\n .pipe(takeUntil(this.$))\n .subscribe(\n using((res: any) => {\n this.menus = (res?.data ?? []).sort((a: any, b: any) =>\n String(a.location).localeCompare(String(b.location)),\n );\n this.loading = false;\n if (this.selected) {\n this.selected = this.menus.find((m) => m.id === this.selected!.id);\n }\n }),\n );\n }\n\n async createMenu(): Promise<void> {\n const name = this.newMenuName.trim();\n if (!name) return;\n try {\n const res: any = await firstValueFrom(\n this.menuSource.create({\n location: this.newMenuLocation,\n name,\n enabled: true,\n } as any),\n );\n this.newMenuName = '';\n notify('Menu created.', undefined, 'success');\n this.load();\n if (res?.data?.id) setTimeout(() => this.select({ ...res.data }), 200);\n } catch {\n notify('Could not create the menu.', undefined, 'error');\n }\n }\n\n select(menu: MenuVm): void {\n this.selected = menu;\n this.editingItem = undefined;\n this.loadItems();\n }\n\n async deleteMenu(): Promise<void> {\n if (!this.selected) return;\n try {\n await firstValueFrom(this.menuSource.remove(this.selected.id));\n this.selected = undefined;\n this.items = [];\n notify('Menu deleted.', undefined, 'success');\n this.load();\n } catch {\n notify('Could not delete the menu.', undefined, 'error');\n }\n }\n\n private loadItems(): void {\n if (!this.selected) return;\n this.itemSource\n .getMany({ menuId: this.selected.id, perPage: 200 } as any)\n .pipe(takeUntil(this.$))\n .subscribe(\n using((res: any) => {\n this.items = ((res?.data ?? []) as ItemVm[]).filter(\n (i) => i.menuId === this.selected!.id,\n );\n }),\n );\n }\n\n async addItem(): Promise<void> {\n if (!this.selected) return;\n try {\n await firstValueFrom(\n this.itemSource.create({\n menuId: this.selected.id,\n label: 'New link',\n url: '/',\n position: this.topLevel.length,\n enabled: true,\n } as any),\n );\n this.loadItems();\n } catch {\n notify('Could not add the item.', undefined, 'error');\n }\n }\n\n editItem(item: ItemVm): void {\n this.editingItem = item;\n this.itemModel = {\n label: item.label,\n url: typeof item.url === 'string' ? item.url : '',\n parentId: item.parentId ?? '',\n icon: item.icon ?? '',\n openInNewTab: !!item.openInNewTab,\n startsAt: this.toLocal(item.startsAt),\n endsAt: this.toLocal(item.endsAt),\n };\n }\n\n cancelItemEdit(): void {\n this.editingItem = undefined;\n this.itemModel = this.blankItem();\n }\n\n async saveItem(): Promise<void> {\n if (!this.editingItem) return;\n try {\n await firstValueFrom(\n this.itemSource.update(this.editingItem.id, {\n label: this.itemModel.label.trim() || 'Link',\n url: this.itemModel.url.trim() || '/',\n parentId: this.itemModel.parentId || null,\n icon: this.itemModel.icon.trim() || undefined,\n openInNewTab: this.itemModel.openInNewTab,\n startsAt: this.itemModel.startsAt ? new Date(this.itemModel.startsAt).toISOString() : null,\n endsAt: this.itemModel.endsAt ? new Date(this.itemModel.endsAt).toISOString() : null,\n } as any),\n );\n notify('Item saved.', undefined, 'success');\n this.cancelItemEdit();\n this.loadItems();\n } catch {\n notify('Could not save the item.', undefined, 'error');\n }\n }\n\n async toggleItem(item: ItemVm): Promise<void> {\n const next = !item.enabled;\n try {\n await firstValueFrom(this.itemSource.update(item.id, { enabled: next } as any));\n item.enabled = next;\n } catch {\n notify('Could not update the item.', undefined, 'error');\n }\n }\n\n async removeItem(item: ItemVm): Promise<void> {\n try {\n // Detach any children first so they don't dangle.\n await Promise.all(\n this.childrenOf(item.id).map((child) =>\n firstValueFrom(this.itemSource.update(child.id, { parentId: null } as any)),\n ),\n );\n await firstValueFrom(this.itemSource.remove(item.id));\n this.items = this.items.filter((i) => i.id !== item.id);\n if (this.editingItem?.id === item.id) this.cancelItemEdit();\n notify('Item removed.', undefined, 'success');\n } catch {\n notify('Could not remove the item.', undefined, 'error');\n }\n }\n\n onDragStart(index: number): void {\n this.dragIndex = index;\n }\n\n onDragOver(event: DragEvent): void {\n event.preventDefault();\n }\n\n onDrop(targetIndex: number): void {\n if (this.dragIndex === null || this.dragIndex === targetIndex) return;\n const ordered = this.topLevel;\n const [moved] = ordered.splice(this.dragIndex, 1);\n ordered.splice(targetIndex, 0, moved);\n this.dragIndex = null;\n void this.persistOrder(ordered);\n }\n\n moveItem(index: number, dir: -1 | 1): void {\n const ordered = this.topLevel;\n const target = index + dir;\n if (target < 0 || target >= ordered.length) return;\n [ordered[index], ordered[target]] = [ordered[target], ordered[index]];\n void this.persistOrder(ordered);\n }\n\n private async persistOrder(ordered: ItemVm[]): Promise<void> {\n const changed: ItemVm[] = [];\n ordered.forEach((item, i) => {\n if (item.position !== i) {\n item.position = i;\n changed.push(item);\n }\n });\n try {\n await Promise.all(\n changed.map((item) =>\n firstValueFrom(this.itemSource.update(item.id, { position: item.position } as any)),\n ),\n );\n } catch {\n notify('Could not save the new order.', undefined, 'error');\n this.loadItems();\n }\n }\n\n private blankItem() {\n return {\n label: '',\n url: '',\n parentId: '',\n icon: '',\n openInNewTab: false,\n startsAt: '',\n endsAt: '',\n };\n }\n\n private toLocal(iso?: string): string {\n if (!iso) return '';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '';\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;\n }\n}\n","<div class=\"x-nav-head\">\n <div class=\"x-nav-title\">Navigation</div>\n <div class=\"x-nav-sub\">Storefront menus — the shell consumes the <code>header_primary</code> menu.</div>\n</div>\n\n@if (loading) {\n <x-element-loader></x-element-loader>\n} @else {\n <div class=\"x-nav-layout\">\n <aside class=\"x-nav-list\">\n <div class=\"x-nav-new\">\n <select [(ngModel)]=\"newMenuLocation\">\n @for (l of locations; track l) { <option [value]=\"l\">{{ l }}</option> }\n </select>\n <input type=\"text\" placeholder=\"Menu name\" [(ngModel)]=\"newMenuName\" />\n <button type=\"button\" (click)=\"createMenu()\">Add menu</button>\n </div>\n @for (m of menus; track m.id) {\n <button\n type=\"button\"\n class=\"x-nav-list-item\"\n [class.x-nav-list-active]=\"selected?.id === m.id\"\n (click)=\"select(m)\"\n >\n <span class=\"x-nav-list-title\">{{ m.name }}</span>\n <span class=\"x-nav-list-meta\">{{ m.location }}</span>\n </button>\n } @empty {\n <div class=\"x-nav-empty\">No menus yet.</div>\n }\n </aside>\n\n <section class=\"x-nav-editor\">\n @if (!selected) {\n <div class=\"x-nav-empty\">Pick a menu, or add one.</div>\n } @else {\n <div class=\"x-nav-editor-head\">\n <span>{{ selected.name }} — <code>{{ selected.location }}</code></span>\n <span>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"addItem()\">Add link</button>\n <button type=\"button\" class=\"x-nav-btn x-nav-danger\" (click)=\"deleteMenu()\">Delete menu</button>\n </span>\n </div>\n\n @if (!topLevel.length) {\n <div class=\"x-nav-empty\">No links yet.</div>\n } @else {\n <div class=\"x-nav-items\">\n @for (item of topLevel; track item.id; let i = $index) {\n <div\n class=\"x-nav-item\"\n [class.x-nav-item-off]=\"!item.enabled\"\n draggable=\"true\"\n (dragstart)=\"onDragStart(i)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop(i)\"\n >\n <div class=\"x-nav-item-row\">\n <span class=\"x-nav-grip\">⠿</span>\n <div class=\"x-nav-order\">\n <button type=\"button\" (click)=\"moveItem(i, -1)\" [disabled]=\"i === 0\">▲</button>\n <button type=\"button\" (click)=\"moveItem(i, 1)\" [disabled]=\"i === topLevel.length - 1\">▼</button>\n </div>\n <span class=\"x-nav-item-label\">{{ item.label }}</span>\n <span class=\"x-nav-item-url\">{{ item.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(item)\">{{ item.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(item)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(item)\">Delete</button>\n </span>\n </div>\n\n @for (child of childrenOf(item.id); track child.id) {\n <div class=\"x-nav-child\" [class.x-nav-item-off]=\"!child.enabled\">\n <span class=\"x-nav-child-label\">↳ {{ child.label }}</span>\n <span class=\"x-nav-item-url\">{{ child.url }}</span>\n <span class=\"x-nav-item-actions\">\n <button type=\"button\" class=\"x-nav-toggle\" (click)=\"toggleItem(child)\">{{ child.enabled ? 'On' : 'Off' }}</button>\n <button type=\"button\" class=\"x-nav-link\" (click)=\"editItem(child)\">Edit</button>\n <button type=\"button\" class=\"x-nav-link x-nav-danger\" (click)=\"removeItem(child)\">Delete</button>\n </span>\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (editingItem) {\n <ng-container *ngTemplateOutlet=\"itemForm\"></ng-container>\n }\n }\n </section>\n </div>\n}\n\n<ng-template #itemForm>\n <div class=\"x-nav-form\">\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Label<input type=\"text\" [(ngModel)]=\"itemModel.label\" /></label>\n <label class=\"x-nav-f\">URL<input type=\"text\" [(ngModel)]=\"itemModel.url\" placeholder=\"/c/solar-panels\" /></label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">\n Parent\n <select [(ngModel)]=\"itemModel.parentId\">\n <option value=\"\">— top level —</option>\n @for (p of parentOptions; track p.id) { <option [value]=\"p.id\">{{ p.label }}</option> }\n </select>\n </label>\n <label class=\"x-nav-f\">Icon<input type=\"text\" [(ngModel)]=\"itemModel.icon\" /></label>\n <label class=\"x-nav-f x-nav-check\">\n <input type=\"checkbox\" [(ngModel)]=\"itemModel.openInNewTab\" /> New tab\n </label>\n </div>\n <div class=\"x-nav-f-row\">\n <label class=\"x-nav-f\">Starts<input type=\"datetime-local\" [(ngModel)]=\"itemModel.startsAt\" /></label>\n <label class=\"x-nav-f\">Ends<input type=\"datetime-local\" [(ngModel)]=\"itemModel.endsAt\" /></label>\n </div>\n <div class=\"x-nav-form-actions\">\n <button type=\"button\" class=\"x-nav-btn x-nav-btn-primary\" (click)=\"saveItem()\">Save link</button>\n <button type=\"button\" class=\"x-nav-btn\" (click)=\"cancelItemEdit()\">Cancel</button>\n </div>\n </div>\n</ng-template>\n\n<style>\n .x-nav-head { margin-bottom: 20px; }\n .x-nav-title { font-size: 24px; font-weight: 800; color: var(--color-text); }\n .x-nav-sub { font-size: 13.5px; color: var(--color-text-muted); margin-top: 2px; }\n .x-nav-sub code, .x-nav-editor-head code { font-family: var(--font-mono); font-size: 12px; }\n .x-nav-empty { font-size: 14px; color: var(--color-text-muted); padding: 12px 0; }\n .x-nav-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }\n .x-nav-list { display: flex; flex-direction: column; gap: 6px; }\n .x-nav-new { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }\n .x-nav-new select, .x-nav-new input, .x-nav-f input, .x-nav-f select {\n border: 1px solid var(--color-border); border-radius: var(--radius-md);\n padding: 6px 10px; font-size: 13px; background: var(--color-surface); color: var(--color-text);\n }\n .x-nav-new button, .x-nav-btn {\n border: 1px solid var(--color-border); background: transparent; border-radius: var(--radius-md);\n padding: 6px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted);\n }\n .x-nav-btn-primary { border-color: var(--color-accent); color: var(--color-accent-hover); }\n .x-nav-danger { color: var(--color-danger, #c0362c); }\n .x-nav-list-item {\n text-align: left; border: 1px solid var(--color-border); border-radius: var(--radius-md);\n background: var(--color-surface); padding: 8px 10px; cursor: pointer;\n display: flex; flex-direction: column; gap: 2px;\n }\n .x-nav-list-active { border-color: var(--color-accent); }\n .x-nav-list-title { font-size: 13px; font-weight: 700; color: var(--color-text); }\n .x-nav-list-meta { font-size: 11px; color: var(--color-text-muted); }\n .x-nav-editor { min-width: 0; }\n .x-nav-editor-head {\n display: flex; justify-content: space-between; align-items: center;\n font-size: 13px; font-weight: 700; color: var(--color-text); margin-bottom: 12px;\n }\n .x-nav-editor-head button { margin-left: 6px; }\n .x-nav-items { display: flex; flex-direction: column; gap: 8px; }\n .x-nav-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 10px 12px; }\n .x-nav-item-off { opacity: 0.5; }\n .x-nav-item-row, .x-nav-child { display: flex; align-items: center; gap: 10px; }\n .x-nav-child { padding: 6px 0 0 28px; font-size: 12.5px; }\n .x-nav-grip { cursor: grab; color: var(--color-text-muted); }\n .x-nav-order { display: flex; flex-direction: column; }\n .x-nav-order button { border: 0; background: transparent; cursor: pointer; color: var(--color-text-muted); font-size: 10px; line-height: 1.1; padding: 1px 3px; }\n .x-nav-order button:disabled { opacity: 0.3; }\n .x-nav-item-label, .x-nav-child-label { font-weight: 700; font-size: 13px; }\n .x-nav-item-url { font-size: 11.5px; color: var(--color-text-muted); font-family: var(--font-mono); flex: 1; }\n .x-nav-item-actions { display: flex; gap: 8px; align-items: center; }\n .x-nav-toggle { border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: transparent; padding: 3px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; color: var(--color-text-muted); }\n .x-nav-link { border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--color-accent-hover); }\n .x-nav-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 10px; }\n .x-nav-f { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 11.5px; color: var(--color-text-muted); font-weight: 700; }\n .x-nav-check { flex-direction: row; align-items: center; gap: 6px; }\n .x-nav-f-row { display: flex; gap: 10px; }\n .x-nav-form-actions { display: flex; gap: 8px; }\n</style>\n","import { NgModule } from '@angular/core';\nimport { RouterModule } from '@angular/router';\nimport { SharedModule } from '@thescaffold/ngx-core';\nimport { ElementsModule } from '@thescaffold/ngx-ui';\nimport { NavigationComponent } from './navigation.component';\n\n@NgModule({\n declarations: [NavigationComponent],\n imports: [\n SharedModule,\n ElementsModule,\n RouterModule.forChild([{ path: '', component: NavigationComponent }]),\n ],\n})\nexport class NavigationModule {}\n"],"names":["i1","i2","i3"],"mappings":";;;;;;;;;;;AAyBA,MAAM,SAAS,GAAG;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,QAAQ;IACR,eAAe;IACf,aAAa;CACd;AAED;AACA;AACA;AAMM,MAAO,mBAAoB,SAAQ,aAAa,CAAA;AALtD,IAAA,WAAA,GAAA;;QAMmB,IAAA,CAAA,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,+BAA+B,CAAC;QAChE,IAAA,CAAA,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,+BAA+B,CAAC;QAExE,IAAA,CAAA,SAAS,GAAG,SAAS;QAE9B,IAAA,CAAA,OAAO,GAAG,IAAI;QACd,IAAA,CAAA,KAAK,GAAa,EAAE;QAEpB,IAAA,CAAA,KAAK,GAAa,EAAE;AAEpB,QAAA,IAAA,CAAA,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC;QAC9B,IAAA,CAAA,WAAW,G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
+ import { RouterModule } from '@angular/router';
5
+ import { BaseDirective, using, SharedModule } from '@thescaffold/ngx-core';
6
+ import * as i1$1 from '@thescaffold/ngx-ui';
7
+ import { ElementsModule } from '@thescaffold/ngx-ui';
8
+ import { BehaviorSubject, takeUntil } from 'rxjs';
9
+ import * as i2 from '@angular/common';
10
+
11
+ // ORD-12 — the ops work queues. Each column is a stage of the order
12
+ // lifecycle a team acts on; cards carry an age so a stale one stands out
13
+ // (a crude SLA cue until per-queue SLA timers + assignment land in P7).
14
+ const QUEUES = [
15
+ { key: 'awaiting_payment', label: 'Awaiting payment', statuses: ['pending_payment', 'on_hold'] },
16
+ { key: 'new', label: 'New — to confirm', statuses: ['payment_received', 'confirmed'] },
17
+ { key: 'processing', label: 'Being prepared', statuses: ['processing', 'partially_fulfilled'] },
18
+ {
19
+ key: 'ready',
20
+ label: 'Ready to ship / pick',
21
+ statuses: ['ready_to_ship', 'ready_for_pickup'],
22
+ },
23
+ {
24
+ key: 'in_transit',
25
+ label: 'In transit',
26
+ statuses: ['dispatched', 'out_for_delivery'],
27
+ },
28
+ { key: 'exceptions', label: 'Delivery exceptions', statuses: ['failed_delivery'] },
29
+ {
30
+ key: 'returns',
31
+ label: 'Returns in flight',
32
+ statuses: ['return_in_flight', 'returned'],
33
+ },
34
+ { key: 'done', label: 'Delivered / done', statuses: ['delivered', 'completed'] },
35
+ ];
36
+ function naira(amount, currency = 'NGN') {
37
+ return `${currency} ${Math.round(amount).toLocaleString('en-US')}`;
38
+ }
39
+ class OrderBoardComponent extends BaseDirective {
40
+ constructor() {
41
+ super(...arguments);
42
+ this.columns$ = new BehaviorSubject(null);
43
+ this.init = () => {
44
+ this.apiService
45
+ .on('apps/commerce/order')
46
+ .getMany({ page: 1, perPage: 400 })
47
+ .pipe(takeUntil(this.$))
48
+ .subscribe(using(({ data }) => {
49
+ const byQueue = new Map();
50
+ const now = Date.now();
51
+ for (const order of data ?? []) {
52
+ const queue = QUEUES.find((q) => q.statuses.includes(order.status));
53
+ if (!queue)
54
+ continue;
55
+ const placed = order.placedAt ?? order.createdAt;
56
+ const ageHours = placed
57
+ ? Math.max(0, (now - new Date(placed).getTime()) / 3_600_000)
58
+ : 0;
59
+ const card = {
60
+ id: order.id,
61
+ orderNumber: order.orderNumber,
62
+ totalLabel: naira(Number(order.grandTotal ?? 0), order.currency),
63
+ ageHours,
64
+ ageLabel: this.ageLabel(ageHours),
65
+ status: order.status,
66
+ };
67
+ const list = byQueue.get(queue.key) ?? [];
68
+ list.push(card);
69
+ byQueue.set(queue.key, list);
70
+ }
71
+ this.columns$.next(QUEUES.map((q) => ({
72
+ key: q.key,
73
+ label: q.label,
74
+ cards: (byQueue.get(q.key) ?? []).sort((a, b) => b.ageHours - a.ageHours),
75
+ })));
76
+ }));
77
+ };
78
+ }
79
+ ageLabel(hours) {
80
+ if (hours < 1)
81
+ return 'just now';
82
+ if (hours < 24)
83
+ return `${Math.floor(hours)}h`;
84
+ return `${Math.floor(hours / 24)}d`;
85
+ }
86
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
87
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: OrderBoardComponent, isStandalone: false, selector: "x-order-board", usesInheritance: true, ngImport: i0, template: "<div class=\"x-page-head\">\n <div class=\"x-page-title\">Order board</div>\n <div class=\"x-page-subtitle\">Every open order by ops queue (ORD-12). Cards are oldest-first.</div>\n</div>\n\n@if (columns$ | async; as columns) {\n <div class=\"x-board\">\n @for (col of columns; track col.key) {\n <div class=\"x-board-col\">\n <div class=\"x-board-col-head\">\n <span>{{ col.label }}</span>\n <span class=\"x-board-col-count\">{{ col.cards.length }}</span>\n </div>\n <div class=\"x-board-col-body\">\n @for (card of col.cards; track card.id) {\n <a class=\"x-order-card\" [routerLink]=\"['../orders']\" [queryParams]=\"{ q: card.orderNumber }\">\n <div class=\"x-order-card-row\">\n <span class=\"x-order-card-num\">{{ card.orderNumber }}</span>\n <span class=\"x-order-card-age\" [class.stale]=\"card.ageHours >= 48\">{{ card.ageLabel }}</span>\n </div>\n <div class=\"x-order-card-total\">{{ card.totalLabel }}</div>\n </a>\n } @empty {\n <div class=\"x-board-col-empty\">None</div>\n }\n </div>\n </div>\n }\n </div>\n} @else {\n <x-element-loader></x-element-loader>\n}\n", styles: [".x-page-head{margin-bottom:20px}.x-page-title{font-size:24px;font-weight:800;color:var(--color-text)}.x-page-subtitle{font-size:13.5px;color:var(--color-text-muted);margin-top:2px}.x-board{display:flex;gap:14px;overflow-x:auto;padding-bottom:12px}.x-board-col{flex:0 0 230px;background:var(--color-surface-2, var(--color-surface));border:1px solid var(--color-border);border-radius:10px;display:flex;flex-direction:column;max-height:calc(100vh - 180px)}.x-board-col-head{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.4px;color:var(--color-text-muted)}.x-board-col-count{background:var(--color-surface);border:1px solid var(--color-border);border-radius:10px;padding:1px 7px;font-size:11px}.x-board-col-body{display:flex;flex-direction:column;gap:8px;padding:0 10px 10px;overflow-y:auto}.x-board-col-empty{font-size:12px;color:var(--color-text-muted);padding:8px 4px;text-align:center}.x-order-card{display:block;text-decoration:none;background:var(--color-surface);border:1px solid var(--color-border);border-radius:8px;padding:10px 12px}.x-order-card-row{display:flex;justify-content:space-between;align-items:baseline}.x-order-card-num{font-family:var(--font-mono);font-size:12px;color:var(--color-text)}.x-order-card-age{font-size:11px;color:var(--color-text-muted)}.x-order-card-age.stale{color:var(--color-danger);font-weight:700}.x-order-card-total{font-size:13px;font-weight:800;color:var(--color-text);margin-top:6px}\n"], dependencies: [{ kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i1$1.LoaderComponent, selector: "x-element-loader", inputs: ["data"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] }); }
88
+ }
89
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardComponent, decorators: [{
90
+ type: Component,
91
+ args: [{ standalone: false, selector: 'x-order-board', template: "<div class=\"x-page-head\">\n <div class=\"x-page-title\">Order board</div>\n <div class=\"x-page-subtitle\">Every open order by ops queue (ORD-12). Cards are oldest-first.</div>\n</div>\n\n@if (columns$ | async; as columns) {\n <div class=\"x-board\">\n @for (col of columns; track col.key) {\n <div class=\"x-board-col\">\n <div class=\"x-board-col-head\">\n <span>{{ col.label }}</span>\n <span class=\"x-board-col-count\">{{ col.cards.length }}</span>\n </div>\n <div class=\"x-board-col-body\">\n @for (card of col.cards; track card.id) {\n <a class=\"x-order-card\" [routerLink]=\"['../orders']\" [queryParams]=\"{ q: card.orderNumber }\">\n <div class=\"x-order-card-row\">\n <span class=\"x-order-card-num\">{{ card.orderNumber }}</span>\n <span class=\"x-order-card-age\" [class.stale]=\"card.ageHours >= 48\">{{ card.ageLabel }}</span>\n </div>\n <div class=\"x-order-card-total\">{{ card.totalLabel }}</div>\n </a>\n } @empty {\n <div class=\"x-board-col-empty\">None</div>\n }\n </div>\n </div>\n }\n </div>\n} @else {\n <x-element-loader></x-element-loader>\n}\n", styles: [".x-page-head{margin-bottom:20px}.x-page-title{font-size:24px;font-weight:800;color:var(--color-text)}.x-page-subtitle{font-size:13.5px;color:var(--color-text-muted);margin-top:2px}.x-board{display:flex;gap:14px;overflow-x:auto;padding-bottom:12px}.x-board-col{flex:0 0 230px;background:var(--color-surface-2, var(--color-surface));border:1px solid var(--color-border);border-radius:10px;display:flex;flex-direction:column;max-height:calc(100vh - 180px)}.x-board-col-head{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.4px;color:var(--color-text-muted)}.x-board-col-count{background:var(--color-surface);border:1px solid var(--color-border);border-radius:10px;padding:1px 7px;font-size:11px}.x-board-col-body{display:flex;flex-direction:column;gap:8px;padding:0 10px 10px;overflow-y:auto}.x-board-col-empty{font-size:12px;color:var(--color-text-muted);padding:8px 4px;text-align:center}.x-order-card{display:block;text-decoration:none;background:var(--color-surface);border:1px solid var(--color-border);border-radius:8px;padding:10px 12px}.x-order-card-row{display:flex;justify-content:space-between;align-items:baseline}.x-order-card-num{font-family:var(--font-mono);font-size:12px;color:var(--color-text)}.x-order-card-age{font-size:11px;color:var(--color-text-muted)}.x-order-card-age.stale{color:var(--color-danger);font-weight:700}.x-order-card-total{font-size:13px;font-weight:800;color:var(--color-text);margin-top:6px}\n"] }]
92
+ }] });
93
+
94
+ class OrderBoardModule {
95
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
96
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardModule, declarations: [OrderBoardComponent], imports: [SharedModule,
97
+ ElementsModule, i1.RouterModule] }); }
98
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardModule, imports: [SharedModule,
99
+ ElementsModule,
100
+ RouterModule.forChild([{ path: '', component: OrderBoardComponent }])] }); }
101
+ }
102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: OrderBoardModule, decorators: [{
103
+ type: NgModule,
104
+ args: [{
105
+ declarations: [OrderBoardComponent],
106
+ imports: [
107
+ SharedModule,
108
+ ElementsModule,
109
+ RouterModule.forChild([{ path: '', component: OrderBoardComponent }]),
110
+ ],
111
+ }]
112
+ }] });
113
+
114
+ export { OrderBoardModule };
115
+ //# sourceMappingURL=isaiahiroko-tilmart-ngx-apps-admin-order-board.module-DIOjhptn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isaiahiroko-tilmart-ngx-apps-admin-order-board.module-DIOjhptn.mjs","sources":["../../../projects/admin/src/lib/pages/order-board/order-board.component.ts","../../../projects/admin/src/lib/pages/order-board/order-board.component.html","../../../projects/admin/src/lib/pages/order-board/order-board.module.ts"],"sourcesContent":["import { Component } from '@angular/core';\nimport { BaseDirective, using } from '@thescaffold/ngx-core';\nimport { BehaviorSubject, takeUntil } from 'rxjs';\n\n// ORD-12 — the ops work queues. Each column is a stage of the order\n// lifecycle a team acts on; cards carry an age so a stale one stands out\n// (a crude SLA cue until per-queue SLA timers + assignment land in P7).\nconst QUEUES: { key: string; label: string; statuses: string[] }[] = [\n { key: 'awaiting_payment', label: 'Awaiting payment', statuses: ['pending_payment', 'on_hold'] },\n { key: 'new', label: 'New — to confirm', statuses: ['payment_received', 'confirmed'] },\n { key: 'processing', label: 'Being prepared', statuses: ['processing', 'partially_fulfilled'] },\n {\n key: 'ready',\n label: 'Ready to ship / pick',\n statuses: ['ready_to_ship', 'ready_for_pickup'],\n },\n {\n key: 'in_transit',\n label: 'In transit',\n statuses: ['dispatched', 'out_for_delivery'],\n },\n { key: 'exceptions', label: 'Delivery exceptions', statuses: ['failed_delivery'] },\n {\n key: 'returns',\n label: 'Returns in flight',\n statuses: ['return_in_flight', 'returned'],\n },\n { key: 'done', label: 'Delivered / done', statuses: ['delivered', 'completed'] },\n];\n\nfunction naira(amount: number, currency = 'NGN'): string {\n return `${currency} ${Math.round(amount).toLocaleString('en-US')}`;\n}\n\ninterface CardVm {\n id: string;\n orderNumber: string;\n totalLabel: string;\n ageLabel: string;\n ageHours: number;\n status: string;\n}\n\ninterface ColumnVm {\n key: string;\n label: string;\n cards: CardVm[];\n}\n\n@Component({\n standalone: false,\n selector: 'x-order-board',\n templateUrl: './order-board.component.html',\n styleUrl: './order-board.component.scss',\n})\nexport class OrderBoardComponent extends BaseDirective {\n readonly columns$ = new BehaviorSubject<ColumnVm[] | null>(null);\n\n override init = () => {\n this.apiService\n .on('apps/commerce/order')\n .getMany({ page: 1, perPage: 400 } as any)\n .pipe(takeUntil(this.$))\n .subscribe(\n using(({ data }: { data: any[] }) => {\n const byQueue = new Map<string, CardVm[]>();\n const now = Date.now();\n for (const order of data ?? []) {\n const queue = QUEUES.find((q) => q.statuses.includes(order.status));\n if (!queue) continue;\n const placed = order.placedAt ?? order.createdAt;\n const ageHours = placed\n ? Math.max(0, (now - new Date(placed).getTime()) / 3_600_000)\n : 0;\n const card: CardVm = {\n id: order.id,\n orderNumber: order.orderNumber,\n totalLabel: naira(Number(order.grandTotal ?? 0), order.currency),\n ageHours,\n ageLabel: this.ageLabel(ageHours),\n status: order.status,\n };\n const list = byQueue.get(queue.key) ?? [];\n list.push(card);\n byQueue.set(queue.key, list);\n }\n this.columns$.next(\n QUEUES.map((q) => ({\n key: q.key,\n label: q.label,\n cards: (byQueue.get(q.key) ?? []).sort((a, b) => b.ageHours - a.ageHours),\n })),\n );\n }),\n );\n };\n\n private ageLabel(hours: number): string {\n if (hours < 1) return 'just now';\n if (hours < 24) return `${Math.floor(hours)}h`;\n return `${Math.floor(hours / 24)}d`;\n }\n}\n","<div class=\"x-page-head\">\n <div class=\"x-page-title\">Order board</div>\n <div class=\"x-page-subtitle\">Every open order by ops queue (ORD-12). Cards are oldest-first.</div>\n</div>\n\n@if (columns$ | async; as columns) {\n <div class=\"x-board\">\n @for (col of columns; track col.key) {\n <div class=\"x-board-col\">\n <div class=\"x-board-col-head\">\n <span>{{ col.label }}</span>\n <span class=\"x-board-col-count\">{{ col.cards.length }}</span>\n </div>\n <div class=\"x-board-col-body\">\n @for (card of col.cards; track card.id) {\n <a class=\"x-order-card\" [routerLink]=\"['../orders']\" [queryParams]=\"{ q: card.orderNumber }\">\n <div class=\"x-order-card-row\">\n <span class=\"x-order-card-num\">{{ card.orderNumber }}</span>\n <span class=\"x-order-card-age\" [class.stale]=\"card.ageHours >= 48\">{{ card.ageLabel }}</span>\n </div>\n <div class=\"x-order-card-total\">{{ card.totalLabel }}</div>\n </a>\n } @empty {\n <div class=\"x-board-col-empty\">None</div>\n }\n </div>\n </div>\n }\n </div>\n} @else {\n <x-element-loader></x-element-loader>\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule } from '@angular/router';\nimport { SharedModule } from '@thescaffold/ngx-core';\nimport { ElementsModule } from '@thescaffold/ngx-ui';\nimport { OrderBoardComponent } from './order-board.component';\n\n@NgModule({\n declarations: [OrderBoardComponent],\n imports: [\n SharedModule,\n ElementsModule,\n RouterModule.forChild([{ path: '', component: OrderBoardComponent }]),\n ],\n})\nexport class OrderBoardModule {}\n"],"names":["i2","i3"],"mappings":";;;;;;;;;;AAIA;AACA;AACA;AACA,MAAM,MAAM,GAAyD;AACnE,IAAA,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE;AAChG,IAAA,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,kBAAkB,EAAE,WAAW,CAAC,EAAE;AACtF,IAAA,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC,EAAE;AAC/F,IAAA;AACE,QAAA,GAAG,EAAE,OAAO;AACZ,QAAA,KAAK,EAAE,sBAAsB;AAC7B,QAAA,QAAQ,EAAE,CAAC,eAAe,EAAE,kBAAkB,CAAC;AAChD,KAAA;AACD,IAAA;AACE,QAAA,GAAG,EAAE,YAAY;AACjB,QAAA,KAAK,EAAE,YAAY;AACnB,QAAA,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;AAC7C,KAAA;AACD,IAAA,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC,iBAAi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