@masterteam/accessibilities 0.0.1
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.
- package/assets/accessibilities.css +2 -0
- package/assets/i18n/ar.json +37 -0
- package/assets/i18n/en.json +37 -0
- package/fesm2022/masterteam-accessibilities.mjs +1126 -0
- package/fesm2022/masterteam-accessibilities.mjs.map +1 -0
- package/package.json +48 -0
- package/types/masterteam-accessibilities.d.ts +376 -0
|
@@ -0,0 +1,1126 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, Injectable, computed, signal, Component, input, linkedSignal, effect, model } from '@angular/core';
|
|
4
|
+
import { ActivatedRoute, Router, RouterOutlet } from '@angular/router';
|
|
5
|
+
import { TranslocoService, TranslocoDirective, TranslocoPipe } from '@jsverse/transloco';
|
|
6
|
+
import { Page } from '@masterteam/components/page';
|
|
7
|
+
import { Action, Selector, State, Store, select } from '@ngxs/store';
|
|
8
|
+
import { HttpClient } from '@angular/common/http';
|
|
9
|
+
import { CrudStateBase, handleApiRequest, ValidatorConfig } from '@masterteam/components';
|
|
10
|
+
import { Avatar } from '@masterteam/components/avatar';
|
|
11
|
+
import { Button } from '@masterteam/components/button';
|
|
12
|
+
import { Card } from '@masterteam/components/card';
|
|
13
|
+
import { ModalService } from '@masterteam/components/modal';
|
|
14
|
+
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
15
|
+
import * as i1$1 from 'primeng/skeleton';
|
|
16
|
+
import { SkeletonModule } from 'primeng/skeleton';
|
|
17
|
+
import * as i1 from '@angular/forms';
|
|
18
|
+
import { FormsModule, FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
19
|
+
import { ModalRef } from '@masterteam/components/dialog';
|
|
20
|
+
import { SelectField } from '@masterteam/components/select-field';
|
|
21
|
+
import { Tabs } from '@masterteam/components/tabs';
|
|
22
|
+
import { DynamicForm } from '@masterteam/forms/dynamic-form';
|
|
23
|
+
import { Tree } from '@masterteam/components/tree';
|
|
24
|
+
|
|
25
|
+
class GetAccessibilities {
|
|
26
|
+
static type = '[Accessibilities] Get Accessibilities';
|
|
27
|
+
}
|
|
28
|
+
class GetCategories {
|
|
29
|
+
static type = '[Accessibilities] Get Categories';
|
|
30
|
+
}
|
|
31
|
+
class AddCategory {
|
|
32
|
+
payload;
|
|
33
|
+
static type = '[Accessibilities] Add Category';
|
|
34
|
+
constructor(payload) {
|
|
35
|
+
this.payload = payload;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class UpdateCategory {
|
|
39
|
+
id;
|
|
40
|
+
payload;
|
|
41
|
+
static type = '[Accessibilities] Update Category';
|
|
42
|
+
constructor(id, payload) {
|
|
43
|
+
this.id = id;
|
|
44
|
+
this.payload = payload;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class DeleteCategory {
|
|
48
|
+
id;
|
|
49
|
+
static type = '[Accessibilities] Delete Category';
|
|
50
|
+
constructor(id) {
|
|
51
|
+
this.id = id;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class GetCategoryDetails {
|
|
55
|
+
id;
|
|
56
|
+
static type = '[Accessibilities] Get Category Details';
|
|
57
|
+
constructor(id) {
|
|
58
|
+
this.id = id;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class UpdateAccessibility {
|
|
62
|
+
id;
|
|
63
|
+
changes;
|
|
64
|
+
static type = '[Accessibilities] Update Accessibility';
|
|
65
|
+
constructor(id, changes) {
|
|
66
|
+
this.id = id;
|
|
67
|
+
this.changes = changes;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class GetGroups {
|
|
71
|
+
static type = '[Accessibilities] Get Groups';
|
|
72
|
+
}
|
|
73
|
+
class UpdateAccessibilities {
|
|
74
|
+
payload;
|
|
75
|
+
static type = '[Accessibilities] Update Accessibilities';
|
|
76
|
+
constructor(payload) {
|
|
77
|
+
this.payload = payload;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class AddGroupsToCategory {
|
|
81
|
+
categoryId;
|
|
82
|
+
payload;
|
|
83
|
+
static type = '[Accessibilities] Add Groups To Category';
|
|
84
|
+
constructor(categoryId, payload) {
|
|
85
|
+
this.categoryId = categoryId;
|
|
86
|
+
this.payload = payload;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class RemoveGroupFromCategory {
|
|
90
|
+
categoryId;
|
|
91
|
+
groupId;
|
|
92
|
+
static type = '[Accessibilities] Remove Group From Category';
|
|
93
|
+
constructor(categoryId, groupId) {
|
|
94
|
+
this.categoryId = categoryId;
|
|
95
|
+
this.groupId = groupId;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class GetLevelsTree {
|
|
99
|
+
static type = '[Accessibilities] Get Levels Tree';
|
|
100
|
+
}
|
|
101
|
+
class UpdateLevelsTreeForCategory {
|
|
102
|
+
categoryId;
|
|
103
|
+
payload;
|
|
104
|
+
static type = '[Accessibilities] Update Levels Tree For Category';
|
|
105
|
+
constructor(categoryId, payload) {
|
|
106
|
+
this.categoryId = categoryId;
|
|
107
|
+
this.payload = payload;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var AccessibilityActionKey;
|
|
112
|
+
(function (AccessibilityActionKey) {
|
|
113
|
+
AccessibilityActionKey["GetAccessibilities"] = "getAccessibilities";
|
|
114
|
+
AccessibilityActionKey["UpdateAccessibility"] = "updateAccessibility";
|
|
115
|
+
AccessibilityActionKey["UpdateAccessibilities"] = "updateAccessibilities";
|
|
116
|
+
AccessibilityActionKey["GetGroups"] = "getGroups";
|
|
117
|
+
AccessibilityActionKey["GetCategories"] = "getCategories";
|
|
118
|
+
AccessibilityActionKey["AddCategory"] = "addCategory";
|
|
119
|
+
AccessibilityActionKey["UpdateCategory"] = "updateCategory";
|
|
120
|
+
AccessibilityActionKey["DeleteCategory"] = "deleteCategory";
|
|
121
|
+
AccessibilityActionKey["GetCategoryDetails"] = "getCategoryDetails";
|
|
122
|
+
AccessibilityActionKey["AddGroupsToCategory"] = "addGroupsToCategory";
|
|
123
|
+
AccessibilityActionKey["RemoveGroupFromCategory"] = "removeGroupFromCategory";
|
|
124
|
+
AccessibilityActionKey["GetLevelsTree"] = "getLevelsTree";
|
|
125
|
+
AccessibilityActionKey["UpdateLevelsTreeForCategory"] = "updateLevelsTreeForCategory";
|
|
126
|
+
})(AccessibilityActionKey || (AccessibilityActionKey = {}));
|
|
127
|
+
|
|
128
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
129
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
130
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
131
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
132
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
133
|
+
};
|
|
134
|
+
let AccessibilitiesState = class AccessibilitiesState extends CrudStateBase {
|
|
135
|
+
http = inject(HttpClient);
|
|
136
|
+
baseUrl = 'identity/accessibilities';
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// Selectors - Individual data selectors for fine-grained reactivity
|
|
139
|
+
// ============================================================================
|
|
140
|
+
static getAccessibilities(state) {
|
|
141
|
+
return state.accessibilities;
|
|
142
|
+
}
|
|
143
|
+
static getSelectedAccessibility(state) {
|
|
144
|
+
return state.selectedAccessibility;
|
|
145
|
+
}
|
|
146
|
+
static getGroups(state) {
|
|
147
|
+
return state.groups;
|
|
148
|
+
}
|
|
149
|
+
static getCategories(state) {
|
|
150
|
+
return state.categories;
|
|
151
|
+
}
|
|
152
|
+
static getSelectedCategory(state) {
|
|
153
|
+
return state.selectedCategory;
|
|
154
|
+
}
|
|
155
|
+
static getLevelsTree(state) {
|
|
156
|
+
return state.levelsTree;
|
|
157
|
+
}
|
|
158
|
+
// ============================================================================
|
|
159
|
+
// Loading/Error Slice Selectors - REQUIRED for optimal performance
|
|
160
|
+
// ============================================================================
|
|
161
|
+
static getLoadingActive(state) {
|
|
162
|
+
return state.loadingActive;
|
|
163
|
+
}
|
|
164
|
+
static getErrors(state) {
|
|
165
|
+
return state.errors;
|
|
166
|
+
}
|
|
167
|
+
// -------- CRUD actions using enum keys --------
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// CRUD Actions
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// Loading Data - use handleApiRequest
|
|
172
|
+
getAccessibilities(ctx) {
|
|
173
|
+
const req$ = this.http.get(this.baseUrl);
|
|
174
|
+
return handleApiRequest({
|
|
175
|
+
ctx,
|
|
176
|
+
key: AccessibilityActionKey.GetAccessibilities,
|
|
177
|
+
request$: req$,
|
|
178
|
+
onSuccess: (response) => ({
|
|
179
|
+
accessibilities: response.data ?? [],
|
|
180
|
+
}),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
updateAccessibility(ctx, { id, changes }) {
|
|
184
|
+
const req$ = this.http.put(`${this.baseUrl}/${id}`, changes);
|
|
185
|
+
return handleApiRequest({
|
|
186
|
+
ctx,
|
|
187
|
+
key: AccessibilityActionKey.UpdateAccessibility,
|
|
188
|
+
request$: req$,
|
|
189
|
+
onSuccess: (response, state) => {
|
|
190
|
+
if (response.data) {
|
|
191
|
+
const updatedAccessibilities = state.accessibilities.map((a) => a.key === response.data.key ? response.data : a);
|
|
192
|
+
return {
|
|
193
|
+
accessibilities: updatedAccessibilities,
|
|
194
|
+
selectedAccessibility: response.data,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {};
|
|
198
|
+
},
|
|
199
|
+
errorMessage: 'Failed to update accessibility',
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
updateAccessibilities(ctx, { payload }) {
|
|
203
|
+
const req$ = this.http.put(`${this.baseUrl}/bulk/groups`, payload);
|
|
204
|
+
return handleApiRequest({
|
|
205
|
+
ctx,
|
|
206
|
+
key: AccessibilityActionKey.UpdateAccessibilities,
|
|
207
|
+
request$: req$,
|
|
208
|
+
onSuccess: (res, state) => {
|
|
209
|
+
if (!res.data || res.data.length === 0) {
|
|
210
|
+
return {};
|
|
211
|
+
}
|
|
212
|
+
const updatedAccessibilities = state.accessibilities.map((accessibility) => {
|
|
213
|
+
const updated = res.data.find((a) => a.key === accessibility.key);
|
|
214
|
+
return updated ?? accessibility;
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
accessibilities: updatedAccessibilities,
|
|
218
|
+
};
|
|
219
|
+
},
|
|
220
|
+
errorMessage: 'Failed to update accessibilities',
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
getGroups(ctx) {
|
|
224
|
+
const req$ = this.http.get('identity/groups');
|
|
225
|
+
return handleApiRequest({
|
|
226
|
+
ctx,
|
|
227
|
+
key: AccessibilityActionKey.GetGroups,
|
|
228
|
+
request$: req$,
|
|
229
|
+
onSuccess: (response) => ({
|
|
230
|
+
groups: response.data ?? [],
|
|
231
|
+
}),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
getCategories(ctx) {
|
|
235
|
+
const req$ = this.http.get('categories');
|
|
236
|
+
return handleApiRequest({
|
|
237
|
+
ctx,
|
|
238
|
+
key: AccessibilityActionKey.GetCategories,
|
|
239
|
+
request$: req$,
|
|
240
|
+
onSuccess: (response) => ({
|
|
241
|
+
categories: response.data ?? [],
|
|
242
|
+
}),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
addCategory(ctx, { payload }) {
|
|
246
|
+
const req$ = this.http.post('categories', payload);
|
|
247
|
+
return handleApiRequest({
|
|
248
|
+
ctx,
|
|
249
|
+
key: AccessibilityActionKey.AddCategory,
|
|
250
|
+
request$: req$,
|
|
251
|
+
onSuccess: (res, state) => ({
|
|
252
|
+
categories: res.data
|
|
253
|
+
? [...state.categories, res.data]
|
|
254
|
+
: state.categories,
|
|
255
|
+
}),
|
|
256
|
+
errorMessage: 'Failed to add category',
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
updateCategory(ctx, { id, payload }) {
|
|
260
|
+
const req$ = this.http.put(`categories/${id}`, payload);
|
|
261
|
+
return handleApiRequest({
|
|
262
|
+
ctx,
|
|
263
|
+
key: AccessibilityActionKey.UpdateCategory,
|
|
264
|
+
request$: req$,
|
|
265
|
+
onSuccess: (res, state) => {
|
|
266
|
+
if (res.data) {
|
|
267
|
+
const updatedCategories = state.categories.map((category) => category.id === id ? res.data : category);
|
|
268
|
+
return {
|
|
269
|
+
categories: updatedCategories,
|
|
270
|
+
selectedCategory: state.selectedCategory?.id === id
|
|
271
|
+
? res.data
|
|
272
|
+
: state.selectedCategory,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return {};
|
|
276
|
+
},
|
|
277
|
+
errorMessage: 'Failed to update category',
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
deleteCategory(ctx, { id }) {
|
|
281
|
+
const req$ = this.http.delete(`categories/${id}`);
|
|
282
|
+
return handleApiRequest({
|
|
283
|
+
ctx,
|
|
284
|
+
key: AccessibilityActionKey.DeleteCategory,
|
|
285
|
+
request$: req$,
|
|
286
|
+
onSuccess: (_res, state) => ({
|
|
287
|
+
categories: state.categories.filter((category) => category.id !== id),
|
|
288
|
+
selectedCategory: state.selectedCategory?.id === id ? null : state.selectedCategory,
|
|
289
|
+
}),
|
|
290
|
+
errorMessage: 'Failed to delete category',
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
getCategoryDetails(ctx, { id }) {
|
|
294
|
+
const req$ = this.http.get(`categories/${id}`);
|
|
295
|
+
return handleApiRequest({
|
|
296
|
+
ctx,
|
|
297
|
+
key: AccessibilityActionKey.GetCategoryDetails,
|
|
298
|
+
request$: req$,
|
|
299
|
+
onSuccess: (response) => ({
|
|
300
|
+
selectedCategory: response.data ?? null,
|
|
301
|
+
}),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
addGroupsToCategory(ctx, { categoryId, payload }) {
|
|
305
|
+
const req$ = this.http.post(`categories/${categoryId}/mapGroups`, payload);
|
|
306
|
+
return handleApiRequest({
|
|
307
|
+
ctx,
|
|
308
|
+
key: AccessibilityActionKey.AddGroupsToCategory,
|
|
309
|
+
request$: req$,
|
|
310
|
+
onSuccess: (_res, _state) => {
|
|
311
|
+
// Refresh category details to get updated groups
|
|
312
|
+
ctx.dispatch(new GetCategoryDetails(categoryId));
|
|
313
|
+
return {};
|
|
314
|
+
},
|
|
315
|
+
errorMessage: 'Failed to add groups to category',
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
removeGroupFromCategory(ctx, { categoryId, groupId }) {
|
|
319
|
+
const state = ctx.getState();
|
|
320
|
+
const currentGroups = state.selectedCategory?.groups ?? [];
|
|
321
|
+
const updatedGroupsIds = currentGroups
|
|
322
|
+
.filter((group) => group.groupId !== groupId)
|
|
323
|
+
.map((group) => group.groupId);
|
|
324
|
+
const req$ = this.http.post(`categories/${categoryId}/mapGroups`, { groupsIds: updatedGroupsIds });
|
|
325
|
+
return handleApiRequest({
|
|
326
|
+
ctx,
|
|
327
|
+
key: AccessibilityActionKey.RemoveGroupFromCategory,
|
|
328
|
+
request$: req$,
|
|
329
|
+
onSuccess: (_res, _state) => {
|
|
330
|
+
// Refresh category details to get updated groups
|
|
331
|
+
ctx.dispatch(new GetCategoryDetails(categoryId));
|
|
332
|
+
return {};
|
|
333
|
+
},
|
|
334
|
+
errorMessage: 'Failed to remove group from category',
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
getLevelsTree(ctx) {
|
|
338
|
+
const req$ = this.http.get('data/levels/tree');
|
|
339
|
+
return handleApiRequest({
|
|
340
|
+
ctx,
|
|
341
|
+
key: AccessibilityActionKey.GetLevelsTree,
|
|
342
|
+
request$: req$,
|
|
343
|
+
onSuccess: (response) => ({
|
|
344
|
+
levelsTree: response.data ?? [],
|
|
345
|
+
}),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
updateLevelsTreeForCategory(ctx, { categoryId, payload }) {
|
|
349
|
+
const req$ = this.http.post(`categories/${categoryId}/mapLevels`, payload);
|
|
350
|
+
return handleApiRequest({
|
|
351
|
+
ctx,
|
|
352
|
+
key: AccessibilityActionKey.UpdateLevelsTreeForCategory,
|
|
353
|
+
request$: req$,
|
|
354
|
+
onSuccess: (_res, _state) => ({}),
|
|
355
|
+
errorMessage: 'Failed to update levels tree for category',
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesState, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
359
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesState });
|
|
360
|
+
};
|
|
361
|
+
__decorate([
|
|
362
|
+
Action(GetAccessibilities)
|
|
363
|
+
], AccessibilitiesState.prototype, "getAccessibilities", null);
|
|
364
|
+
__decorate([
|
|
365
|
+
Action(UpdateAccessibility)
|
|
366
|
+
], AccessibilitiesState.prototype, "updateAccessibility", null);
|
|
367
|
+
__decorate([
|
|
368
|
+
Action(UpdateAccessibilities)
|
|
369
|
+
], AccessibilitiesState.prototype, "updateAccessibilities", null);
|
|
370
|
+
__decorate([
|
|
371
|
+
Action(GetGroups)
|
|
372
|
+
], AccessibilitiesState.prototype, "getGroups", null);
|
|
373
|
+
__decorate([
|
|
374
|
+
Action(GetCategories)
|
|
375
|
+
], AccessibilitiesState.prototype, "getCategories", null);
|
|
376
|
+
__decorate([
|
|
377
|
+
Action(AddCategory)
|
|
378
|
+
], AccessibilitiesState.prototype, "addCategory", null);
|
|
379
|
+
__decorate([
|
|
380
|
+
Action(UpdateCategory)
|
|
381
|
+
], AccessibilitiesState.prototype, "updateCategory", null);
|
|
382
|
+
__decorate([
|
|
383
|
+
Action(DeleteCategory)
|
|
384
|
+
], AccessibilitiesState.prototype, "deleteCategory", null);
|
|
385
|
+
__decorate([
|
|
386
|
+
Action(GetCategoryDetails)
|
|
387
|
+
], AccessibilitiesState.prototype, "getCategoryDetails", null);
|
|
388
|
+
__decorate([
|
|
389
|
+
Action(AddGroupsToCategory)
|
|
390
|
+
], AccessibilitiesState.prototype, "addGroupsToCategory", null);
|
|
391
|
+
__decorate([
|
|
392
|
+
Action(RemoveGroupFromCategory)
|
|
393
|
+
], AccessibilitiesState.prototype, "removeGroupFromCategory", null);
|
|
394
|
+
__decorate([
|
|
395
|
+
Action(GetLevelsTree)
|
|
396
|
+
], AccessibilitiesState.prototype, "getLevelsTree", null);
|
|
397
|
+
__decorate([
|
|
398
|
+
Action(UpdateLevelsTreeForCategory)
|
|
399
|
+
], AccessibilitiesState.prototype, "updateLevelsTreeForCategory", null);
|
|
400
|
+
__decorate([
|
|
401
|
+
Selector()
|
|
402
|
+
], AccessibilitiesState, "getAccessibilities", null);
|
|
403
|
+
__decorate([
|
|
404
|
+
Selector()
|
|
405
|
+
], AccessibilitiesState, "getSelectedAccessibility", null);
|
|
406
|
+
__decorate([
|
|
407
|
+
Selector()
|
|
408
|
+
], AccessibilitiesState, "getGroups", null);
|
|
409
|
+
__decorate([
|
|
410
|
+
Selector()
|
|
411
|
+
], AccessibilitiesState, "getCategories", null);
|
|
412
|
+
__decorate([
|
|
413
|
+
Selector()
|
|
414
|
+
], AccessibilitiesState, "getSelectedCategory", null);
|
|
415
|
+
__decorate([
|
|
416
|
+
Selector()
|
|
417
|
+
], AccessibilitiesState, "getLevelsTree", null);
|
|
418
|
+
__decorate([
|
|
419
|
+
Selector()
|
|
420
|
+
], AccessibilitiesState, "getLoadingActive", null);
|
|
421
|
+
__decorate([
|
|
422
|
+
Selector()
|
|
423
|
+
], AccessibilitiesState, "getErrors", null);
|
|
424
|
+
AccessibilitiesState = __decorate([
|
|
425
|
+
State({
|
|
426
|
+
name: 'accessibilities',
|
|
427
|
+
defaults: {
|
|
428
|
+
accessibilities: [],
|
|
429
|
+
selectedAccessibility: null,
|
|
430
|
+
groups: [],
|
|
431
|
+
categories: [],
|
|
432
|
+
selectedCategory: null,
|
|
433
|
+
levelsTree: [],
|
|
434
|
+
loadingActive: [],
|
|
435
|
+
errors: {},
|
|
436
|
+
},
|
|
437
|
+
})
|
|
438
|
+
], AccessibilitiesState);
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesState, decorators: [{
|
|
440
|
+
type: Injectable
|
|
441
|
+
}], propDecorators: { getAccessibilities: [], updateAccessibility: [], updateAccessibilities: [], getGroups: [], getCategories: [], addCategory: [], updateCategory: [], deleteCategory: [], getCategoryDetails: [], addGroupsToCategory: [], removeGroupFromCategory: [], getLevelsTree: [], updateLevelsTreeForCategory: [] } });
|
|
442
|
+
|
|
443
|
+
class AccessibilitiesFacade {
|
|
444
|
+
store = inject(Store);
|
|
445
|
+
// ============================================================================
|
|
446
|
+
// Data Selectors - Memoized by NGXS (fine-grained reactivity)
|
|
447
|
+
// ============================================================================
|
|
448
|
+
accessibilities = select(AccessibilitiesState.getAccessibilities);
|
|
449
|
+
selectedAccessibility = select(AccessibilitiesState.getSelectedAccessibility);
|
|
450
|
+
groups = select(AccessibilitiesState.getGroups);
|
|
451
|
+
categories = select(AccessibilitiesState.getCategories);
|
|
452
|
+
selectedCategory = select(AccessibilitiesState.getSelectedCategory);
|
|
453
|
+
levelsTree = select(AccessibilitiesState.getLevelsTree);
|
|
454
|
+
// ============================================================================
|
|
455
|
+
// Loading/Error Slices - Memoized by NGXS
|
|
456
|
+
// ============================================================================
|
|
457
|
+
loadingActive = select(AccessibilitiesState.getLoadingActive);
|
|
458
|
+
errors = select(AccessibilitiesState.getErrors);
|
|
459
|
+
// ============================================================================
|
|
460
|
+
// Loading Signals - Computed from slice (minimal reactivity)
|
|
461
|
+
// ============================================================================
|
|
462
|
+
isLoadingAccessibilities = computed(() => this.loadingActive().includes(AccessibilityActionKey.GetAccessibilities), ...(ngDevMode ? [{ debugName: "isLoadingAccessibilities" }] : []));
|
|
463
|
+
isUpdatingAccessibility = computed(() => this.loadingActive().includes(AccessibilityActionKey.UpdateAccessibility), ...(ngDevMode ? [{ debugName: "isUpdatingAccessibility" }] : []));
|
|
464
|
+
isUpdatingAccessibilities = computed(() => this.loadingActive().includes(AccessibilityActionKey.UpdateAccessibilities), ...(ngDevMode ? [{ debugName: "isUpdatingAccessibilities" }] : []));
|
|
465
|
+
isLoadingGroups = computed(() => this.loadingActive().includes(AccessibilityActionKey.GetGroups), ...(ngDevMode ? [{ debugName: "isLoadingGroups" }] : []));
|
|
466
|
+
isLoadingCategories = computed(() => this.loadingActive().includes(AccessibilityActionKey.GetCategories), ...(ngDevMode ? [{ debugName: "isLoadingCategories" }] : []));
|
|
467
|
+
isAddingCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.AddCategory), ...(ngDevMode ? [{ debugName: "isAddingCategory" }] : []));
|
|
468
|
+
isUpdatingCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.UpdateCategory), ...(ngDevMode ? [{ debugName: "isUpdatingCategory" }] : []));
|
|
469
|
+
isDeletingCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.DeleteCategory), ...(ngDevMode ? [{ debugName: "isDeletingCategory" }] : []));
|
|
470
|
+
isLoadingCategoryDetails = computed(() => this.loadingActive().includes(AccessibilityActionKey.GetCategoryDetails), ...(ngDevMode ? [{ debugName: "isLoadingCategoryDetails" }] : []));
|
|
471
|
+
isAddingGroupsToCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.AddGroupsToCategory), ...(ngDevMode ? [{ debugName: "isAddingGroupsToCategory" }] : []));
|
|
472
|
+
isRemovingGroupFromCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.RemoveGroupFromCategory), ...(ngDevMode ? [{ debugName: "isRemovingGroupFromCategory" }] : []));
|
|
473
|
+
isLoadingLevelsTree = computed(() => this.loadingActive().includes(AccessibilityActionKey.GetLevelsTree), ...(ngDevMode ? [{ debugName: "isLoadingLevelsTree" }] : []));
|
|
474
|
+
isUpdatingLevelsTreeForCategory = computed(() => this.loadingActive().includes(AccessibilityActionKey.UpdateLevelsTreeForCategory), ...(ngDevMode ? [{ debugName: "isUpdatingLevelsTreeForCategory" }] : []));
|
|
475
|
+
// ============================================================================
|
|
476
|
+
// Error Signals - Computed from slice (minimal reactivity)
|
|
477
|
+
// ============================================================================
|
|
478
|
+
accessibilitiesError = computed(() => this.errors()[AccessibilityActionKey.GetAccessibilities] ?? null, ...(ngDevMode ? [{ debugName: "accessibilitiesError" }] : []));
|
|
479
|
+
updateAccessibilityError = computed(() => this.errors()[AccessibilityActionKey.UpdateAccessibility] ?? null, ...(ngDevMode ? [{ debugName: "updateAccessibilityError" }] : []));
|
|
480
|
+
updateAccessibilitiesError = computed(() => this.errors()[AccessibilityActionKey.UpdateAccessibilities] ?? null, ...(ngDevMode ? [{ debugName: "updateAccessibilitiesError" }] : []));
|
|
481
|
+
groupsError = computed(() => this.errors()[AccessibilityActionKey.GetGroups] ?? null, ...(ngDevMode ? [{ debugName: "groupsError" }] : []));
|
|
482
|
+
categoriesError = computed(() => this.errors()[AccessibilityActionKey.GetCategories] ?? null, ...(ngDevMode ? [{ debugName: "categoriesError" }] : []));
|
|
483
|
+
addCategoryError = computed(() => this.errors()[AccessibilityActionKey.AddCategory] ?? null, ...(ngDevMode ? [{ debugName: "addCategoryError" }] : []));
|
|
484
|
+
updateCategoryError = computed(() => this.errors()[AccessibilityActionKey.UpdateCategory] ?? null, ...(ngDevMode ? [{ debugName: "updateCategoryError" }] : []));
|
|
485
|
+
deleteCategoryError = computed(() => this.errors()[AccessibilityActionKey.DeleteCategory] ?? null, ...(ngDevMode ? [{ debugName: "deleteCategoryError" }] : []));
|
|
486
|
+
getCategoryDetailsError = computed(() => this.errors()[AccessibilityActionKey.GetCategoryDetails] ?? null, ...(ngDevMode ? [{ debugName: "getCategoryDetailsError" }] : []));
|
|
487
|
+
addGroupsToCategoryError = computed(() => this.errors()[AccessibilityActionKey.AddGroupsToCategory] ?? null, ...(ngDevMode ? [{ debugName: "addGroupsToCategoryError" }] : []));
|
|
488
|
+
removeGroupFromCategoryError = computed(() => this.errors()[AccessibilityActionKey.RemoveGroupFromCategory] ?? null, ...(ngDevMode ? [{ debugName: "removeGroupFromCategoryError" }] : []));
|
|
489
|
+
getLevelsTreeError = computed(() => this.errors()[AccessibilityActionKey.GetLevelsTree] ?? null, ...(ngDevMode ? [{ debugName: "getLevelsTreeError" }] : []));
|
|
490
|
+
updateLevelsTreeForCategoryError = computed(() => this.errors()[AccessibilityActionKey.UpdateLevelsTreeForCategory] ?? null, ...(ngDevMode ? [{ debugName: "updateLevelsTreeForCategoryError" }] : []));
|
|
491
|
+
// ============================================================================
|
|
492
|
+
// Derived Data - Computed from data selectors
|
|
493
|
+
// ============================================================================
|
|
494
|
+
categoriesCount = computed(() => this.categories().length, ...(ngDevMode ? [{ debugName: "categoriesCount" }] : []));
|
|
495
|
+
hasCategories = computed(() => this.categories().length > 0, ...(ngDevMode ? [{ debugName: "hasCategories" }] : []));
|
|
496
|
+
groupsCount = computed(() => this.groups().length, ...(ngDevMode ? [{ debugName: "groupsCount" }] : []));
|
|
497
|
+
hasGroups = computed(() => this.groups().length > 0, ...(ngDevMode ? [{ debugName: "hasGroups" }] : []));
|
|
498
|
+
// ============================================================================
|
|
499
|
+
// Action Dispatchers
|
|
500
|
+
// ============================================================================
|
|
501
|
+
// Actions
|
|
502
|
+
getAccessibilities() {
|
|
503
|
+
return this.store.dispatch(new GetAccessibilities());
|
|
504
|
+
}
|
|
505
|
+
updateAccessibility(key, changes) {
|
|
506
|
+
return this.store.dispatch(new UpdateAccessibility(key, changes));
|
|
507
|
+
}
|
|
508
|
+
getGroups() {
|
|
509
|
+
return this.store.dispatch(new GetGroups());
|
|
510
|
+
}
|
|
511
|
+
updateAccessibilities(payload) {
|
|
512
|
+
return this.store.dispatch(new UpdateAccessibilities(payload));
|
|
513
|
+
}
|
|
514
|
+
getCategories() {
|
|
515
|
+
return this.store.dispatch(new GetCategories());
|
|
516
|
+
}
|
|
517
|
+
addCategory(payload) {
|
|
518
|
+
return this.store.dispatch(new AddCategory(payload));
|
|
519
|
+
}
|
|
520
|
+
updateCategory(id, payload) {
|
|
521
|
+
return this.store.dispatch(new UpdateCategory(id, payload));
|
|
522
|
+
}
|
|
523
|
+
deleteCategory(id) {
|
|
524
|
+
return this.store.dispatch(new DeleteCategory(id));
|
|
525
|
+
}
|
|
526
|
+
getCategoryDetails(id) {
|
|
527
|
+
return this.store.dispatch(new GetCategoryDetails(id));
|
|
528
|
+
}
|
|
529
|
+
addGroupsToCategory(categoryId, groupsIds) {
|
|
530
|
+
return this.store.dispatch(new AddGroupsToCategory(categoryId, { groupsIds }));
|
|
531
|
+
}
|
|
532
|
+
removeGroupFromCategory(categoryId, groupId) {
|
|
533
|
+
return this.store.dispatch(new RemoveGroupFromCategory(categoryId, groupId));
|
|
534
|
+
}
|
|
535
|
+
getLevelsTree() {
|
|
536
|
+
return this.store.dispatch(new GetLevelsTree());
|
|
537
|
+
}
|
|
538
|
+
updateLevelsTreeForCategory(categoryId, keys) {
|
|
539
|
+
return this.store.dispatch(new UpdateLevelsTreeForCategory(categoryId, { levelDataIds: keys }));
|
|
540
|
+
}
|
|
541
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesFacade, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
542
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesFacade, providedIn: 'root' });
|
|
543
|
+
}
|
|
544
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesFacade, decorators: [{
|
|
545
|
+
type: Injectable,
|
|
546
|
+
args: [{ providedIn: 'root' }]
|
|
547
|
+
}] });
|
|
548
|
+
|
|
549
|
+
class Accessibilities {
|
|
550
|
+
facade = inject(AccessibilitiesFacade);
|
|
551
|
+
route = inject(ActivatedRoute);
|
|
552
|
+
router = inject(Router);
|
|
553
|
+
translocoService = inject(TranslocoService);
|
|
554
|
+
selectedTab = signal('accessibilities', ...(ngDevMode ? [{ debugName: "selectedTab" }] : []));
|
|
555
|
+
tabsList = [
|
|
556
|
+
{
|
|
557
|
+
label: this.translocoService.translate('accessibilities.accessibilities'),
|
|
558
|
+
value: 'accessibilities',
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
label: this.translocoService.translate('accessibilities.categories'),
|
|
562
|
+
value: 'categories',
|
|
563
|
+
},
|
|
564
|
+
];
|
|
565
|
+
breadcrumbItems = [
|
|
566
|
+
{
|
|
567
|
+
label: '',
|
|
568
|
+
icon: 'general.home-line',
|
|
569
|
+
routerLink: '/control-panel/workspaces',
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
label: this.translocoService.translate('product-settings.product-settings'),
|
|
573
|
+
routerLink: '/control-panel/product-settings',
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
label: this.translocoService.translate('accessibilities.accessibilities'),
|
|
577
|
+
},
|
|
578
|
+
];
|
|
579
|
+
ngOnInit() {
|
|
580
|
+
const selectedTab = this.route.snapshot.firstChild?.data['componentType'];
|
|
581
|
+
this.selectedTab.set(selectedTab || 'accessibilities');
|
|
582
|
+
this.facade.getAccessibilities();
|
|
583
|
+
this.facade.getGroups();
|
|
584
|
+
this.facade.getCategories();
|
|
585
|
+
this.facade.getLevelsTree();
|
|
586
|
+
}
|
|
587
|
+
goBack() {
|
|
588
|
+
this.router.navigate(['control-panel/product-settings']);
|
|
589
|
+
}
|
|
590
|
+
onTabChange(event) {
|
|
591
|
+
if (event == 'accessibilities') {
|
|
592
|
+
this.router.navigate(['accessibilities-list'], {
|
|
593
|
+
relativeTo: this.route,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
else if (event == 'categories') {
|
|
597
|
+
this.router.navigate(['categories'], { relativeTo: this.route });
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Accessibilities, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
601
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.3", type: Accessibilities, isStandalone: true, selector: "mt-accessibilities", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <mt-page\r\n [title]=\"t('accessibilities')\"\r\n [avatarIcon]=\"'security.passcode-lock'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-pink-50)',\r\n '--p-avatar-color': 'var(--p-pink-700)',\r\n }\"\r\n [tabs]=\"tabsList\"\r\n [activeTab]=\"selectedTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Page, selector: "mt-page", inputs: ["backButton", "backButtonIcon", "avatarIcon", "avatarStyle", "avatarShape", "title", "tabs", "activeTab", "contentClass", "contentId"], outputs: ["backButtonClick", "tabChange"] }, { kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
|
|
602
|
+
}
|
|
603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Accessibilities, decorators: [{
|
|
604
|
+
type: Component,
|
|
605
|
+
args: [{ selector: 'mt-accessibilities', standalone: true, imports: [CommonModule, Page, RouterOutlet, TranslocoDirective], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <mt-page\r\n [title]=\"t('accessibilities')\"\r\n [avatarIcon]=\"'security.passcode-lock'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-pink-50)',\r\n '--p-avatar-color': 'var(--p-pink-700)',\r\n }\"\r\n [tabs]=\"tabsList\"\r\n [activeTab]=\"selectedTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n" }]
|
|
606
|
+
}] });
|
|
607
|
+
|
|
608
|
+
class AccessibilityPermissionsEditModal {
|
|
609
|
+
modal = inject(ModalService);
|
|
610
|
+
ref = inject(ModalRef);
|
|
611
|
+
accessibilitiesFacade = inject(AccessibilitiesFacade);
|
|
612
|
+
confirmationService = inject(ConfirmationService);
|
|
613
|
+
accessibility = input(null, ...(ngDevMode ? [{ debugName: "accessibility" }] : []));
|
|
614
|
+
groups = this.accessibilitiesFacade.groups;
|
|
615
|
+
saveLoading = this.accessibilitiesFacade.isUpdatingAccessibilities;
|
|
616
|
+
selectedGroups = signal({}, ...(ngDevMode ? [{ debugName: "selectedGroups" }] : []));
|
|
617
|
+
getAvailableGroupsOptions = computed(() => (settingId) => {
|
|
618
|
+
const selectedIds = this.selectedGroups()[settingId] || [];
|
|
619
|
+
return this.groups()
|
|
620
|
+
.filter((group) => !selectedIds.includes(group.id))
|
|
621
|
+
.map((group) => ({
|
|
622
|
+
label: group.name,
|
|
623
|
+
value: group.id,
|
|
624
|
+
}));
|
|
625
|
+
}, ...(ngDevMode ? [{ debugName: "getAvailableGroupsOptions" }] : []));
|
|
626
|
+
ngOnInit() {
|
|
627
|
+
const initialSelectedGroups = {};
|
|
628
|
+
this.accessibility()?.settings?.forEach((setting) => {
|
|
629
|
+
initialSelectedGroups[setting.id] = setting.groups.map((g) => g.id);
|
|
630
|
+
});
|
|
631
|
+
this.selectedGroups.set(initialSelectedGroups);
|
|
632
|
+
}
|
|
633
|
+
onClose() {
|
|
634
|
+
this.ref.close();
|
|
635
|
+
}
|
|
636
|
+
onSave() {
|
|
637
|
+
const selectedGroups = this.selectedGroups();
|
|
638
|
+
const permissions = this.accessibility()?.settings || [];
|
|
639
|
+
const accessibilitiesData = permissions.map((setting) => ({
|
|
640
|
+
AccessibilityId: setting.id,
|
|
641
|
+
Groups: selectedGroups[setting.id] || [],
|
|
642
|
+
}));
|
|
643
|
+
const payload = {
|
|
644
|
+
Accessibilities: accessibilitiesData,
|
|
645
|
+
};
|
|
646
|
+
this.accessibilitiesFacade.updateAccessibilities(payload).subscribe({
|
|
647
|
+
next: () => {
|
|
648
|
+
this.ref.close();
|
|
649
|
+
},
|
|
650
|
+
error: (error) => {
|
|
651
|
+
console.error('Failed to save accessibility permissions:', error);
|
|
652
|
+
},
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
onGroupSelectionChange(settingId, selectedGroupIds) {
|
|
656
|
+
this.selectedGroups.update((current) => ({
|
|
657
|
+
...current,
|
|
658
|
+
[settingId]: selectedGroupIds,
|
|
659
|
+
}));
|
|
660
|
+
}
|
|
661
|
+
onGroupSelect(settingId, groupId) {
|
|
662
|
+
if (!groupId)
|
|
663
|
+
return;
|
|
664
|
+
const currentGroups = this.selectedGroups()[settingId] || [];
|
|
665
|
+
if (!currentGroups.includes(groupId)) {
|
|
666
|
+
const updatedGroups = [...currentGroups, groupId];
|
|
667
|
+
this.onGroupSelectionChange(settingId, updatedGroups);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
getSelectedGroupsForSetting(settingId) {
|
|
671
|
+
const selectedIds = this.selectedGroups()[settingId] || [];
|
|
672
|
+
return this.groups().filter((group) => selectedIds.includes(group.id));
|
|
673
|
+
}
|
|
674
|
+
removeGroupFromSetting(event, settingId, groupId) {
|
|
675
|
+
event.stopPropagation();
|
|
676
|
+
this.confirmationService.confirmDelete({
|
|
677
|
+
event: event,
|
|
678
|
+
type: 'popup',
|
|
679
|
+
accept: () => {
|
|
680
|
+
const currentGroups = this.selectedGroups()[settingId] || [];
|
|
681
|
+
const updatedGroups = currentGroups.filter((id) => id !== groupId);
|
|
682
|
+
this.onGroupSelectionChange(settingId, updatedGroups);
|
|
683
|
+
},
|
|
684
|
+
reject: () => { },
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilityPermissionsEditModal, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
688
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: AccessibilityPermissionsEditModal, isStandalone: true, selector: "mt-accessibility-permissions-edit-modal", inputs: { accessibility: { classPropertyName: "accessibility", publicName: "accessibility", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t\">\r\n <div [class]=\"'flex flex-col gap-4 p-4 ' + modal.contentClass\">\r\n @if (accessibility()) {\r\n <div class=\"space-y-4\">\r\n @for (setting of this.accessibility()?.settings; track setting.id) {\r\n <div class=\"border border-gray-200 rounded-lg overflow-hidden\">\r\n <div class=\"bg-sky-50 px-4 py-3 border-b border-gray-200\">\r\n <h4 class=\"font-medium text-gray-900\">{{ setting.keyName }}</h4>\r\n </div>\r\n\r\n <div class=\"p-4\">\r\n <div class=\"mb-3\">\r\n <mt-select-field\r\n [placeholder]=\"t('accessibilities.selectGroupsPlaceholder')\"\r\n [options]=\"getAvailableGroupsOptions()(setting.id)\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [ngModel]=\"null\"\r\n (ngModelChange)=\"onGroupSelect(setting.id, $event)\"\r\n class=\"w-full\"\r\n >\r\n </mt-select-field>\r\n </div>\r\n\r\n @if (getSelectedGroupsForSetting(setting.id).length > 0) {\r\n <div class=\"mt-4\">\r\n <h5 class=\"text-sm font-medium text-gray-700 mb-2\">\r\n {{ t(\"accessibilities.selectedGroups\") }}\r\n </h5>\r\n <div class=\"space-y-2\">\r\n @for (\r\n group of getSelectedGroupsForSetting(setting.id);\r\n track group.id\r\n ) {\r\n <div\r\n class=\"flex items-center justify-between bg-gray-50 px-3 py-2 rounded-lg border border-gray-100\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <mt-avatar [icon]=\"'user.users-01'\" shape=\"square\">\r\n </mt-avatar>\r\n <span class=\"text-sm font-medium\">{{\r\n group.name\r\n }}</span>\r\n </div>\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"\r\n removeGroupFromSetting($event, setting.id, group.id)\r\n \"\r\n title=\"Remove Group\"\r\n >\r\n </mt-button>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"text-center text-gray-500 py-8 bg-gray-50 rounded-lg\">\r\n <p>{{ \"no-data-found\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('save')\"\r\n (click)=\"onSave()\"\r\n [loading]=\"saveLoading()\"\r\n severity=\"primary\"\r\n />\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n severity=\"secondary\"\r\n [disabled]=\"saveLoading()\"\r\n (click)=\"onClose()\"\r\n />\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading"], outputs: ["onChange"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "ngmodule", type: FormsModule }, { 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: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
689
|
+
}
|
|
690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilityPermissionsEditModal, decorators: [{
|
|
691
|
+
type: Component,
|
|
692
|
+
args: [{ selector: 'mt-accessibility-permissions-edit-modal', standalone: true, imports: [
|
|
693
|
+
CommonModule,
|
|
694
|
+
Button,
|
|
695
|
+
SelectField,
|
|
696
|
+
Avatar,
|
|
697
|
+
FormsModule,
|
|
698
|
+
TranslocoDirective,
|
|
699
|
+
TranslocoPipe,
|
|
700
|
+
], template: "<ng-container *transloco=\"let t\">\r\n <div [class]=\"'flex flex-col gap-4 p-4 ' + modal.contentClass\">\r\n @if (accessibility()) {\r\n <div class=\"space-y-4\">\r\n @for (setting of this.accessibility()?.settings; track setting.id) {\r\n <div class=\"border border-gray-200 rounded-lg overflow-hidden\">\r\n <div class=\"bg-sky-50 px-4 py-3 border-b border-gray-200\">\r\n <h4 class=\"font-medium text-gray-900\">{{ setting.keyName }}</h4>\r\n </div>\r\n\r\n <div class=\"p-4\">\r\n <div class=\"mb-3\">\r\n <mt-select-field\r\n [placeholder]=\"t('accessibilities.selectGroupsPlaceholder')\"\r\n [options]=\"getAvailableGroupsOptions()(setting.id)\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n [ngModel]=\"null\"\r\n (ngModelChange)=\"onGroupSelect(setting.id, $event)\"\r\n class=\"w-full\"\r\n >\r\n </mt-select-field>\r\n </div>\r\n\r\n @if (getSelectedGroupsForSetting(setting.id).length > 0) {\r\n <div class=\"mt-4\">\r\n <h5 class=\"text-sm font-medium text-gray-700 mb-2\">\r\n {{ t(\"accessibilities.selectedGroups\") }}\r\n </h5>\r\n <div class=\"space-y-2\">\r\n @for (\r\n group of getSelectedGroupsForSetting(setting.id);\r\n track group.id\r\n ) {\r\n <div\r\n class=\"flex items-center justify-between bg-gray-50 px-3 py-2 rounded-lg border border-gray-100\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <mt-avatar [icon]=\"'user.users-01'\" shape=\"square\">\r\n </mt-avatar>\r\n <span class=\"text-sm font-medium\">{{\r\n group.name\r\n }}</span>\r\n </div>\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"\r\n removeGroupFromSetting($event, setting.id, group.id)\r\n \"\r\n title=\"Remove Group\"\r\n >\r\n </mt-button>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"text-center text-gray-500 py-8 bg-gray-50 rounded-lg\">\r\n <p>{{ \"no-data-found\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('save')\"\r\n (click)=\"onSave()\"\r\n [loading]=\"saveLoading()\"\r\n severity=\"primary\"\r\n />\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n severity=\"secondary\"\r\n [disabled]=\"saveLoading()\"\r\n (click)=\"onClose()\"\r\n />\r\n </div>\r\n</ng-container>\r\n" }]
|
|
701
|
+
}], propDecorators: { accessibility: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessibility", required: false }] }] } });
|
|
702
|
+
|
|
703
|
+
// store/index.ts
|
|
704
|
+
|
|
705
|
+
class AccessibilitiesList {
|
|
706
|
+
modal = inject(ModalService);
|
|
707
|
+
accessibilitiesFacade = inject(AccessibilitiesFacade);
|
|
708
|
+
translocoService = inject(TranslocoService);
|
|
709
|
+
confirmationService = inject(ConfirmationService);
|
|
710
|
+
accessibilities = this.accessibilitiesFacade.accessibilities;
|
|
711
|
+
isLoading = this.accessibilitiesFacade.isLoadingAccessibilities;
|
|
712
|
+
itemDeletedId = signal(null, ...(ngDevMode ? [{ debugName: "itemDeletedId" }] : []));
|
|
713
|
+
openPermissionsModal(accessibility) {
|
|
714
|
+
this.modal.openModal(AccessibilityPermissionsEditModal, 'drawer', {
|
|
715
|
+
header: this.translocoService.translate('accessibilities.setPermissions'),
|
|
716
|
+
styleClass: '!w-[30vw] !absolute !shadow-none',
|
|
717
|
+
height: '100%',
|
|
718
|
+
position: 'end',
|
|
719
|
+
appendTo: 'page-content',
|
|
720
|
+
dismissible: true,
|
|
721
|
+
inputValues: {
|
|
722
|
+
accessibility: accessibility,
|
|
723
|
+
},
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
727
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: AccessibilitiesList, isStandalone: true, selector: "mt-accessibilities-list", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <mt-card class=\"w-250 my-5 mx-auto\">\r\n <div class=\"flex flex-col\">\r\n <ng-template #headless>\r\n <div class=\"p-5 mb-5 border-b border-surface\">\r\n <h2 class=\"text-lg font-semibold m-0\">\r\n {{ t(\"system-accessibilities\") }}\r\n </h2>\r\n </div>\r\n @if (isLoading()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n <div class=\"overflow-auto\">\r\n @for (accessibility of accessibilities(); track accessibility.key) {\r\n <div\r\n class=\"mb-5 p-2 mx-5 rounded-lg border-1 border-surface flex items-center justify-between\"\r\n >\r\n <div class=\"flex items-center gap-3\">\r\n <mt-avatar\r\n [icon]=\"'security.lock-unlocked-01'\"\r\n shape=\"square\"\r\n size=\"normal\"\r\n [style.--p-avatar-background]=\"\r\n 'var(--p-' + 'surface' + '-100)'\r\n \"\r\n [style.--p-avatar-color]=\"'var(--p-' + 'primary' + '-600)'\"\r\n >\r\n </mt-avatar>\r\n <div>\r\n <div class=\"font-semibold\">{{ accessibility.name }}</div>\r\n </div>\r\n </div>\r\n <div class=\"flex items-center\">\r\n <div\r\n class=\"py-1 px-3 mx-4 text-sm font-semibold rounded-lg border-1 border-surface\"\r\n >\r\n {{ accessibility.groupsCounts }} {{ t(\"groups\") }}\r\n </div>\r\n <div class=\"border-surface border-s-1 px-1\">\r\n <mt-button\r\n [text]=\"true\"\r\n icon=\"security.lock-unlocked-01\"\r\n severity=\"primary\"\r\n (click)=\"openPermissionsModal(accessibility)\"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div\r\n class=\"flex items-center justify-center mt-20 text-muted-color\"\r\n >\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n </div>\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1$1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
728
|
+
}
|
|
729
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesList, decorators: [{
|
|
730
|
+
type: Component,
|
|
731
|
+
args: [{ selector: 'mt-accessibilities-list', standalone: true, imports: [
|
|
732
|
+
CommonModule,
|
|
733
|
+
TranslocoDirective,
|
|
734
|
+
Avatar,
|
|
735
|
+
Card,
|
|
736
|
+
Button,
|
|
737
|
+
SkeletonModule,
|
|
738
|
+
TranslocoPipe,
|
|
739
|
+
], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <mt-card class=\"w-250 my-5 mx-auto\">\r\n <div class=\"flex flex-col\">\r\n <ng-template #headless>\r\n <div class=\"p-5 mb-5 border-b border-surface\">\r\n <h2 class=\"text-lg font-semibold m-0\">\r\n {{ t(\"system-accessibilities\") }}\r\n </h2>\r\n </div>\r\n @if (isLoading()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n <div class=\"overflow-auto\">\r\n @for (accessibility of accessibilities(); track accessibility.key) {\r\n <div\r\n class=\"mb-5 p-2 mx-5 rounded-lg border-1 border-surface flex items-center justify-between\"\r\n >\r\n <div class=\"flex items-center gap-3\">\r\n <mt-avatar\r\n [icon]=\"'security.lock-unlocked-01'\"\r\n shape=\"square\"\r\n size=\"normal\"\r\n [style.--p-avatar-background]=\"\r\n 'var(--p-' + 'surface' + '-100)'\r\n \"\r\n [style.--p-avatar-color]=\"'var(--p-' + 'primary' + '-600)'\"\r\n >\r\n </mt-avatar>\r\n <div>\r\n <div class=\"font-semibold\">{{ accessibility.name }}</div>\r\n </div>\r\n </div>\r\n <div class=\"flex items-center\">\r\n <div\r\n class=\"py-1 px-3 mx-4 text-sm font-semibold rounded-lg border-1 border-surface\"\r\n >\r\n {{ accessibility.groupsCounts }} {{ t(\"groups\") }}\r\n </div>\r\n <div class=\"border-surface border-s-1 px-1\">\r\n <mt-button\r\n [text]=\"true\"\r\n icon=\"security.lock-unlocked-01\"\r\n severity=\"primary\"\r\n (click)=\"openPermissionsModal(accessibility)\"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div\r\n class=\"flex items-center justify-center mt-20 text-muted-color\"\r\n >\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n </div>\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n</ng-container>\r\n" }]
|
|
740
|
+
}] });
|
|
741
|
+
|
|
742
|
+
class AddCategoryModal {
|
|
743
|
+
modal = inject(ModalService);
|
|
744
|
+
ref = inject(ModalRef);
|
|
745
|
+
facade = inject(AccessibilitiesFacade);
|
|
746
|
+
translocoService = inject(TranslocoService);
|
|
747
|
+
// Input for edit mode - receives category with rawName
|
|
748
|
+
category = input(null, ...(ngDevMode ? [{ debugName: "category" }] : []));
|
|
749
|
+
categoryFormControl = new FormControl(null);
|
|
750
|
+
dynamicFormConfig = linkedSignal(() => ({
|
|
751
|
+
sections: [
|
|
752
|
+
{
|
|
753
|
+
key: '',
|
|
754
|
+
label: '',
|
|
755
|
+
type: 'header',
|
|
756
|
+
order: 1,
|
|
757
|
+
fields: [
|
|
758
|
+
{
|
|
759
|
+
key: 'name.en',
|
|
760
|
+
label: this.translocoService.translate('accessibilities.category-title-en'),
|
|
761
|
+
placeholder: this.translocoService.translate('accessibilities.category-title-en'),
|
|
762
|
+
validators: [ValidatorConfig.required()],
|
|
763
|
+
order: 1,
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
key: 'name.ar',
|
|
767
|
+
label: this.translocoService.translate('accessibilities.category-title-ar'),
|
|
768
|
+
placeholder: this.translocoService.translate('accessibilities.category-title-ar'),
|
|
769
|
+
validators: [ValidatorConfig.required()],
|
|
770
|
+
order: 1,
|
|
771
|
+
},
|
|
772
|
+
],
|
|
773
|
+
},
|
|
774
|
+
],
|
|
775
|
+
}), ...(ngDevMode ? [{ debugName: "dynamicFormConfig" }] : []));
|
|
776
|
+
isAddingCategory = this.facade.isAddingCategory;
|
|
777
|
+
isUpdatingCategory = this.facade.isUpdatingCategory;
|
|
778
|
+
constructor() {
|
|
779
|
+
// Initialize form with category data if in edit mode
|
|
780
|
+
effect(() => {
|
|
781
|
+
const cat = this.category();
|
|
782
|
+
if (cat?.rawName) {
|
|
783
|
+
this.categoryFormControl.patchValue({
|
|
784
|
+
name: {
|
|
785
|
+
en: cat.rawName.en,
|
|
786
|
+
ar: cat.rawName.ar,
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
onSubmit() {
|
|
793
|
+
if (this.categoryFormControl.invalid)
|
|
794
|
+
return;
|
|
795
|
+
const formValue = this.categoryFormControl.getRawValue();
|
|
796
|
+
const cat = this.category();
|
|
797
|
+
// Check if we're in edit mode
|
|
798
|
+
if (cat?.id) {
|
|
799
|
+
this.facade.updateCategory(cat.id, formValue).subscribe({
|
|
800
|
+
next: () => {
|
|
801
|
+
this.ref.close(true);
|
|
802
|
+
},
|
|
803
|
+
error: () => { },
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
this.facade.addCategory(formValue).subscribe({
|
|
808
|
+
next: () => {
|
|
809
|
+
this.ref.close(true);
|
|
810
|
+
},
|
|
811
|
+
error: () => { },
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
onCancel() {
|
|
816
|
+
this.ref.close(false);
|
|
817
|
+
}
|
|
818
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AddCategoryModal, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
819
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.3", type: AddCategoryModal, isStandalone: true, selector: "mt-add-category-modal", inputs: { category: { classPropertyName: "category", publicName: "category", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div [class]=\"'flex flex-col gap-3 p-4 ' + modal.contentClass\">\r\n <mt-dynamic-form\r\n [formConfig]=\"dynamicFormConfig()\"\r\n [formControl]=\"categoryFormControl\"\r\n />\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button variant=\"outlined\" [label]=\"t('cancel')\" (click)=\"onCancel()\" />\r\n\r\n <mt-button\r\n [label]=\"'add' | transloco\"\r\n (click)=\"onSubmit()\"\r\n [loading]=\"isAddingCategory() || isUpdatingCategory()\"\r\n [disabled]=\"!this.categoryFormControl.valid\"\r\n />\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
820
|
+
}
|
|
821
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AddCategoryModal, decorators: [{
|
|
822
|
+
type: Component,
|
|
823
|
+
args: [{ selector: 'mt-add-category-modal', standalone: true, imports: [
|
|
824
|
+
CommonModule,
|
|
825
|
+
Button,
|
|
826
|
+
SkeletonModule,
|
|
827
|
+
DynamicForm,
|
|
828
|
+
ReactiveFormsModule,
|
|
829
|
+
TranslocoDirective,
|
|
830
|
+
TranslocoPipe,
|
|
831
|
+
], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div [class]=\"'flex flex-col gap-3 p-4 ' + modal.contentClass\">\r\n <mt-dynamic-form\r\n [formConfig]=\"dynamicFormConfig()\"\r\n [formControl]=\"categoryFormControl\"\r\n />\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button variant=\"outlined\" [label]=\"t('cancel')\" (click)=\"onCancel()\" />\r\n\r\n <mt-button\r\n [label]=\"'add' | transloco\"\r\n (click)=\"onSubmit()\"\r\n [loading]=\"isAddingCategory() || isUpdatingCategory()\"\r\n [disabled]=\"!this.categoryFormControl.valid\"\r\n />\r\n </div>\r\n</ng-container>\r\n" }]
|
|
832
|
+
}], ctorParameters: () => [], propDecorators: { category: [{ type: i0.Input, args: [{ isSignal: true, alias: "category", required: false }] }] } });
|
|
833
|
+
|
|
834
|
+
class CategoryGroups {
|
|
835
|
+
accessibilitiesFacade = inject(AccessibilitiesFacade);
|
|
836
|
+
confirmationService = inject(ConfirmationService);
|
|
837
|
+
groupSelectControl = input.required(...(ngDevMode ? [{ debugName: "groupSelectControl" }] : []));
|
|
838
|
+
availableGroups = input.required(...(ngDevMode ? [{ debugName: "availableGroups" }] : []));
|
|
839
|
+
categoryGroups = input.required(...(ngDevMode ? [{ debugName: "categoryGroups" }] : []));
|
|
840
|
+
selectedCategoryId = input.required(...(ngDevMode ? [{ debugName: "selectedCategoryId" }] : []));
|
|
841
|
+
isLoadingCategoryDetails = input.required(...(ngDevMode ? [{ debugName: "isLoadingCategoryDetails" }] : []));
|
|
842
|
+
isAddingGroupsToCategory = this.accessibilitiesFacade.isAddingGroupsToCategory;
|
|
843
|
+
isRemovingGroupFromCategory = this.accessibilitiesFacade.isRemovingGroupFromCategory;
|
|
844
|
+
groupDeletedId = signal(null, ...(ngDevMode ? [{ debugName: "groupDeletedId" }] : []));
|
|
845
|
+
onDeleteGroup(event, groupId) {
|
|
846
|
+
event.stopPropagation();
|
|
847
|
+
const categoryId = this.selectedCategoryId();
|
|
848
|
+
if (!categoryId)
|
|
849
|
+
return;
|
|
850
|
+
this.confirmationService.confirmDelete({
|
|
851
|
+
event: event,
|
|
852
|
+
type: 'popup',
|
|
853
|
+
accept: () => {
|
|
854
|
+
this.groupDeletedId.set(groupId);
|
|
855
|
+
this.accessibilitiesFacade
|
|
856
|
+
.removeGroupFromCategory(categoryId, groupId)
|
|
857
|
+
.subscribe({
|
|
858
|
+
complete: () => this.groupDeletedId.set(null),
|
|
859
|
+
error: () => this.groupDeletedId.set(null),
|
|
860
|
+
});
|
|
861
|
+
},
|
|
862
|
+
reject: () => { },
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
onAddGroupToCategory() {
|
|
866
|
+
const selectedGroupId = this.groupSelectControl().value;
|
|
867
|
+
const categoryId = this.selectedCategoryId();
|
|
868
|
+
if (selectedGroupId && categoryId) {
|
|
869
|
+
const currentGroups = this.categoryGroups();
|
|
870
|
+
const currentGroupIds = currentGroups.map((g) => g.groupId);
|
|
871
|
+
const updatedGroupIds = [...currentGroupIds, selectedGroupId];
|
|
872
|
+
this.accessibilitiesFacade
|
|
873
|
+
.addGroupsToCategory(categoryId, updatedGroupIds)
|
|
874
|
+
.subscribe(() => {
|
|
875
|
+
this.groupSelectControl().setValue(null);
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: CategoryGroups, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
880
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: CategoryGroups, isStandalone: true, selector: "mt-category-groups", inputs: { groupSelectControl: { classPropertyName: "groupSelectControl", publicName: "groupSelectControl", isSignal: true, isRequired: true, transformFunction: null }, availableGroups: { classPropertyName: "availableGroups", publicName: "availableGroups", isSignal: true, isRequired: true, transformFunction: null }, categoryGroups: { classPropertyName: "categoryGroups", publicName: "categoryGroups", isSignal: true, isRequired: true, transformFunction: null }, selectedCategoryId: { classPropertyName: "selectedCategoryId", publicName: "selectedCategoryId", isSignal: true, isRequired: true, transformFunction: null }, isLoadingCategoryDetails: { classPropertyName: "isLoadingCategoryDetails", publicName: "isLoadingCategoryDetails", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"p-4\">\r\n <!-- Group Selection Section -->\r\n <div class=\"flex gap-3 items-end\">\r\n <div class=\"w-[50%]\">\r\n <mt-select-field\r\n [formControl]=\"groupSelectControl()\"\r\n [label]=\"t('groups')\"\r\n [options]=\"availableGroups()\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n >\r\n </mt-select-field>\r\n </div>\r\n <mt-button\r\n icon=\"general.plus\"\r\n [label]=\"t('add-group')\"\r\n (click)=\"onAddGroupToCategory()\"\r\n [disabled]=\"!groupSelectControl().value || !selectedCategoryId()\"\r\n [loading]=\"isAddingGroupsToCategory()\"\r\n >\r\n </mt-button>\r\n </div>\r\n\r\n <div class=\"mt-6\">\r\n @if (isLoadingCategoryDetails()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n @for (group of categoryGroups(); track group.id) {\r\n <div\r\n class=\"flex my-3 items-center border rounded-lg p-1 px-6 border-surface\"\r\n >\r\n <div class=\"text-lg w-[30%]\">{{ group.name }}</div>\r\n <div class=\"text-md w-[30%]\">\r\n {{ group.usersCount }} {{ t(\"users\") }}\r\n </div>\r\n <div class=\"flex items-center gap-0 ms-auto\">\r\n <!-- <mt-button variant=\"text\" size=\"large\" icon=\"user.users-03\">\r\n </mt-button> -->\r\n <mt-button\r\n variant=\"text\"\r\n size=\"large\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"onDeleteGroup($event, group.groupId)\"\r\n [loading]=\"\r\n isRemovingGroupFromCategory() &&\r\n groupDeletedId() === group.groupId\r\n \"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"flex items-center justify-center h-20 text-muted-color\">\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n }\r\n </div>\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading"], outputs: ["onChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1$1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
881
|
+
}
|
|
882
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: CategoryGroups, decorators: [{
|
|
883
|
+
type: Component,
|
|
884
|
+
args: [{ selector: 'mt-category-groups', standalone: true, imports: [
|
|
885
|
+
CommonModule,
|
|
886
|
+
TranslocoDirective,
|
|
887
|
+
TranslocoPipe,
|
|
888
|
+
Button,
|
|
889
|
+
SelectField,
|
|
890
|
+
FormsModule,
|
|
891
|
+
ReactiveFormsModule,
|
|
892
|
+
SkeletonModule,
|
|
893
|
+
], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"p-4\">\r\n <!-- Group Selection Section -->\r\n <div class=\"flex gap-3 items-end\">\r\n <div class=\"w-[50%]\">\r\n <mt-select-field\r\n [formControl]=\"groupSelectControl()\"\r\n [label]=\"t('groups')\"\r\n [options]=\"availableGroups()\"\r\n optionLabel=\"name\"\r\n optionValue=\"id\"\r\n >\r\n </mt-select-field>\r\n </div>\r\n <mt-button\r\n icon=\"general.plus\"\r\n [label]=\"t('add-group')\"\r\n (click)=\"onAddGroupToCategory()\"\r\n [disabled]=\"!groupSelectControl().value || !selectedCategoryId()\"\r\n [loading]=\"isAddingGroupsToCategory()\"\r\n >\r\n </mt-button>\r\n </div>\r\n\r\n <div class=\"mt-6\">\r\n @if (isLoadingCategoryDetails()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n @for (group of categoryGroups(); track group.id) {\r\n <div\r\n class=\"flex my-3 items-center border rounded-lg p-1 px-6 border-surface\"\r\n >\r\n <div class=\"text-lg w-[30%]\">{{ group.name }}</div>\r\n <div class=\"text-md w-[30%]\">\r\n {{ group.usersCount }} {{ t(\"users\") }}\r\n </div>\r\n <div class=\"flex items-center gap-0 ms-auto\">\r\n <!-- <mt-button variant=\"text\" size=\"large\" icon=\"user.users-03\">\r\n </mt-button> -->\r\n <mt-button\r\n variant=\"text\"\r\n size=\"large\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"onDeleteGroup($event, group.groupId)\"\r\n [loading]=\"\r\n isRemovingGroupFromCategory() &&\r\n groupDeletedId() === group.groupId\r\n \"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"flex items-center justify-center h-20 text-muted-color\">\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n }\r\n </div>\r\n </div>\r\n</ng-container>\r\n" }]
|
|
894
|
+
}], propDecorators: { groupSelectControl: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupSelectControl", required: true }] }], availableGroups: [{ type: i0.Input, args: [{ isSignal: true, alias: "availableGroups", required: true }] }], categoryGroups: [{ type: i0.Input, args: [{ isSignal: true, alias: "categoryGroups", required: true }] }], selectedCategoryId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedCategoryId", required: true }] }], isLoadingCategoryDetails: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLoadingCategoryDetails", required: true }] }] } });
|
|
895
|
+
|
|
896
|
+
class CategoryElements {
|
|
897
|
+
accessibilitiesFacade = inject(AccessibilitiesFacade);
|
|
898
|
+
selectedCategoryId = input.required(...(ngDevMode ? [{ debugName: "selectedCategoryId" }] : []));
|
|
899
|
+
categoryLevels = model(...(ngDevMode ? [undefined, { debugName: "categoryLevels" }] : []));
|
|
900
|
+
nodes = computed(() => {
|
|
901
|
+
const tree = this.accessibilitiesFacade.levelsTree();
|
|
902
|
+
return this.transformTreeNodes(tree);
|
|
903
|
+
}, ...(ngDevMode ? [{ debugName: "nodes" }] : []));
|
|
904
|
+
isLoadingTree = this.accessibilitiesFacade.isLoadingLevelsTree;
|
|
905
|
+
isLoadingCategoryDetails = this.accessibilitiesFacade.isLoadingCategoryDetails;
|
|
906
|
+
selection = model(null, ...(ngDevMode ? [{ debugName: "selection" }] : []));
|
|
907
|
+
constructor() {
|
|
908
|
+
effect(() => {
|
|
909
|
+
const selectedLevels = this.categoryLevels();
|
|
910
|
+
if (selectedLevels?.length) {
|
|
911
|
+
const selection = selectedLevels.map((level) => {
|
|
912
|
+
return { key: level.groupId.toString() };
|
|
913
|
+
});
|
|
914
|
+
this.selection.set(selection);
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
this.selection.set([]);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
onTreeAction(event) {
|
|
922
|
+
switch (event.action) {
|
|
923
|
+
case 'selectionChange':
|
|
924
|
+
const selection = this.selection();
|
|
925
|
+
const categoryId = this.selectedCategoryId();
|
|
926
|
+
if (categoryId && selection) {
|
|
927
|
+
const keys = this.extractKeys(selection);
|
|
928
|
+
if (keys.length > 0) {
|
|
929
|
+
this.accessibilitiesFacade.updateLevelsTreeForCategory(categoryId, keys);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
extractKeys(selection) {
|
|
936
|
+
if (selection?.length) {
|
|
937
|
+
return (selection?.map((node) => node.key).filter((id) => !!id) || []);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
return [];
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
transformTreeNodes(nodes) {
|
|
944
|
+
if (!nodes || !Array.isArray(nodes))
|
|
945
|
+
return [];
|
|
946
|
+
return nodes.map((node) => ({
|
|
947
|
+
...node,
|
|
948
|
+
label: node.name,
|
|
949
|
+
icon: node?.level.icon || 'file.folder',
|
|
950
|
+
key: node.id.toString(),
|
|
951
|
+
children: node.children
|
|
952
|
+
? this.transformTreeNodes(node.children)
|
|
953
|
+
: undefined,
|
|
954
|
+
}));
|
|
955
|
+
}
|
|
956
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: CategoryElements, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
957
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.3", type: CategoryElements, isStandalone: true, selector: "mt-category-elements", inputs: { selectedCategoryId: { classPropertyName: "selectedCategoryId", publicName: "selectedCategoryId", isSignal: true, isRequired: true, transformFunction: null }, categoryLevels: { classPropertyName: "categoryLevels", publicName: "categoryLevels", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { categoryLevels: "categoryLevelsChange", selection: "selectionChange" }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"p-4\">\r\n <mt-tree\r\n [value]=\"nodes()\"\r\n [(selection)]=\"selection\"\r\n selectionMode=\"checkbox\"\r\n [loading]=\"isLoadingTree() || isLoadingCategoryDetails()\"\r\n (action)=\"onTreeAction($event)\"\r\n [checkAllChildren]=\"true\"\r\n />\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Tree, selector: "mt-tree", inputs: ["value", "selection", "selectionMode", "nodeIcon", "propagateSelectionUp", "propagateSelectionDown", "checkAllChildren", "loading", "emptyMessage", "checkAllLabel", "filterPlaceholder", "dataKey", "filter", "filterMode", "styleClass", "style", "pInputs", "nodeActions", "nodeContextmenuActions", "contextMenuSelection"], outputs: ["selectionChange", "contextMenuSelectionChange", "action"] }] });
|
|
958
|
+
}
|
|
959
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: CategoryElements, decorators: [{
|
|
960
|
+
type: Component,
|
|
961
|
+
args: [{ selector: 'mt-category-elements', standalone: true, imports: [CommonModule, TranslocoDirective, Tree], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"p-4\">\r\n <mt-tree\r\n [value]=\"nodes()\"\r\n [(selection)]=\"selection\"\r\n selectionMode=\"checkbox\"\r\n [loading]=\"isLoadingTree() || isLoadingCategoryDetails()\"\r\n (action)=\"onTreeAction($event)\"\r\n [checkAllChildren]=\"true\"\r\n />\r\n </div>\r\n</ng-container>\r\n" }]
|
|
962
|
+
}], ctorParameters: () => [], propDecorators: { selectedCategoryId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedCategoryId", required: true }] }], categoryLevels: [{ type: i0.Input, args: [{ isSignal: true, alias: "categoryLevels", required: false }] }, { type: i0.Output, args: ["categoryLevelsChange"] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }] } });
|
|
963
|
+
|
|
964
|
+
class AccessibilitiesCategories {
|
|
965
|
+
accessibilitiesFacade = inject(AccessibilitiesFacade);
|
|
966
|
+
modalService = inject(ModalService);
|
|
967
|
+
confirmationService = inject(ConfirmationService);
|
|
968
|
+
router = inject(Router);
|
|
969
|
+
route = inject(ActivatedRoute);
|
|
970
|
+
translocoService = inject(TranslocoService);
|
|
971
|
+
isLoading = this.accessibilitiesFacade.isLoadingGroups;
|
|
972
|
+
groups = this.accessibilitiesFacade.groups;
|
|
973
|
+
categories = this.accessibilitiesFacade.categories;
|
|
974
|
+
isLoadingCategories = this.accessibilitiesFacade.isLoadingCategories;
|
|
975
|
+
isDeletingCategory = this.accessibilitiesFacade.isDeletingCategory;
|
|
976
|
+
selectedCategory = this.accessibilitiesFacade.selectedCategory;
|
|
977
|
+
isLoadingCategoryDetails = this.accessibilitiesFacade.isLoadingCategoryDetails;
|
|
978
|
+
isUpdatingCategory = this.accessibilitiesFacade.isUpdatingCategory;
|
|
979
|
+
selectedCategoryId = signal(null, ...(ngDevMode ? [{ debugName: "selectedCategoryId" }] : []));
|
|
980
|
+
categoryDeletedId = signal(null, ...(ngDevMode ? [{ debugName: "categoryDeletedId" }] : []));
|
|
981
|
+
categoryEditedId = signal(null, ...(ngDevMode ? [{ debugName: "categoryEditedId" }] : []));
|
|
982
|
+
groupDeletedId = signal(null, ...(ngDevMode ? [{ debugName: "groupDeletedId" }] : []));
|
|
983
|
+
groupSelectControl = new FormControl(null);
|
|
984
|
+
availableGroups = computed(() => {
|
|
985
|
+
const allGroups = this.groups();
|
|
986
|
+
const selectedCategoryGroups = this.selectedCategory()?.groups || [];
|
|
987
|
+
const selectedGroupIds = selectedCategoryGroups.map((g) => g.groupId);
|
|
988
|
+
return allGroups.filter((group) => !selectedGroupIds.includes(group.id));
|
|
989
|
+
}, ...(ngDevMode ? [{ debugName: "availableGroups" }] : []));
|
|
990
|
+
categoryGroups = computed(() => {
|
|
991
|
+
return this.selectedCategory()?.groups || [];
|
|
992
|
+
}, ...(ngDevMode ? [{ debugName: "categoryGroups" }] : []));
|
|
993
|
+
categoryLevels = computed(() => {
|
|
994
|
+
return this.selectedCategory()?.levels || [];
|
|
995
|
+
}, ...(ngDevMode ? [{ debugName: "categoryLevels" }] : []));
|
|
996
|
+
selectedTab = signal('elements', ...(ngDevMode ? [{ debugName: "selectedTab" }] : []));
|
|
997
|
+
tabsList = [
|
|
998
|
+
{
|
|
999
|
+
label: this.translocoService.translate('accessibilities.elements'),
|
|
1000
|
+
value: 'elements',
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
label: this.translocoService.translate('accessibilities.groups'),
|
|
1004
|
+
value: 'groups',
|
|
1005
|
+
},
|
|
1006
|
+
];
|
|
1007
|
+
constructor() {
|
|
1008
|
+
effect(() => {
|
|
1009
|
+
const categories = this.categories();
|
|
1010
|
+
const routeId = this.route.snapshot.params['id'];
|
|
1011
|
+
const categoryId = routeId ? +routeId : null;
|
|
1012
|
+
if (categories && categories.length > 0) {
|
|
1013
|
+
if (categoryId && categories.find((c) => c.id === categoryId)) {
|
|
1014
|
+
if (this.selectedCategoryId() !== categoryId) {
|
|
1015
|
+
this.selectedCategoryId.set(categoryId);
|
|
1016
|
+
this.accessibilitiesFacade.getCategoryDetails(categoryId);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
else if (!this.selectedCategoryId()) {
|
|
1020
|
+
const firstCategoryId = categories[0].id;
|
|
1021
|
+
this.selectedCategoryId.set(firstCategoryId);
|
|
1022
|
+
this.router.navigate([firstCategoryId], {
|
|
1023
|
+
relativeTo: this.route,
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
onAddCategory() {
|
|
1030
|
+
this.modalService
|
|
1031
|
+
.openModal(AddCategoryModal, 'dialog', {
|
|
1032
|
+
header: this.translocoService.translate('accessibilities.add-new-category'),
|
|
1033
|
+
width: '500px',
|
|
1034
|
+
styleClass: '!absolute !shadow-none',
|
|
1035
|
+
position: '',
|
|
1036
|
+
appendTo: 'body',
|
|
1037
|
+
dismissableMask: true,
|
|
1038
|
+
dismissible: true,
|
|
1039
|
+
})
|
|
1040
|
+
.onClose.subscribe((result) => {
|
|
1041
|
+
if (result) {
|
|
1042
|
+
// this.accessibilitiesFacade.getCategories();
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
onEditCategory(event, category) {
|
|
1047
|
+
event.stopPropagation();
|
|
1048
|
+
this.categoryEditedId.set(category.id);
|
|
1049
|
+
this.modalService
|
|
1050
|
+
.openModal(AddCategoryModal, 'dialog', {
|
|
1051
|
+
header: this.translocoService.translate('accessibilities.edit-category'),
|
|
1052
|
+
width: '500px',
|
|
1053
|
+
dismissableMask: true,
|
|
1054
|
+
inputValues: {
|
|
1055
|
+
category: category,
|
|
1056
|
+
},
|
|
1057
|
+
})
|
|
1058
|
+
.onClose.subscribe((result) => {
|
|
1059
|
+
this.categoryEditedId.set(null);
|
|
1060
|
+
if (result) {
|
|
1061
|
+
// this.accessibilitiesFacade.getCategories();
|
|
1062
|
+
// // Refresh category details if currently selected
|
|
1063
|
+
// if (this.selectedCategoryId() === category.id) {
|
|
1064
|
+
// this.accessibilitiesFacade.getCategoryDetails(category.id);
|
|
1065
|
+
// }
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
onDeleteCategory(event, categoryId) {
|
|
1070
|
+
event.stopPropagation();
|
|
1071
|
+
this.confirmationService.confirmDelete({
|
|
1072
|
+
event: event,
|
|
1073
|
+
type: 'popup',
|
|
1074
|
+
accept: () => {
|
|
1075
|
+
this.categoryDeletedId.set(categoryId);
|
|
1076
|
+
this.accessibilitiesFacade.deleteCategory(categoryId).subscribe({
|
|
1077
|
+
next: () => {
|
|
1078
|
+
this.categoryDeletedId.set(null);
|
|
1079
|
+
if (this.selectedCategoryId() === categoryId) {
|
|
1080
|
+
this.selectedCategoryId.set(null);
|
|
1081
|
+
this.router.navigate(['../'], { relativeTo: this.route });
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
error: () => {
|
|
1085
|
+
this.categoryDeletedId.set(null);
|
|
1086
|
+
},
|
|
1087
|
+
});
|
|
1088
|
+
},
|
|
1089
|
+
reject: () => { },
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
onCategoryClick(categoryId) {
|
|
1093
|
+
this.selectedCategoryId.set(categoryId);
|
|
1094
|
+
this.accessibilitiesFacade.getCategoryDetails(categoryId);
|
|
1095
|
+
this.router.navigate(['../', categoryId], { relativeTo: this.route });
|
|
1096
|
+
}
|
|
1097
|
+
isCategorySelected(categoryId) {
|
|
1098
|
+
return this.selectedCategoryId() === categoryId;
|
|
1099
|
+
}
|
|
1100
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesCategories, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1101
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: AccessibilitiesCategories, isStandalone: true, selector: "mt-accessibilities-categories", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"flex gap-7\">\r\n <mt-card class=\"h-full w-[20%] mt-4\">\r\n <div class=\"flex flex-col h-full\">\r\n <ng-template #headless>\r\n <div\r\n class=\"p-5 mb-5 border-b border-surface flex justify-between items-center\"\r\n >\r\n <h2 class=\"text-lg font-semibold m-0\">{{ t(\"categories\") }}</h2>\r\n </div>\r\n @if (isLoadingCategories()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-col gap-3 mb-4 overflow-auto\">\r\n @for (category of categories(); track category.id) {\r\n <div\r\n class=\"p-2 mx-4 border-1 border-gray-300 rounded-lg cursor-pointer transition-colors flex items-center gap-3\"\r\n [class.bg-primary-50]=\"isCategorySelected(category.id)\"\r\n [class.border-primary-400]=\"isCategorySelected(category.id)\"\r\n [style.--p-avatar-background]=\"\r\n isCategorySelected(category.id)\r\n ? 'var(--p-primary-color)'\r\n : 'var(--p-surface-100)'\r\n \"\r\n [style.--p-avatar-color]=\"\r\n isCategorySelected(category.id) ? '#ffffff' : ''\r\n \"\r\n (click)=\"onCategoryClick(category.id)\"\r\n >\r\n <mt-avatar [icon]=\"'user.user-check-01'\" shape=\"square\">\r\n </mt-avatar>\r\n <div class=\"flex-1 min-w-0\">\r\n <div class=\"font-medium truncate\">{{ category.name }}</div>\r\n </div>\r\n <div class=\"flex\">\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"editor.pencil-01\"\r\n severity=\"primary\"\r\n (click)=\"onEditCategory($event, category)\"\r\n [loading]=\"\r\n isUpdatingCategory() &&\r\n categoryEditedId() === category.id\r\n \"\r\n >\r\n </mt-button>\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"onDeleteCategory($event, category.id)\"\r\n [loading]=\"\r\n isDeletingCategory() &&\r\n categoryDeletedId() === category.id\r\n \"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div\r\n class=\"flex items-center justify-center h-12 text-muted-color\"\r\n >\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n <div class=\"mx-4 mt-2\">\r\n <mt-button\r\n icon=\"general.plus\"\r\n (click)=\"onAddCategory()\"\r\n [label]=\"t('add-category')\"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n <mt-card class=\"h-full w-[80%] mt-4\">\r\n <div class=\"flex flex-col h-full\">\r\n <ng-template #headless>\r\n <div class=\"p-5 mb-5 border-b border-surface\">\r\n <h2 class=\"text-lg font-semibold m-0\">\r\n {{ t(\"category-relations\") }}\r\n </h2>\r\n </div>\r\n\r\n <div class=\"px-5 mb-4\">\r\n <mt-tabs [(active)]=\"selectedTab\" [options]=\"tabsList\" size=\"small\">\r\n </mt-tabs>\r\n </div>\r\n\r\n @if (selectedTab() === \"elements\") {\r\n <mt-category-elements\r\n [selectedCategoryId]=\"selectedCategoryId()\"\r\n [categoryLevels]=\"categoryLevels()\"\r\n />\r\n } @else if (selectedTab() === \"groups\") {\r\n <mt-category-groups\r\n [groupSelectControl]=\"groupSelectControl\"\r\n [availableGroups]=\"availableGroups()\"\r\n [categoryGroups]=\"categoryGroups()\"\r\n [selectedCategoryId]=\"selectedCategoryId()\"\r\n [isLoadingCategoryDetails]=\"isLoadingCategoryDetails()\"\r\n />\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1$1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Tabs, selector: "mt-tabs", inputs: ["options", "optionLabel", "optionValue", "active", "size", "fluid", "disabled"], outputs: ["activeChange", "onChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: CategoryGroups, selector: "mt-category-groups", inputs: ["groupSelectControl", "availableGroups", "categoryGroups", "selectedCategoryId", "isLoadingCategoryDetails"] }, { kind: "component", type: CategoryElements, selector: "mt-category-elements", inputs: ["selectedCategoryId", "categoryLevels", "selection"], outputs: ["categoryLevelsChange", "selectionChange"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
1102
|
+
}
|
|
1103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: AccessibilitiesCategories, decorators: [{
|
|
1104
|
+
type: Component,
|
|
1105
|
+
args: [{ selector: 'mt-accessibilities-categories', standalone: true, imports: [
|
|
1106
|
+
CommonModule,
|
|
1107
|
+
TranslocoDirective,
|
|
1108
|
+
Avatar,
|
|
1109
|
+
Card,
|
|
1110
|
+
SkeletonModule,
|
|
1111
|
+
Button,
|
|
1112
|
+
Tabs,
|
|
1113
|
+
FormsModule,
|
|
1114
|
+
ReactiveFormsModule,
|
|
1115
|
+
TranslocoPipe,
|
|
1116
|
+
CategoryGroups,
|
|
1117
|
+
CategoryElements,
|
|
1118
|
+
], template: "<ng-container *transloco=\"let t; prefix: 'accessibilities'\">\r\n <div class=\"flex gap-7\">\r\n <mt-card class=\"h-full w-[20%] mt-4\">\r\n <div class=\"flex flex-col h-full\">\r\n <ng-template #headless>\r\n <div\r\n class=\"p-5 mb-5 border-b border-surface flex justify-between items-center\"\r\n >\r\n <h2 class=\"text-lg font-semibold m-0\">{{ t(\"categories\") }}</h2>\r\n </div>\r\n @if (isLoadingCategories()) {\r\n <div class=\"space-y-4 p-4\">\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n <p-skeleton height=\"4rem\" />\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-col gap-3 mb-4 overflow-auto\">\r\n @for (category of categories(); track category.id) {\r\n <div\r\n class=\"p-2 mx-4 border-1 border-gray-300 rounded-lg cursor-pointer transition-colors flex items-center gap-3\"\r\n [class.bg-primary-50]=\"isCategorySelected(category.id)\"\r\n [class.border-primary-400]=\"isCategorySelected(category.id)\"\r\n [style.--p-avatar-background]=\"\r\n isCategorySelected(category.id)\r\n ? 'var(--p-primary-color)'\r\n : 'var(--p-surface-100)'\r\n \"\r\n [style.--p-avatar-color]=\"\r\n isCategorySelected(category.id) ? '#ffffff' : ''\r\n \"\r\n (click)=\"onCategoryClick(category.id)\"\r\n >\r\n <mt-avatar [icon]=\"'user.user-check-01'\" shape=\"square\">\r\n </mt-avatar>\r\n <div class=\"flex-1 min-w-0\">\r\n <div class=\"font-medium truncate\">{{ category.name }}</div>\r\n </div>\r\n <div class=\"flex\">\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"editor.pencil-01\"\r\n severity=\"primary\"\r\n (click)=\"onEditCategory($event, category)\"\r\n [loading]=\"\r\n isUpdatingCategory() &&\r\n categoryEditedId() === category.id\r\n \"\r\n >\r\n </mt-button>\r\n <mt-button\r\n variant=\"text\"\r\n size=\"small\"\r\n icon=\"general.trash-01\"\r\n severity=\"danger\"\r\n (click)=\"onDeleteCategory($event, category.id)\"\r\n [loading]=\"\r\n isDeletingCategory() &&\r\n categoryDeletedId() === category.id\r\n \"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n } @empty {\r\n <div\r\n class=\"flex items-center justify-center h-12 text-muted-color\"\r\n >\r\n {{ \"no-data-found\" | transloco }}\r\n </div>\r\n }\r\n <div class=\"mx-4 mt-2\">\r\n <mt-button\r\n icon=\"general.plus\"\r\n (click)=\"onAddCategory()\"\r\n [label]=\"t('add-category')\"\r\n >\r\n </mt-button>\r\n </div>\r\n </div>\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n <mt-card class=\"h-full w-[80%] mt-4\">\r\n <div class=\"flex flex-col h-full\">\r\n <ng-template #headless>\r\n <div class=\"p-5 mb-5 border-b border-surface\">\r\n <h2 class=\"text-lg font-semibold m-0\">\r\n {{ t(\"category-relations\") }}\r\n </h2>\r\n </div>\r\n\r\n <div class=\"px-5 mb-4\">\r\n <mt-tabs [(active)]=\"selectedTab\" [options]=\"tabsList\" size=\"small\">\r\n </mt-tabs>\r\n </div>\r\n\r\n @if (selectedTab() === \"elements\") {\r\n <mt-category-elements\r\n [selectedCategoryId]=\"selectedCategoryId()\"\r\n [categoryLevels]=\"categoryLevels()\"\r\n />\r\n } @else if (selectedTab() === \"groups\") {\r\n <mt-category-groups\r\n [groupSelectControl]=\"groupSelectControl\"\r\n [availableGroups]=\"availableGroups()\"\r\n [categoryGroups]=\"categoryGroups()\"\r\n [selectedCategoryId]=\"selectedCategoryId()\"\r\n [isLoadingCategoryDetails]=\"isLoadingCategoryDetails()\"\r\n />\r\n }\r\n </ng-template>\r\n </div>\r\n </mt-card>\r\n </div>\r\n</ng-container>\r\n" }]
|
|
1119
|
+
}], ctorParameters: () => [] });
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Generated bundle index. Do not edit.
|
|
1123
|
+
*/
|
|
1124
|
+
|
|
1125
|
+
export { Accessibilities, AccessibilitiesCategories, AccessibilitiesFacade, AccessibilitiesList, AccessibilitiesState, AccessibilityActionKey, AddCategory, AddGroupsToCategory, DeleteCategory, GetAccessibilities, GetCategories, GetCategoryDetails, GetGroups, GetLevelsTree, RemoveGroupFromCategory, UpdateAccessibilities, UpdateAccessibility, UpdateCategory, UpdateLevelsTreeForCategory };
|
|
1126
|
+
//# sourceMappingURL=masterteam-accessibilities.mjs.map
|