@unifylib/ui-lib 1.2.15 → 1.2.17
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/cli/client-app-component-guide.md +166 -166
- package/cli/generators/dashboard.js +147 -147
- package/cli/generators/form-screen.js +95 -95
- package/cli/generators/line-editor.js +110 -110
- package/cli/generators/permission-matrix.js +115 -115
- package/cli/generators/section-form.js +103 -103
- package/cli/generators/table-screen.js +181 -181
- package/cli/index.js +185 -185
- package/cli/utils.js +228 -228
- package/esm2022/iq-ui-lib.mjs +5 -0
- package/esm2022/lib/base-model/SearchStrConfig.mjs +1 -1
- package/esm2022/lib/base-model/api-response.mjs +1 -1
- package/esm2022/lib/base-model/audit-log-entry.mjs +1 -1
- package/esm2022/lib/base-model/button-action-settings.mjs +1 -1
- package/esm2022/lib/base-model/column-def.model.mjs +1 -1
- package/esm2022/lib/base-model/do-action-request.mjs +1 -1
- package/esm2022/lib/base-model/field-action.mjs +1 -1
- package/esm2022/lib/base-model/field-filter.model.mjs +1 -1
- package/esm2022/lib/base-model/field-info.mjs +1 -1
- package/esm2022/lib/base-model/field-predicate.model.mjs +1 -1
- package/esm2022/lib/base-model/filter-request.mjs +1 -1
- package/esm2022/lib/base-model/filter.model.mjs +1 -1
- package/esm2022/lib/base-model/get-items-list.mjs +1 -1
- package/esm2022/lib/base-model/index.mjs +1 -1
- package/esm2022/lib/base-model/items-total.model.mjs +1 -1
- package/esm2022/lib/base-model/line-item.model.mjs +1 -1
- package/esm2022/lib/base-model/lookupItem.mjs +1 -1
- package/esm2022/lib/base-model/page-info.mjs +1 -1
- package/esm2022/lib/base-model/permission-matrix.model.mjs +1 -1
- package/esm2022/lib/base-model/report-request.model.mjs +1 -1
- package/esm2022/lib/base-model/response-envelop.model.mjs +1 -1
- package/esm2022/lib/base-model/snack-message.model.mjs +1 -1
- package/esm2022/lib/base-model/table-column.interface.mjs +1 -1
- package/esm2022/lib/base-model/table-page-user-action.interface.mjs +1 -1
- package/esm2022/lib/base-model/workflow/workflow-steps.model.mjs +1 -1
- package/esm2022/lib/base-model/workflow/workflow.model.mjs +1 -1
- package/esm2022/lib/components/action-comment/action-comment.component.mjs +3 -3
- package/esm2022/lib/components/action-confirmation/action-confirmation.component.mjs +3 -3
- package/esm2022/lib/components/activity-report-form/activity-report-form.component.mjs +3 -3
- package/esm2022/lib/components/advanced-filter/field-filter/field-filter.component.mjs +3 -3
- package/esm2022/lib/components/advanced-filter/filter-builder/filter-builder.component.mjs +3 -3
- package/esm2022/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.mjs +3 -3
- package/esm2022/lib/components/auto-complete/auto-complete.component.mjs +3 -3
- package/esm2022/lib/components/base-form/base-form.component.mjs +3 -3
- package/esm2022/lib/components/base-form-canvas/MaxDigitsDirective.mjs +1 -1
- package/esm2022/lib/components/base-form-canvas/NumbersOnlyDirective.mjs +1 -1
- package/esm2022/lib/components/base-form-canvas/base-form-canvas.component.mjs +3 -3
- package/esm2022/lib/components/base-input-dialog/base-input-dialog.component.mjs +3 -3
- package/esm2022/lib/components/base-table/base-table.component.mjs +3 -3
- package/esm2022/lib/components/button-actions/button-actions.component.mjs +3 -3
- package/esm2022/lib/components/editable-base-table/editable-base-table.component.mjs +3 -3
- package/esm2022/lib/components/equation-builder/equation-builder.component.mjs +3 -3
- package/esm2022/lib/components/item-line-editor/item-line-editor.component.mjs +3 -3
- package/esm2022/lib/components/multi-auto-complete/multi-auto-complete.component.mjs +3 -3
- package/esm2022/lib/components/paginator/paginator.component.mjs +3 -3
- package/esm2022/lib/components/permission-matrix/permission-matrix.component.mjs +3 -3
- package/esm2022/lib/components/report-details-dialog/report-details-dialog.component.mjs +3 -3
- package/esm2022/lib/components/report-form/report-form.component.mjs +3 -3
- package/esm2022/lib/components/search-bar/search-bar.component.mjs +3 -3
- package/esm2022/lib/components/section-form-canvas/section-form-canvas.component.mjs +3 -3
- package/esm2022/lib/components/shared/action-button/action-button.component.mjs +3 -3
- package/esm2022/lib/components/shared/action-card/action-card.component.mjs +3 -3
- package/esm2022/lib/components/shared/attachment-uploader/attachment-uploader.component.mjs +3 -3
- package/esm2022/lib/components/shared-list/shared-list.component.mjs +3 -3
- package/esm2022/lib/components/snackbar-static/snackbar-static.component.mjs +3 -3
- package/esm2022/lib/components/title-bar/title-bar.component.mjs +3 -3
- package/esm2022/lib/directives/phone-number-only.directive.mjs +1 -1
- package/esm2022/lib/services/backend-service.mjs +1 -1
- package/esm2022/lib/services/index.mjs +1 -1
- package/esm2022/lib/services/top-panel.mjs +1 -1
- package/esm2022/lib/services/trigger-form.service.mjs +1 -1
- package/esm2022/lib/utils/base-utils.mjs +1 -1
- package/esm2022/lib/validators/date-range-validator.mjs +1 -1
- package/esm2022/lib/validators/index.mjs +1 -1
- package/esm2022/lib/validators/match-list.validator.mjs +1 -1
- package/esm2022/lib/validators/multi-email-validator.mjs +1 -1
- package/esm2022/public-api.mjs +1 -1
- package/fesm2022/iq-ui-lib.mjs +7059 -0
- package/fesm2022/iq-ui-lib.mjs.map +1 -0
- package/index.d.ts +1 -1
- package/package.json +14 -6
- package/esm2022/unifylib-ui-lib.mjs +0 -5
- package/fesm2022/unifylib-ui-lib.mjs +0 -7059
- package/fesm2022/unifylib-ui-lib.mjs.map +0 -1
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { buildFieldInfoLines } = require("../utils");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {{
|
|
7
|
-
* kebab: string,
|
|
8
|
-
* pascal: string,
|
|
9
|
-
* labelsSection: string,
|
|
10
|
-
* apiUri: string,
|
|
11
|
-
* importPath: string,
|
|
12
|
-
* fieldsCount: number,
|
|
13
|
-
* }} ctx
|
|
14
|
-
*/
|
|
15
|
-
function generate(ctx) {
|
|
16
|
-
const fileBase = ctx.kebab;
|
|
17
|
-
const fieldsBlock = buildFieldInfoLines(ctx.fieldsCount, 2, " ");
|
|
18
|
-
|
|
19
|
-
const settings = `import { Validators } from "@angular/forms";
|
|
20
|
-
import { FieldInfo, PageInfo } from "${ctx.importPath}";
|
|
21
|
-
|
|
22
|
-
export const PAGE_INFO: PageInfo = {
|
|
23
|
-
id: "${ctx.kebab}",
|
|
24
|
-
labelsSection: "${ctx.labelsSection}",
|
|
25
|
-
hasAddButton: false,
|
|
26
|
-
apiUri: "${ctx.apiUri}",
|
|
27
|
-
draftSupported: false,
|
|
28
|
-
selfRouting: true,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const FIELDS: FieldInfo[] = [
|
|
32
|
-
${fieldsBlock}
|
|
33
|
-
];
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
37
|
-
import { FormGroup, ReactiveFormsModule } from "@angular/forms";
|
|
38
|
-
import { TranslateModule } from "@ngx-translate/core";
|
|
39
|
-
import { BaseFormCanvasComponent } from "${ctx.importPath}";
|
|
40
|
-
import { FIELDS, PAGE_INFO } from "./${fileBase}.settings";
|
|
41
|
-
|
|
42
|
-
@Component({
|
|
43
|
-
selector: "app-${fileBase}",
|
|
44
|
-
standalone: true,
|
|
45
|
-
imports: [BaseFormCanvasComponent, ReactiveFormsModule, TranslateModule],
|
|
46
|
-
templateUrl: "./${fileBase}.component.html",
|
|
47
|
-
styleUrls: ["./${fileBase}.component.scss"],
|
|
48
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
|
-
})
|
|
50
|
-
export class ${ctx.pascal}Component {
|
|
51
|
-
readonly pageInfo = PAGE_INFO;
|
|
52
|
-
readonly fields = FIELDS;
|
|
53
|
-
item: Record<string, unknown> = {};
|
|
54
|
-
editable = true;
|
|
55
|
-
form: FormGroup | null = null;
|
|
56
|
-
|
|
57
|
-
onFormUpdated(form: FormGroup): void {
|
|
58
|
-
this.form = form;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
const componentHtml = `<app-base-form-canvas
|
|
64
|
-
*ngIf="fields?.length"
|
|
65
|
-
[pageInfo]="pageInfo"
|
|
66
|
-
[fields]="fields"
|
|
67
|
-
[editable]="editable"
|
|
68
|
-
[item]="item"
|
|
69
|
-
(formUpdated)="onFormUpdated($event)">
|
|
70
|
-
</app-base-form-canvas>
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const componentScss = `:host {
|
|
74
|
-
display: block;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
return [
|
|
79
|
-
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
80
|
-
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
81
|
-
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
82
|
-
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getTranslations(ctx) {
|
|
87
|
-
const out = {};
|
|
88
|
-
out[`${ctx.labelsSection}.list_title`] = `${ctx.pascal} List`;
|
|
89
|
-
for (let i = 1; i <= ctx.fieldsCount; i++) {
|
|
90
|
-
out[`${ctx.labelsSection}.field${i}`] = `Field ${i}`;
|
|
91
|
-
}
|
|
92
|
-
return out;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = { generate, getTranslations };
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { buildFieldInfoLines } = require("../utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {{
|
|
7
|
+
* kebab: string,
|
|
8
|
+
* pascal: string,
|
|
9
|
+
* labelsSection: string,
|
|
10
|
+
* apiUri: string,
|
|
11
|
+
* importPath: string,
|
|
12
|
+
* fieldsCount: number,
|
|
13
|
+
* }} ctx
|
|
14
|
+
*/
|
|
15
|
+
function generate(ctx) {
|
|
16
|
+
const fileBase = ctx.kebab;
|
|
17
|
+
const fieldsBlock = buildFieldInfoLines(ctx.fieldsCount, 2, " ");
|
|
18
|
+
|
|
19
|
+
const settings = `import { Validators } from "@angular/forms";
|
|
20
|
+
import { FieldInfo, PageInfo } from "${ctx.importPath}";
|
|
21
|
+
|
|
22
|
+
export const PAGE_INFO: PageInfo = {
|
|
23
|
+
id: "${ctx.kebab}",
|
|
24
|
+
labelsSection: "${ctx.labelsSection}",
|
|
25
|
+
hasAddButton: false,
|
|
26
|
+
apiUri: "${ctx.apiUri}",
|
|
27
|
+
draftSupported: false,
|
|
28
|
+
selfRouting: true,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const FIELDS: FieldInfo[] = [
|
|
32
|
+
${fieldsBlock}
|
|
33
|
+
];
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
37
|
+
import { FormGroup, ReactiveFormsModule } from "@angular/forms";
|
|
38
|
+
import { TranslateModule } from "@ngx-translate/core";
|
|
39
|
+
import { BaseFormCanvasComponent } from "${ctx.importPath}";
|
|
40
|
+
import { FIELDS, PAGE_INFO } from "./${fileBase}.settings";
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
selector: "app-${fileBase}",
|
|
44
|
+
standalone: true,
|
|
45
|
+
imports: [BaseFormCanvasComponent, ReactiveFormsModule, TranslateModule],
|
|
46
|
+
templateUrl: "./${fileBase}.component.html",
|
|
47
|
+
styleUrls: ["./${fileBase}.component.scss"],
|
|
48
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
|
+
})
|
|
50
|
+
export class ${ctx.pascal}Component {
|
|
51
|
+
readonly pageInfo = PAGE_INFO;
|
|
52
|
+
readonly fields = FIELDS;
|
|
53
|
+
item: Record<string, unknown> = {};
|
|
54
|
+
editable = true;
|
|
55
|
+
form: FormGroup | null = null;
|
|
56
|
+
|
|
57
|
+
onFormUpdated(form: FormGroup): void {
|
|
58
|
+
this.form = form;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const componentHtml = `<app-base-form-canvas
|
|
64
|
+
*ngIf="fields?.length"
|
|
65
|
+
[pageInfo]="pageInfo"
|
|
66
|
+
[fields]="fields"
|
|
67
|
+
[editable]="editable"
|
|
68
|
+
[item]="item"
|
|
69
|
+
(formUpdated)="onFormUpdated($event)">
|
|
70
|
+
</app-base-form-canvas>
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const componentScss = `:host {
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
return [
|
|
79
|
+
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
80
|
+
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
81
|
+
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
82
|
+
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getTranslations(ctx) {
|
|
87
|
+
const out = {};
|
|
88
|
+
out[`${ctx.labelsSection}.list_title`] = `${ctx.pascal} List`;
|
|
89
|
+
for (let i = 1; i <= ctx.fieldsCount; i++) {
|
|
90
|
+
out[`${ctx.labelsSection}.field${i}`] = `Field ${i}`;
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { generate, getTranslations };
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { buildFieldInfoLines } = require("../utils");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {{
|
|
7
|
-
* kebab: string,
|
|
8
|
-
* pascal: string,
|
|
9
|
-
* labelsSection: string,
|
|
10
|
-
* importPath: string,
|
|
11
|
-
* fieldsCount: number,
|
|
12
|
-
* }} ctx
|
|
13
|
-
*/
|
|
14
|
-
function generate(ctx) {
|
|
15
|
-
const fileBase = ctx.kebab;
|
|
16
|
-
const fieldsBlock = buildFieldInfoLines(ctx.fieldsCount, 2, " ");
|
|
17
|
-
|
|
18
|
-
const settings = `import { Validators } from "@angular/forms";
|
|
19
|
-
import { FieldInfo, PageInfo } from "${ctx.importPath}";
|
|
20
|
-
|
|
21
|
-
export const PAGE_INFO: PageInfo = {
|
|
22
|
-
id: "${ctx.kebab}",
|
|
23
|
-
labelsSection: "${ctx.labelsSection}",
|
|
24
|
-
hasAddButton: false,
|
|
25
|
-
draftSupported: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** Shared schema for every line row; adjust \`row\` / \`visible\` for header vs body fields in your feature. */
|
|
29
|
-
export const LINE_FIELDS: FieldInfo[] = [
|
|
30
|
-
${fieldsBlock}
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
/** Grid columns for the line header row (length matches number of line fields). */
|
|
34
|
-
export const COLUMN_HEADER_WIDTHS: string[] = [
|
|
35
|
-
${Array.from({ length: ctx.fieldsCount }, () => ' "minmax(0,1fr)"').join(",\n")}
|
|
36
|
-
];
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
40
|
-
import { TranslateModule } from "@ngx-translate/core";
|
|
41
|
-
import {
|
|
42
|
-
ItemLineEditorComponent,
|
|
43
|
-
ItemsTotal,
|
|
44
|
-
LineItem,
|
|
45
|
-
} from "${ctx.importPath}";
|
|
46
|
-
import { COLUMN_HEADER_WIDTHS, LINE_FIELDS, PAGE_INFO } from "./${fileBase}.settings";
|
|
47
|
-
|
|
48
|
-
@Component({
|
|
49
|
-
selector: "app-${fileBase}",
|
|
50
|
-
standalone: true,
|
|
51
|
-
imports: [ItemLineEditorComponent, TranslateModule],
|
|
52
|
-
templateUrl: "./${fileBase}.component.html",
|
|
53
|
-
styleUrls: ["./${fileBase}.component.scss"],
|
|
54
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
55
|
-
})
|
|
56
|
-
export class ${ctx.pascal}Component {
|
|
57
|
-
readonly pageInfo = PAGE_INFO;
|
|
58
|
-
readonly lineFields = LINE_FIELDS;
|
|
59
|
-
readonly columnHeaderWidths = COLUMN_HEADER_WIDTHS;
|
|
60
|
-
lines: LineItem[] = [];
|
|
61
|
-
currency = "QAR";
|
|
62
|
-
|
|
63
|
-
onLinesChange(items: LineItem[]): void {
|
|
64
|
-
this.lines = items;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
onTotalsChange(_totals: ItemsTotal): void {
|
|
68
|
-
// Optional: patch a parent form or show summary.
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const componentHtml = `<app-item-line-editor
|
|
74
|
-
[pageInfo]="pageInfo"
|
|
75
|
-
[fields]="lineFields"
|
|
76
|
-
[columnHeaderWidths]="columnHeaderWidths"
|
|
77
|
-
[items]="lines"
|
|
78
|
-
[currency]="currency"
|
|
79
|
-
[title]="'${ctx.labelsSection}.linesTitle'"
|
|
80
|
-
[subtitle]="'${ctx.labelsSection}.linesSubtitle'"
|
|
81
|
-
(itemsChange)="onLinesChange($event)"
|
|
82
|
-
(totalsChange)="onTotalsChange($event)">
|
|
83
|
-
</app-item-line-editor>
|
|
84
|
-
`;
|
|
85
|
-
|
|
86
|
-
const componentScss = `:host {
|
|
87
|
-
display: block;
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
return [
|
|
92
|
-
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
93
|
-
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
94
|
-
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
95
|
-
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getTranslations(ctx) {
|
|
100
|
-
const out = {
|
|
101
|
-
[`${ctx.labelsSection}.linesTitle`]: `${ctx.pascal} Lines`,
|
|
102
|
-
[`${ctx.labelsSection}.linesSubtitle`]: "Review and edit line items",
|
|
103
|
-
};
|
|
104
|
-
for (let i = 1; i <= ctx.fieldsCount; i++) {
|
|
105
|
-
out[`${ctx.labelsSection}.field${i}`] = `Field ${i}`;
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
module.exports = { generate, getTranslations };
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { buildFieldInfoLines } = require("../utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {{
|
|
7
|
+
* kebab: string,
|
|
8
|
+
* pascal: string,
|
|
9
|
+
* labelsSection: string,
|
|
10
|
+
* importPath: string,
|
|
11
|
+
* fieldsCount: number,
|
|
12
|
+
* }} ctx
|
|
13
|
+
*/
|
|
14
|
+
function generate(ctx) {
|
|
15
|
+
const fileBase = ctx.kebab;
|
|
16
|
+
const fieldsBlock = buildFieldInfoLines(ctx.fieldsCount, 2, " ");
|
|
17
|
+
|
|
18
|
+
const settings = `import { Validators } from "@angular/forms";
|
|
19
|
+
import { FieldInfo, PageInfo } from "${ctx.importPath}";
|
|
20
|
+
|
|
21
|
+
export const PAGE_INFO: PageInfo = {
|
|
22
|
+
id: "${ctx.kebab}",
|
|
23
|
+
labelsSection: "${ctx.labelsSection}",
|
|
24
|
+
hasAddButton: false,
|
|
25
|
+
draftSupported: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Shared schema for every line row; adjust \`row\` / \`visible\` for header vs body fields in your feature. */
|
|
29
|
+
export const LINE_FIELDS: FieldInfo[] = [
|
|
30
|
+
${fieldsBlock}
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** Grid columns for the line header row (length matches number of line fields). */
|
|
34
|
+
export const COLUMN_HEADER_WIDTHS: string[] = [
|
|
35
|
+
${Array.from({ length: ctx.fieldsCount }, () => ' "minmax(0,1fr)"').join(",\n")}
|
|
36
|
+
];
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
40
|
+
import { TranslateModule } from "@ngx-translate/core";
|
|
41
|
+
import {
|
|
42
|
+
ItemLineEditorComponent,
|
|
43
|
+
ItemsTotal,
|
|
44
|
+
LineItem,
|
|
45
|
+
} from "${ctx.importPath}";
|
|
46
|
+
import { COLUMN_HEADER_WIDTHS, LINE_FIELDS, PAGE_INFO } from "./${fileBase}.settings";
|
|
47
|
+
|
|
48
|
+
@Component({
|
|
49
|
+
selector: "app-${fileBase}",
|
|
50
|
+
standalone: true,
|
|
51
|
+
imports: [ItemLineEditorComponent, TranslateModule],
|
|
52
|
+
templateUrl: "./${fileBase}.component.html",
|
|
53
|
+
styleUrls: ["./${fileBase}.component.scss"],
|
|
54
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
55
|
+
})
|
|
56
|
+
export class ${ctx.pascal}Component {
|
|
57
|
+
readonly pageInfo = PAGE_INFO;
|
|
58
|
+
readonly lineFields = LINE_FIELDS;
|
|
59
|
+
readonly columnHeaderWidths = COLUMN_HEADER_WIDTHS;
|
|
60
|
+
lines: LineItem[] = [];
|
|
61
|
+
currency = "QAR";
|
|
62
|
+
|
|
63
|
+
onLinesChange(items: LineItem[]): void {
|
|
64
|
+
this.lines = items;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onTotalsChange(_totals: ItemsTotal): void {
|
|
68
|
+
// Optional: patch a parent form or show summary.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const componentHtml = `<app-item-line-editor
|
|
74
|
+
[pageInfo]="pageInfo"
|
|
75
|
+
[fields]="lineFields"
|
|
76
|
+
[columnHeaderWidths]="columnHeaderWidths"
|
|
77
|
+
[items]="lines"
|
|
78
|
+
[currency]="currency"
|
|
79
|
+
[title]="'${ctx.labelsSection}.linesTitle'"
|
|
80
|
+
[subtitle]="'${ctx.labelsSection}.linesSubtitle'"
|
|
81
|
+
(itemsChange)="onLinesChange($event)"
|
|
82
|
+
(totalsChange)="onTotalsChange($event)">
|
|
83
|
+
</app-item-line-editor>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
const componentScss = `:host {
|
|
87
|
+
display: block;
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
return [
|
|
92
|
+
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
93
|
+
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
94
|
+
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
95
|
+
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getTranslations(ctx) {
|
|
100
|
+
const out = {
|
|
101
|
+
[`${ctx.labelsSection}.linesTitle`]: `${ctx.pascal} Lines`,
|
|
102
|
+
[`${ctx.labelsSection}.linesSubtitle`]: "Review and edit line items",
|
|
103
|
+
};
|
|
104
|
+
for (let i = 1; i <= ctx.fieldsCount; i++) {
|
|
105
|
+
out[`${ctx.labelsSection}.field${i}`] = `Field ${i}`;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = { generate, getTranslations };
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {{
|
|
5
|
-
* kebab: string,
|
|
6
|
-
* pascal: string,
|
|
7
|
-
* labelsSection: string,
|
|
8
|
-
* importPath: string,
|
|
9
|
-
* }} ctx
|
|
10
|
-
*/
|
|
11
|
-
function generate(ctx) {
|
|
12
|
-
const fileBase = ctx.kebab;
|
|
13
|
-
|
|
14
|
-
const settings = `import {
|
|
15
|
-
PermissionConfig,
|
|
16
|
-
PermissionMatrixItem,
|
|
17
|
-
} from "${ctx.importPath}";
|
|
18
|
-
|
|
19
|
-
export const PERMISSION_COLUMNS: PermissionConfig[] = [
|
|
20
|
-
{ key: "view", labelKey: "${ctx.labelsSection}.view" },
|
|
21
|
-
{ key: "edit", labelKey: "${ctx.labelsSection}.edit" },
|
|
22
|
-
{
|
|
23
|
-
key: "completeAndTerminate",
|
|
24
|
-
labelKey: "${ctx.labelsSection}.completeAndTerminate",
|
|
25
|
-
combinedKeys: ["completePermission", "terminatePermission"],
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
export const SAMPLE_GROUPS: PermissionMatrixItem[] = [
|
|
30
|
-
{
|
|
31
|
-
id: "sample-group",
|
|
32
|
-
title: "Sample group",
|
|
33
|
-
description: "Replace with data from your API",
|
|
34
|
-
expanded: true,
|
|
35
|
-
permissions: {
|
|
36
|
-
view: false,
|
|
37
|
-
edit: false,
|
|
38
|
-
completePermission: false,
|
|
39
|
-
terminatePermission: false,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
46
|
-
import { TranslateModule } from "@ngx-translate/core";
|
|
47
|
-
import {
|
|
48
|
-
PermissionChangeEvent,
|
|
49
|
-
PermissionMatrixComponent,
|
|
50
|
-
PermissionMatrixItem,
|
|
51
|
-
} from "${ctx.importPath}";
|
|
52
|
-
import { PERMISSION_COLUMNS, SAMPLE_GROUPS } from "./${fileBase}.settings";
|
|
53
|
-
|
|
54
|
-
@Component({
|
|
55
|
-
selector: "app-${fileBase}",
|
|
56
|
-
standalone: true,
|
|
57
|
-
imports: [PermissionMatrixComponent, TranslateModule],
|
|
58
|
-
templateUrl: "./${fileBase}.component.html",
|
|
59
|
-
styleUrls: ["./${fileBase}.component.scss"],
|
|
60
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
61
|
-
})
|
|
62
|
-
export class ${ctx.pascal}Component {
|
|
63
|
-
readonly permissionConfig = PERMISSION_COLUMNS;
|
|
64
|
-
groups: PermissionMatrixItem[] = SAMPLE_GROUPS;
|
|
65
|
-
readonly canEdit = true;
|
|
66
|
-
|
|
67
|
-
onMatrixChange(items: PermissionMatrixItem[]): void {
|
|
68
|
-
this.groups = items;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onCell(_event: PermissionChangeEvent): void {
|
|
72
|
-
// Optional: audit / incremental API
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
const componentHtml = `<lib-permission-matrix
|
|
78
|
-
[items]="groups"
|
|
79
|
-
[permissions]="permissionConfig"
|
|
80
|
-
[titleKey]="'${ctx.labelsSection}.groupMatrix'"
|
|
81
|
-
[selectAllLabelKey]="'${ctx.labelsSection}.selectAll'"
|
|
82
|
-
[expandAllLabelKey]="'${ctx.labelsSection}.expandAll'"
|
|
83
|
-
[collapseAllLabelKey]="'${ctx.labelsSection}.collapseAll'"
|
|
84
|
-
[readonly]="!canEdit"
|
|
85
|
-
(itemsChange)="onMatrixChange($event)"
|
|
86
|
-
(permissionChange)="onCell($event)">
|
|
87
|
-
</lib-permission-matrix>
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
const componentScss = `:host {
|
|
91
|
-
display: block;
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
|
|
95
|
-
return [
|
|
96
|
-
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
97
|
-
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
98
|
-
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
99
|
-
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getTranslations(ctx) {
|
|
104
|
-
return {
|
|
105
|
-
[`${ctx.labelsSection}.groupMatrix`]: "Group matrix",
|
|
106
|
-
[`${ctx.labelsSection}.selectAll`]: "Select all",
|
|
107
|
-
[`${ctx.labelsSection}.expandAll`]: "Expand all",
|
|
108
|
-
[`${ctx.labelsSection}.collapseAll`]: "Collapse all",
|
|
109
|
-
[`${ctx.labelsSection}.view`]: "View",
|
|
110
|
-
[`${ctx.labelsSection}.edit`]: "Edit",
|
|
111
|
-
[`${ctx.labelsSection}.completeAndTerminate`]: "Complete and terminate",
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = { generate, getTranslations };
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {{
|
|
5
|
+
* kebab: string,
|
|
6
|
+
* pascal: string,
|
|
7
|
+
* labelsSection: string,
|
|
8
|
+
* importPath: string,
|
|
9
|
+
* }} ctx
|
|
10
|
+
*/
|
|
11
|
+
function generate(ctx) {
|
|
12
|
+
const fileBase = ctx.kebab;
|
|
13
|
+
|
|
14
|
+
const settings = `import {
|
|
15
|
+
PermissionConfig,
|
|
16
|
+
PermissionMatrixItem,
|
|
17
|
+
} from "${ctx.importPath}";
|
|
18
|
+
|
|
19
|
+
export const PERMISSION_COLUMNS: PermissionConfig[] = [
|
|
20
|
+
{ key: "view", labelKey: "${ctx.labelsSection}.view" },
|
|
21
|
+
{ key: "edit", labelKey: "${ctx.labelsSection}.edit" },
|
|
22
|
+
{
|
|
23
|
+
key: "completeAndTerminate",
|
|
24
|
+
labelKey: "${ctx.labelsSection}.completeAndTerminate",
|
|
25
|
+
combinedKeys: ["completePermission", "terminatePermission"],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export const SAMPLE_GROUPS: PermissionMatrixItem[] = [
|
|
30
|
+
{
|
|
31
|
+
id: "sample-group",
|
|
32
|
+
title: "Sample group",
|
|
33
|
+
description: "Replace with data from your API",
|
|
34
|
+
expanded: true,
|
|
35
|
+
permissions: {
|
|
36
|
+
view: false,
|
|
37
|
+
edit: false,
|
|
38
|
+
completePermission: false,
|
|
39
|
+
terminatePermission: false,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const componentTs = `import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
46
|
+
import { TranslateModule } from "@ngx-translate/core";
|
|
47
|
+
import {
|
|
48
|
+
PermissionChangeEvent,
|
|
49
|
+
PermissionMatrixComponent,
|
|
50
|
+
PermissionMatrixItem,
|
|
51
|
+
} from "${ctx.importPath}";
|
|
52
|
+
import { PERMISSION_COLUMNS, SAMPLE_GROUPS } from "./${fileBase}.settings";
|
|
53
|
+
|
|
54
|
+
@Component({
|
|
55
|
+
selector: "app-${fileBase}",
|
|
56
|
+
standalone: true,
|
|
57
|
+
imports: [PermissionMatrixComponent, TranslateModule],
|
|
58
|
+
templateUrl: "./${fileBase}.component.html",
|
|
59
|
+
styleUrls: ["./${fileBase}.component.scss"],
|
|
60
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
61
|
+
})
|
|
62
|
+
export class ${ctx.pascal}Component {
|
|
63
|
+
readonly permissionConfig = PERMISSION_COLUMNS;
|
|
64
|
+
groups: PermissionMatrixItem[] = SAMPLE_GROUPS;
|
|
65
|
+
readonly canEdit = true;
|
|
66
|
+
|
|
67
|
+
onMatrixChange(items: PermissionMatrixItem[]): void {
|
|
68
|
+
this.groups = items;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onCell(_event: PermissionChangeEvent): void {
|
|
72
|
+
// Optional: audit / incremental API
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const componentHtml = `<lib-permission-matrix
|
|
78
|
+
[items]="groups"
|
|
79
|
+
[permissions]="permissionConfig"
|
|
80
|
+
[titleKey]="'${ctx.labelsSection}.groupMatrix'"
|
|
81
|
+
[selectAllLabelKey]="'${ctx.labelsSection}.selectAll'"
|
|
82
|
+
[expandAllLabelKey]="'${ctx.labelsSection}.expandAll'"
|
|
83
|
+
[collapseAllLabelKey]="'${ctx.labelsSection}.collapseAll'"
|
|
84
|
+
[readonly]="!canEdit"
|
|
85
|
+
(itemsChange)="onMatrixChange($event)"
|
|
86
|
+
(permissionChange)="onCell($event)">
|
|
87
|
+
</lib-permission-matrix>
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
const componentScss = `:host {
|
|
91
|
+
display: block;
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
return [
|
|
96
|
+
{ relative: `${fileBase}.settings.ts`, content: settings },
|
|
97
|
+
{ relative: `${fileBase}.component.ts`, content: componentTs },
|
|
98
|
+
{ relative: `${fileBase}.component.html`, content: componentHtml },
|
|
99
|
+
{ relative: `${fileBase}.component.scss`, content: componentScss },
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getTranslations(ctx) {
|
|
104
|
+
return {
|
|
105
|
+
[`${ctx.labelsSection}.groupMatrix`]: "Group matrix",
|
|
106
|
+
[`${ctx.labelsSection}.selectAll`]: "Select all",
|
|
107
|
+
[`${ctx.labelsSection}.expandAll`]: "Expand all",
|
|
108
|
+
[`${ctx.labelsSection}.collapseAll`]: "Collapse all",
|
|
109
|
+
[`${ctx.labelsSection}.view`]: "View",
|
|
110
|
+
[`${ctx.labelsSection}.edit`]: "Edit",
|
|
111
|
+
[`${ctx.labelsSection}.completeAndTerminate`]: "Complete and terminate",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { generate, getTranslations };
|