@mintplayer/ng-spark 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/mintplayer-ng-spark-icon.mjs +35 -0
- package/fesm2022/mintplayer-ng-spark-icon.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-models.mjs +48 -0
- package/fesm2022/mintplayer-ng-spark-models.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-pipes.mjs +427 -0
- package/fesm2022/mintplayer-ng-spark-pipes.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-po-create.mjs +121 -0
- package/fesm2022/mintplayer-ng-spark-po-create.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-po-detail.mjs +368 -0
- package/fesm2022/mintplayer-ng-spark-po-detail.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-po-edit.mjs +139 -0
- package/fesm2022/mintplayer-ng-spark-po-edit.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-po-form.mjs +393 -0
- package/fesm2022/mintplayer-ng-spark-po-form.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-query-list.mjs +392 -0
- package/fesm2022/mintplayer-ng-spark-query-list.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-renderers.mjs +25 -0
- package/fesm2022/mintplayer-ng-spark-renderers.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-retry-action-modal.mjs +87 -0
- package/fesm2022/mintplayer-ng-spark-retry-action-modal.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-routes.mjs +31 -0
- package/fesm2022/mintplayer-ng-spark-routes.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-services.mjs +348 -0
- package/fesm2022/mintplayer-ng-spark-services.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark.mjs +17 -2262
- package/fesm2022/mintplayer-ng-spark.mjs.map +1 -1
- package/package.json +49 -1
- package/types/mintplayer-ng-spark-icon.d.ts +13 -0
- package/types/mintplayer-ng-spark-models.d.ts +275 -0
- package/types/mintplayer-ng-spark-pipes.d.ts +143 -0
- package/types/mintplayer-ng-spark-po-create.d.ts +29 -0
- package/types/mintplayer-ng-spark-po-detail.d.ts +88 -0
- package/types/mintplayer-ng-spark-po-edit.d.ts +31 -0
- package/types/mintplayer-ng-spark-po-form.d.ts +84 -0
- package/types/mintplayer-ng-spark-query-list.d.ts +60 -0
- package/types/mintplayer-ng-spark-renderers.d.ts +68 -0
- package/types/mintplayer-ng-spark-retry-action-modal.d.ts +14 -0
- package/types/mintplayer-ng-spark-routes.d.ts +12 -0
- package/types/mintplayer-ng-spark-services.d.ts +100 -0
- package/types/mintplayer-ng-spark.d.ts +3 -855
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, output, signal, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
6
|
+
import { Color } from '@mintplayer/ng-bootstrap';
|
|
7
|
+
import { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';
|
|
8
|
+
import { BsContainerComponent } from '@mintplayer/ng-bootstrap/container';
|
|
9
|
+
import { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';
|
|
10
|
+
import { SparkService } from '@mintplayer/ng-spark/services';
|
|
11
|
+
import { SparkPoFormComponent } from '@mintplayer/ng-spark/po-form';
|
|
12
|
+
import { ResolveTranslationPipe, TranslateKeyPipe } from '@mintplayer/ng-spark/pipes';
|
|
13
|
+
import { hasShowedOnFlag, ShowedOn } from '@mintplayer/ng-spark/models';
|
|
14
|
+
|
|
15
|
+
class SparkPoCreateComponent {
|
|
16
|
+
route = inject(ActivatedRoute);
|
|
17
|
+
router = inject(Router);
|
|
18
|
+
sparkService = inject(SparkService);
|
|
19
|
+
saved = output();
|
|
20
|
+
cancelled = output();
|
|
21
|
+
colors = Color;
|
|
22
|
+
entityType = signal(null, ...(ngDevMode ? [{ debugName: "entityType" }] : []));
|
|
23
|
+
type = signal('', ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
24
|
+
formData = signal({}, ...(ngDevMode ? [{ debugName: "formData" }] : []));
|
|
25
|
+
validationErrors = signal([], ...(ngDevMode ? [{ debugName: "validationErrors" }] : []));
|
|
26
|
+
isSaving = signal(false, ...(ngDevMode ? [{ debugName: "isSaving" }] : []));
|
|
27
|
+
generalErrors = computed(() => this.validationErrors().filter(e => !e.attributeName), ...(ngDevMode ? [{ debugName: "generalErrors" }] : []));
|
|
28
|
+
constructor() {
|
|
29
|
+
this.route.paramMap.pipe(takeUntilDestroyed()).subscribe(params => this.onParamsChange(params));
|
|
30
|
+
}
|
|
31
|
+
async onParamsChange(params) {
|
|
32
|
+
this.type.set(params.get('type') || '');
|
|
33
|
+
const types = await this.sparkService.getEntityTypes();
|
|
34
|
+
const entityType = types.find(t => t.id === this.type() || t.alias === this.type()) || null;
|
|
35
|
+
this.entityType.set(entityType);
|
|
36
|
+
this.initFormData();
|
|
37
|
+
}
|
|
38
|
+
initFormData() {
|
|
39
|
+
const data = {};
|
|
40
|
+
this.getEditableAttributes().forEach(attr => {
|
|
41
|
+
if (attr.dataType === 'Reference') {
|
|
42
|
+
data[attr.name] = null;
|
|
43
|
+
}
|
|
44
|
+
else if (attr.dataType === 'AsDetail') {
|
|
45
|
+
data[attr.name] = attr.isArray ? [] : {};
|
|
46
|
+
}
|
|
47
|
+
else if (attr.dataType === 'boolean') {
|
|
48
|
+
data[attr.name] = false;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
data[attr.name] = '';
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.formData.set(data);
|
|
55
|
+
}
|
|
56
|
+
getEditableAttributes() {
|
|
57
|
+
return this.entityType()?.attributes
|
|
58
|
+
.filter(a => a.isVisible && !a.isReadOnly && hasShowedOnFlag(a.showedOn, ShowedOn.PersistentObject))
|
|
59
|
+
.sort((a, b) => a.order - b.order) || [];
|
|
60
|
+
}
|
|
61
|
+
async onSave() {
|
|
62
|
+
if (!this.entityType())
|
|
63
|
+
return;
|
|
64
|
+
this.validationErrors.set([]);
|
|
65
|
+
this.isSaving.set(true);
|
|
66
|
+
const attributes = this.getEditableAttributes().map(attr => ({
|
|
67
|
+
id: attr.id,
|
|
68
|
+
name: attr.name,
|
|
69
|
+
value: this.formData()[attr.name],
|
|
70
|
+
dataType: attr.dataType,
|
|
71
|
+
isRequired: attr.isRequired,
|
|
72
|
+
isVisible: attr.isVisible,
|
|
73
|
+
isReadOnly: attr.isReadOnly,
|
|
74
|
+
isValueChanged: true,
|
|
75
|
+
order: attr.order,
|
|
76
|
+
rules: attr.rules
|
|
77
|
+
}));
|
|
78
|
+
const po = {
|
|
79
|
+
name: this.formData()['Name'] || 'New Item',
|
|
80
|
+
objectTypeId: this.entityType().id,
|
|
81
|
+
attributes
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
const result = await this.sparkService.create(this.type(), po);
|
|
85
|
+
this.isSaving.set(false);
|
|
86
|
+
this.saved.emit(result);
|
|
87
|
+
this.router.navigate(['/po', this.type(), result.id]);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
this.isSaving.set(false);
|
|
91
|
+
const error = e;
|
|
92
|
+
if (error.status === 400 && error.error?.errors) {
|
|
93
|
+
this.validationErrors.set(error.error.errors);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.validationErrors.set([{
|
|
97
|
+
attributeName: '',
|
|
98
|
+
errorMessage: { en: error.message || 'An unexpected error occurred' },
|
|
99
|
+
ruleType: 'error'
|
|
100
|
+
}]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
onCancel() {
|
|
105
|
+
this.cancelled.emit();
|
|
106
|
+
window.history.back();
|
|
107
|
+
}
|
|
108
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkPoCreateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
109
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: SparkPoCreateComponent, isStandalone: true, selector: "spark-po-create", outputs: { saved: "saved", cancelled: "cancelled" }, ngImport: i0, template: "<bs-container>\n<div class=\"container\">\n @if (entityType(); as et) {\n <h2 class=\"mb-4\">{{ 'common.create' | t }} {{ (et.description | resolveTranslation) || et.name }}</h2>\n\n @for (error of generalErrors(); track error.errorMessage) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">\n {{ error.errorMessage }}\n </bs-alert>\n }\n\n <spark-po-form\n [entityType]=\"et\"\n [(formData)]=\"formData\"\n [validationErrors]=\"validationErrors()\"\n [showButtons]=\"true\"\n [isSaving]=\"isSaving()\"\n (save)=\"onSave()\"\n (cancel)=\"onCancel()\">\n </spark-po-form>\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n</bs-container>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: BsAlertComponent, selector: "bs-alert", inputs: ["type", "isVisible"], outputs: ["isVisibleChange", "afterOpenedOrClosed"] }, { kind: "component", type: BsContainerComponent, selector: "bs-container" }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "component", type: SparkPoFormComponent, selector: "spark-po-form", inputs: ["entityType", "formData", "validationErrors", "showButtons", "isSaving", "parentId", "parentType"], outputs: ["formDataChange", "save", "cancel"] }, { kind: "pipe", type: ResolveTranslationPipe, name: "resolveTranslation" }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
110
|
+
}
|
|
111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkPoCreateComponent, decorators: [{
|
|
112
|
+
type: Component,
|
|
113
|
+
args: [{ selector: 'spark-po-create', imports: [CommonModule, BsAlertComponent, BsContainerComponent, BsSpinnerComponent, SparkPoFormComponent, ResolveTranslationPipe, TranslateKeyPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-container>\n<div class=\"container\">\n @if (entityType(); as et) {\n <h2 class=\"mb-4\">{{ 'common.create' | t }} {{ (et.description | resolveTranslation) || et.name }}</h2>\n\n @for (error of generalErrors(); track error.errorMessage) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">\n {{ error.errorMessage }}\n </bs-alert>\n }\n\n <spark-po-form\n [entityType]=\"et\"\n [(formData)]=\"formData\"\n [validationErrors]=\"validationErrors()\"\n [showButtons]=\"true\"\n [isSaving]=\"isSaving()\"\n (save)=\"onSave()\"\n (cancel)=\"onCancel()\">\n </spark-po-form>\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n</bs-container>\n" }]
|
|
114
|
+
}], ctorParameters: () => [], propDecorators: { saved: [{ type: i0.Output, args: ["saved"] }], cancelled: [{ type: i0.Output, args: ["cancelled"] }] } });
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Generated bundle index. Do not edit.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
export { SparkPoCreateComponent };
|
|
121
|
+
//# sourceMappingURL=mintplayer-ng-spark-po-create.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-spark-po-create.mjs","sources":["../../po-create/src/spark-po-create.component.ts","../../po-create/src/spark-po-create.component.html","../../po-create/mintplayer-ng-spark-po-create.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, inject, output, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { CommonModule } from '@angular/common';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { HttpErrorResponse } from '@angular/common/http';\nimport { Color } from '@mintplayer/ng-bootstrap';\nimport { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';\nimport { BsContainerComponent } from '@mintplayer/ng-bootstrap/container';\nimport { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';\nimport { SparkService } from '@mintplayer/ng-spark/services';\nimport { SparkPoFormComponent } from '@mintplayer/ng-spark/po-form';\nimport { TranslateKeyPipe, ResolveTranslationPipe } from '@mintplayer/ng-spark/pipes';\nimport {\n EntityType,\n PersistentObject,\n PersistentObjectAttribute,\n ValidationError,\n ShowedOn,\n hasShowedOnFlag,\n} from '@mintplayer/ng-spark/models';\n\n@Component({\n selector: 'spark-po-create',\n imports: [CommonModule, BsAlertComponent, BsContainerComponent, BsSpinnerComponent, SparkPoFormComponent, ResolveTranslationPipe, TranslateKeyPipe],\n templateUrl: './spark-po-create.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SparkPoCreateComponent {\n private readonly route = inject(ActivatedRoute);\n private readonly router = inject(Router);\n private readonly sparkService = inject(SparkService);\n\n saved = output<PersistentObject>();\n cancelled = output<void>();\n\n colors = Color;\n entityType = signal<EntityType | null>(null);\n type = signal('');\n formData = signal<Record<string, any>>({});\n validationErrors = signal<ValidationError[]>([]);\n isSaving = signal(false);\n generalErrors = computed(() => this.validationErrors().filter(e => !e.attributeName));\n\n constructor() {\n this.route.paramMap.pipe(takeUntilDestroyed()).subscribe(params => this.onParamsChange(params));\n }\n\n private async onParamsChange(params: any): Promise<void> {\n this.type.set(params.get('type') || '');\n const types = await this.sparkService.getEntityTypes();\n const entityType = types.find(t => t.id === this.type() || t.alias === this.type()) || null;\n this.entityType.set(entityType);\n this.initFormData();\n }\n\n initFormData(): void {\n const data: Record<string, any> = {};\n this.getEditableAttributes().forEach(attr => {\n if (attr.dataType === 'Reference') {\n data[attr.name] = null;\n } else if (attr.dataType === 'AsDetail') {\n data[attr.name] = attr.isArray ? [] : {};\n } else if (attr.dataType === 'boolean') {\n data[attr.name] = false;\n } else {\n data[attr.name] = '';\n }\n });\n this.formData.set(data);\n }\n\n getEditableAttributes() {\n return this.entityType()?.attributes\n .filter(a => a.isVisible && !a.isReadOnly && hasShowedOnFlag(a.showedOn, ShowedOn.PersistentObject))\n .sort((a, b) => a.order - b.order) || [];\n }\n\n async onSave(): Promise<void> {\n if (!this.entityType()) return;\n\n this.validationErrors.set([]);\n this.isSaving.set(true);\n\n const attributes: PersistentObjectAttribute[] = this.getEditableAttributes().map(attr => ({\n id: attr.id,\n name: attr.name,\n value: this.formData()[attr.name],\n dataType: attr.dataType,\n isRequired: attr.isRequired,\n isVisible: attr.isVisible,\n isReadOnly: attr.isReadOnly,\n isValueChanged: true,\n order: attr.order,\n rules: attr.rules\n }));\n\n const po: Partial<PersistentObject> = {\n name: this.formData()['Name'] || 'New Item',\n objectTypeId: this.entityType()!.id,\n attributes\n };\n\n try {\n const result = await this.sparkService.create(this.type(), po);\n this.isSaving.set(false);\n this.saved.emit(result);\n this.router.navigate(['/po', this.type(), result.id]);\n } catch (e) {\n this.isSaving.set(false);\n const error = e as HttpErrorResponse;\n if (error.status === 400 && error.error?.errors) {\n this.validationErrors.set(error.error.errors);\n } else {\n this.validationErrors.set([{\n attributeName: '',\n errorMessage: { en: error.message || 'An unexpected error occurred' },\n ruleType: 'error'\n }]);\n }\n }\n }\n\n onCancel(): void {\n this.cancelled.emit();\n window.history.back();\n }\n}\n","<bs-container>\n<div class=\"container\">\n @if (entityType(); as et) {\n <h2 class=\"mb-4\">{{ 'common.create' | t }} {{ (et.description | resolveTranslation) || et.name }}</h2>\n\n @for (error of generalErrors(); track error.errorMessage) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">\n {{ error.errorMessage }}\n </bs-alert>\n }\n\n <spark-po-form\n [entityType]=\"et\"\n [(formData)]=\"formData\"\n [validationErrors]=\"validationErrors()\"\n [showButtons]=\"true\"\n [isSaving]=\"isSaving()\"\n (save)=\"onSave()\"\n (cancel)=\"onCancel()\">\n </spark-po-form>\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n</bs-container>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MA2Ba,sBAAsB,CAAA;AAChB,IAAA,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;AAC9B,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAEpD,KAAK,GAAG,MAAM,EAAoB;IAClC,SAAS,GAAG,MAAM,EAAQ;IAE1B,MAAM,GAAG,KAAK;AACd,IAAA,UAAU,GAAG,MAAM,CAAoB,IAAI,sDAAC;AAC5C,IAAA,IAAI,GAAG,MAAM,CAAC,EAAE,gDAAC;AACjB,IAAA,QAAQ,GAAG,MAAM,CAAsB,EAAE,oDAAC;AAC1C,IAAA,gBAAgB,GAAG,MAAM,CAAoB,EAAE,4DAAC;AAChD,IAAA,QAAQ,GAAG,MAAM,CAAC,KAAK,oDAAC;IACxB,aAAa,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,eAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAC;AAErF,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACjG;IAEQ,MAAM,cAAc,CAAC,MAAW,EAAA;AACtC,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,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
+
import { inject, input, signal, computed, effect, ChangeDetectionStrategy, Component, output } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import * as i1 from '@angular/common';
|
|
5
|
+
import { CommonModule, NgComponentOutlet, NgTemplateOutlet } from '@angular/common';
|
|
6
|
+
import * as i2 from '@angular/router';
|
|
7
|
+
import { RouterModule, ActivatedRoute, Router } from '@angular/router';
|
|
8
|
+
import { Color } from '@mintplayer/ng-bootstrap';
|
|
9
|
+
import { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';
|
|
10
|
+
import { BsButtonGroupComponent } from '@mintplayer/ng-bootstrap/button-group';
|
|
11
|
+
import { BsCardComponent, BsCardHeaderComponent } from '@mintplayer/ng-bootstrap/card';
|
|
12
|
+
import { BsContainerComponent } from '@mintplayer/ng-bootstrap/container';
|
|
13
|
+
import { BsGridComponent, BsGridRowDirective, BsGridColumnDirective } from '@mintplayer/ng-bootstrap/grid';
|
|
14
|
+
import { BsTableComponent } from '@mintplayer/ng-bootstrap/table';
|
|
15
|
+
import { BsTabControlComponent, BsTabPageComponent, BsTabPageHeaderDirective } from '@mintplayer/ng-bootstrap/tab-control';
|
|
16
|
+
import { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';
|
|
17
|
+
import { SparkService, SparkLanguageService } from '@mintplayer/ng-spark/services';
|
|
18
|
+
import { ResolveTranslationPipe, TranslateKeyPipe, AttributeValuePipe, RawAttributeValuePipe, AsDetailColumnsPipe, AsDetailCellValuePipe, ArrayValuePipe, ReferenceLinkRoutePipe } from '@mintplayer/ng-spark/pipes';
|
|
19
|
+
import { SparkIconComponent } from '@mintplayer/ng-spark/icon';
|
|
20
|
+
import { DatatableSettings, BsDatatableComponent, BsDatatableColumnDirective, BsRowTemplateDirective } from '@mintplayer/ng-bootstrap/datatable';
|
|
21
|
+
import { VirtualDatatableDataSource, BsVirtualDatatableComponent, BsVirtualRowTemplateDirective } from '@mintplayer/ng-bootstrap/virtual-datatable';
|
|
22
|
+
import { SPARK_ATTRIBUTE_RENDERERS } from '@mintplayer/ng-spark/renderers';
|
|
23
|
+
import { hasShowedOnFlag, ShowedOn } from '@mintplayer/ng-spark/models';
|
|
24
|
+
|
|
25
|
+
class SparkSubQueryComponent {
|
|
26
|
+
sparkService = inject(SparkService);
|
|
27
|
+
rendererRegistry = inject(SPARK_ATTRIBUTE_RENDERERS);
|
|
28
|
+
queryId = input.required(...(ngDevMode ? [{ debugName: "queryId" }] : []));
|
|
29
|
+
parentId = input.required(...(ngDevMode ? [{ debugName: "parentId" }] : []));
|
|
30
|
+
parentType = input.required(...(ngDevMode ? [{ debugName: "parentType" }] : []));
|
|
31
|
+
query = signal(null, ...(ngDevMode ? [{ debugName: "query" }] : []));
|
|
32
|
+
entityType = signal(null, ...(ngDevMode ? [{ debugName: "entityType" }] : []));
|
|
33
|
+
allEntityTypes = signal([], ...(ngDevMode ? [{ debugName: "allEntityTypes" }] : []));
|
|
34
|
+
paginationData = signal(undefined, ...(ngDevMode ? [{ debugName: "paginationData" }] : []));
|
|
35
|
+
lookupReferenceOptions = signal({}, ...(ngDevMode ? [{ debugName: "lookupReferenceOptions" }] : []));
|
|
36
|
+
loading = signal(true, ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
37
|
+
canRead = signal(false, ...(ngDevMode ? [{ debugName: "canRead" }] : []));
|
|
38
|
+
settings = signal(new DatatableSettings({
|
|
39
|
+
perPage: { values: [10, 25, 50], selected: 10 },
|
|
40
|
+
page: { values: [1], selected: 1 },
|
|
41
|
+
sortColumns: []
|
|
42
|
+
}), ...(ngDevMode ? [{ debugName: "settings" }] : []));
|
|
43
|
+
virtualDataSource = signal(null, ...(ngDevMode ? [{ debugName: "virtualDataSource" }] : []));
|
|
44
|
+
virtualSettings = signal(new DatatableSettings({
|
|
45
|
+
sortColumns: []
|
|
46
|
+
}), ...(ngDevMode ? [{ debugName: "virtualSettings" }] : []));
|
|
47
|
+
visibleAttributes = computed(() => {
|
|
48
|
+
return this.entityType()?.attributes
|
|
49
|
+
.filter(a => a.isVisible && hasShowedOnFlag(a.showedOn, ShowedOn.Query))
|
|
50
|
+
.sort((a, b) => a.order - b.order) || [];
|
|
51
|
+
}, ...(ngDevMode ? [{ debugName: "visibleAttributes" }] : []));
|
|
52
|
+
constructor() {
|
|
53
|
+
effect(() => {
|
|
54
|
+
const qId = this.queryId();
|
|
55
|
+
const pId = this.parentId();
|
|
56
|
+
const pType = this.parentType();
|
|
57
|
+
if (qId && pId && pType) {
|
|
58
|
+
this.loadData(qId, pId, pType);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async loadData(queryId, parentId, parentType) {
|
|
63
|
+
this.loading.set(true);
|
|
64
|
+
try {
|
|
65
|
+
const [resolvedQuery, entityTypes] = await Promise.all([
|
|
66
|
+
this.sparkService.getQuery(queryId),
|
|
67
|
+
this.sparkService.getEntityTypes()
|
|
68
|
+
]);
|
|
69
|
+
this.query.set(resolvedQuery);
|
|
70
|
+
this.allEntityTypes.set(entityTypes);
|
|
71
|
+
const initialSortColumns = (resolvedQuery.sortColumns || []).map(sc => ({
|
|
72
|
+
property: sc.property,
|
|
73
|
+
direction: sc.direction === 'desc' ? 'descending' : 'ascending'
|
|
74
|
+
}));
|
|
75
|
+
// Resolve entity type from query's entityType field
|
|
76
|
+
if (resolvedQuery.entityType) {
|
|
77
|
+
const et = entityTypes.find(t => t.name === resolvedQuery.entityType || t.alias === resolvedQuery.entityType?.toLowerCase());
|
|
78
|
+
this.entityType.set(et || null);
|
|
79
|
+
if (et) {
|
|
80
|
+
const permissions = await this.sparkService.getPermissions(et.id);
|
|
81
|
+
this.canRead.set(permissions.canRead);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (resolvedQuery.renderMode === 'VirtualScrolling') {
|
|
85
|
+
this.virtualSettings.set(new DatatableSettings({ sortColumns: initialSortColumns }));
|
|
86
|
+
this.virtualDataSource.set(new VirtualDatatableDataSource((skip, take) => this.sparkService.executeQuery(resolvedQuery.id, {
|
|
87
|
+
sortColumns: this.virtualSettings().sortColumns,
|
|
88
|
+
skip, take,
|
|
89
|
+
parentId, parentType,
|
|
90
|
+
}).then(r => ({ data: r.data, totalRecords: r.totalRecords })), 50));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.settings.set(new DatatableSettings({
|
|
94
|
+
perPage: { values: [10, 25, 50], selected: 10 },
|
|
95
|
+
page: { values: [1], selected: 1 },
|
|
96
|
+
sortColumns: initialSortColumns
|
|
97
|
+
}));
|
|
98
|
+
await this.loadPage(resolvedQuery.id, parentId, parentType);
|
|
99
|
+
}
|
|
100
|
+
this.loadLookupReferenceOptions();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
this.paginationData.set(undefined);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
this.loading.set(false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async loadPage(queryId, parentId, parentType) {
|
|
110
|
+
const s = this.settings();
|
|
111
|
+
const result = await this.sparkService.executeQuery(queryId, {
|
|
112
|
+
sortColumns: s.sortColumns,
|
|
113
|
+
skip: (s.page.selected - 1) * s.perPage.selected,
|
|
114
|
+
take: s.perPage.selected,
|
|
115
|
+
parentId, parentType,
|
|
116
|
+
});
|
|
117
|
+
const totalPages = Math.ceil(result.totalRecords / s.perPage.selected) || 1;
|
|
118
|
+
this.paginationData.set({
|
|
119
|
+
data: result.data,
|
|
120
|
+
totalRecords: result.totalRecords,
|
|
121
|
+
totalPages,
|
|
122
|
+
perPage: s.perPage.selected,
|
|
123
|
+
page: s.page.selected,
|
|
124
|
+
});
|
|
125
|
+
s.page.values = Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
126
|
+
}
|
|
127
|
+
onSettingsChange() {
|
|
128
|
+
const q = this.query();
|
|
129
|
+
if (!q)
|
|
130
|
+
return;
|
|
131
|
+
if (q.renderMode === 'VirtualScrolling') {
|
|
132
|
+
this.virtualDataSource()?.reset();
|
|
133
|
+
const pId = this.parentId();
|
|
134
|
+
const pType = this.parentType();
|
|
135
|
+
this.virtualDataSource.set(new VirtualDatatableDataSource((skip, take) => this.sparkService.executeQuery(q.id, {
|
|
136
|
+
sortColumns: this.virtualSettings().sortColumns,
|
|
137
|
+
skip, take,
|
|
138
|
+
parentId: pId, parentType: pType,
|
|
139
|
+
}).then(r => ({ data: r.data, totalRecords: r.totalRecords })), 50));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.loadPage(q.id, this.parentId(), this.parentType());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async loadLookupReferenceOptions() {
|
|
146
|
+
const lookupAttrs = this.visibleAttributes().filter(a => a.lookupReferenceType);
|
|
147
|
+
if (lookupAttrs.length === 0)
|
|
148
|
+
return;
|
|
149
|
+
const lookupNames = [...new Set(lookupAttrs.map(a => a.lookupReferenceType))];
|
|
150
|
+
const entries = await Promise.all(lookupNames.map(async (name) => {
|
|
151
|
+
const result = await this.sparkService.getLookupReference(name);
|
|
152
|
+
return [name, result];
|
|
153
|
+
}));
|
|
154
|
+
this.lookupReferenceOptions.set(entries.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}));
|
|
155
|
+
}
|
|
156
|
+
getColumnRendererComponent(attr) {
|
|
157
|
+
if (!attr.renderer)
|
|
158
|
+
return null;
|
|
159
|
+
return this.rendererRegistry.find(r => r.name === attr.renderer)?.columnComponent ?? null;
|
|
160
|
+
}
|
|
161
|
+
getColumnRendererInputs(item, attr) {
|
|
162
|
+
const itemAttr = item.attributes.find(a => a.name === attr.name);
|
|
163
|
+
return {
|
|
164
|
+
value: itemAttr?.value,
|
|
165
|
+
attribute: attr,
|
|
166
|
+
options: attr.rendererOptions,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkSubQueryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
170
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: SparkSubQueryComponent, isStandalone: true, selector: "spark-sub-query", inputs: { queryId: { classPropertyName: "queryId", publicName: "queryId", isSignal: true, isRequired: true, transformFunction: null }, parentId: { classPropertyName: "parentId", publicName: "parentId", isSignal: true, isRequired: true, transformFunction: null }, parentType: { classPropertyName: "parentType", publicName: "parentType", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (query(); as q) {\n <bs-card style=\"display: block; margin: 1rem 0;\">\n <bs-card-header>{{ (q.description | resolveTranslation) || q.name }}</bs-card-header>\n @if (loading()) {\n <div class=\"text-center p-3\">\n <bs-spinner />\n </div>\n } @else if (q.renderMode === 'VirtualScrolling') {\n @if (virtualDataSource(); as vds) {\n <div class=\"p-3 d-flex flex-column\" style=\"height: 400px;\">\n <bs-virtual-datatable class=\"flex-grow-1 overflow-hidden\"\n [(settings)]=\"virtualSettings\"\n [dataSource]=\"vds\"\n [isResponsive]=\"true\"\n (settingsChange)=\"onSettingsChange()\">\n @for (attr of visibleAttributes(); track attr.id) {\n <div *bsDatatableColumn=\"attr.name; sortable: true\">\n {{ (attr.label | resolveTranslation) || attr.name }}\n </div>\n }\n\n <ng-template bsVirtualRowTemplate let-item>\n @for (attr of visibleAttributes(); track attr.id; let first = $first) {\n <td>\n @if (item) {\n @if (first && canRead()) {\n <a [routerLink]=\"['/po', entityType()!.alias || entityType()!.id, item.id]\">\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n </a>\n } @else {\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n }\n } @else {\n \n }\n </td>\n }\n </ng-template>\n </bs-virtual-datatable>\n </div>\n }\n } @else {\n <div class=\"p-3\">\n @if (!paginationData() || paginationData()!.totalRecords === 0) {\n <div class=\"text-center text-muted\">\n {{ 'common.noItemsFound' | t }}\n </div>\n } @else {\n <bs-datatable [(settings)]=\"settings\" (settingsChange)=\"onSettingsChange()\">\n @for (attr of visibleAttributes(); track attr.id) {\n <div *bsDatatableColumn=\"attr.name; sortable: true\">\n {{ (attr.label | resolveTranslation) || attr.name }}\n </div>\n }\n\n <tr *bsRowTemplate=\"let item of paginationData()\">\n @for (attr of visibleAttributes(); track attr.id; let first = $first) {\n <td>\n @if (first && canRead()) {\n <a [routerLink]=\"['/po', entityType()!.alias || entityType()!.id, item.id]\">\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n </a>\n } @else {\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n }\n </td>\n }\n </tr>\n </bs-datatable>\n }\n </div>\n }\n </bs-card>\n}\n\n<ng-template #cellContent let-item let-attr=\"attr\">\n @if (getColumnRendererComponent(attr); as rendererType) {\n <ng-container *ngComponentOutlet=\"rendererType; inputs: getColumnRendererInputs(item, attr)\"></ng-container>\n } @else if (attr.dataType === 'boolean') {\n <input type=\"checkbox\"\n [checked]=\"(attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes()) === true\"\n disabled\n onclick=\"return false;\">\n } @else if (attr.dataType === 'color') {\n @let colorVal = (attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes());\n @if (colorVal) {\n <span class=\"d-inline-block align-middle border rounded\" [style.background-color]=\"colorVal\" style=\"width: 1.5em; height: 1.5em;\"></span>\n }\n } @else {\n {{ (attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes()) }}\n }\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: RouterModule }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: BsCardComponent, selector: "bs-card", inputs: ["rounded"] }, { kind: "component", type: BsCardHeaderComponent, selector: "bs-card-header", inputs: ["noPadding"] }, { kind: "component", type: BsDatatableComponent, selector: "bs-datatable", inputs: ["data"], outputs: ["dataChange"] }, { kind: "directive", type: BsDatatableColumnDirective, selector: "[bsDatatableColumn]", inputs: ["bsDatatableColumn", "bsDatatableColumnSortable"] }, { kind: "directive", type: BsRowTemplateDirective, selector: "[bsRowTemplate]", inputs: ["bsRowTemplateOf"] }, { kind: "component", type: BsVirtualDatatableComponent, selector: "bs-virtual-datatable", inputs: ["dataSource", "isResponsive", "itemSize"] }, { kind: "directive", type: BsVirtualRowTemplateDirective, selector: "[bsVirtualRowTemplate]" }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "pipe", type: ResolveTranslationPipe, name: "resolveTranslation" }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }, { kind: "pipe", type: AttributeValuePipe, name: "attributeValue" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
171
|
+
}
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkSubQueryComponent, decorators: [{
|
|
173
|
+
type: Component,
|
|
174
|
+
args: [{ selector: 'spark-sub-query', imports: [CommonModule, NgComponentOutlet, RouterModule, BsCardComponent, BsCardHeaderComponent, BsDatatableComponent, BsDatatableColumnDirective, BsRowTemplateDirective, BsVirtualDatatableComponent, BsVirtualRowTemplateDirective, BsTableComponent, BsSpinnerComponent, ResolveTranslationPipe, TranslateKeyPipe, AttributeValuePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (query(); as q) {\n <bs-card style=\"display: block; margin: 1rem 0;\">\n <bs-card-header>{{ (q.description | resolveTranslation) || q.name }}</bs-card-header>\n @if (loading()) {\n <div class=\"text-center p-3\">\n <bs-spinner />\n </div>\n } @else if (q.renderMode === 'VirtualScrolling') {\n @if (virtualDataSource(); as vds) {\n <div class=\"p-3 d-flex flex-column\" style=\"height: 400px;\">\n <bs-virtual-datatable class=\"flex-grow-1 overflow-hidden\"\n [(settings)]=\"virtualSettings\"\n [dataSource]=\"vds\"\n [isResponsive]=\"true\"\n (settingsChange)=\"onSettingsChange()\">\n @for (attr of visibleAttributes(); track attr.id) {\n <div *bsDatatableColumn=\"attr.name; sortable: true\">\n {{ (attr.label | resolveTranslation) || attr.name }}\n </div>\n }\n\n <ng-template bsVirtualRowTemplate let-item>\n @for (attr of visibleAttributes(); track attr.id; let first = $first) {\n <td>\n @if (item) {\n @if (first && canRead()) {\n <a [routerLink]=\"['/po', entityType()!.alias || entityType()!.id, item.id]\">\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n </a>\n } @else {\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n }\n } @else {\n \n }\n </td>\n }\n </ng-template>\n </bs-virtual-datatable>\n </div>\n }\n } @else {\n <div class=\"p-3\">\n @if (!paginationData() || paginationData()!.totalRecords === 0) {\n <div class=\"text-center text-muted\">\n {{ 'common.noItemsFound' | t }}\n </div>\n } @else {\n <bs-datatable [(settings)]=\"settings\" (settingsChange)=\"onSettingsChange()\">\n @for (attr of visibleAttributes(); track attr.id) {\n <div *bsDatatableColumn=\"attr.name; sortable: true\">\n {{ (attr.label | resolveTranslation) || attr.name }}\n </div>\n }\n\n <tr *bsRowTemplate=\"let item of paginationData()\">\n @for (attr of visibleAttributes(); track attr.id; let first = $first) {\n <td>\n @if (first && canRead()) {\n <a [routerLink]=\"['/po', entityType()!.alias || entityType()!.id, item.id]\">\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n </a>\n } @else {\n <ng-container *ngTemplateOutlet=\"cellContent; context: { $implicit: item, attr: attr }\"></ng-container>\n }\n </td>\n }\n </tr>\n </bs-datatable>\n }\n </div>\n }\n </bs-card>\n}\n\n<ng-template #cellContent let-item let-attr=\"attr\">\n @if (getColumnRendererComponent(attr); as rendererType) {\n <ng-container *ngComponentOutlet=\"rendererType; inputs: getColumnRendererInputs(item, attr)\"></ng-container>\n } @else if (attr.dataType === 'boolean') {\n <input type=\"checkbox\"\n [checked]=\"(attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes()) === true\"\n disabled\n onclick=\"return false;\">\n } @else if (attr.dataType === 'color') {\n @let colorVal = (attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes());\n @if (colorVal) {\n <span class=\"d-inline-block align-middle border rounded\" [style.background-color]=\"colorVal\" style=\"width: 1.5em; height: 1.5em;\"></span>\n }\n } @else {\n {{ (attr.name | attributeValue:item:entityType():lookupReferenceOptions():allEntityTypes()) }}\n }\n</ng-template>\n" }]
|
|
175
|
+
}], ctorParameters: () => [], propDecorators: { queryId: [{ type: i0.Input, args: [{ isSignal: true, alias: "queryId", required: true }] }], parentId: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentId", required: true }] }], parentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentType", required: true }] }] } });
|
|
176
|
+
|
|
177
|
+
class SparkPoDetailComponent {
|
|
178
|
+
route = inject(ActivatedRoute);
|
|
179
|
+
router = inject(Router);
|
|
180
|
+
sparkService = inject(SparkService);
|
|
181
|
+
lang = inject(SparkLanguageService);
|
|
182
|
+
rendererRegistry = inject(SPARK_ATTRIBUTE_RENDERERS);
|
|
183
|
+
showCustomActions = input(true, ...(ngDevMode ? [{ debugName: "showCustomActions" }] : []));
|
|
184
|
+
extraActionsTemplate = input(null, ...(ngDevMode ? [{ debugName: "extraActionsTemplate" }] : []));
|
|
185
|
+
extraContentTemplate = input(null, ...(ngDevMode ? [{ debugName: "extraContentTemplate" }] : []));
|
|
186
|
+
edited = output();
|
|
187
|
+
deleted = output();
|
|
188
|
+
customActionExecuted = output();
|
|
189
|
+
colors = Color;
|
|
190
|
+
errorMessage = signal(null, ...(ngDevMode ? [{ debugName: "errorMessage" }] : []));
|
|
191
|
+
entityType = signal(null, ...(ngDevMode ? [{ debugName: "entityType" }] : []));
|
|
192
|
+
allEntityTypes = signal([], ...(ngDevMode ? [{ debugName: "allEntityTypes" }] : []));
|
|
193
|
+
item = signal(null, ...(ngDevMode ? [{ debugName: "item" }] : []));
|
|
194
|
+
lookupReferenceOptions = signal({}, ...(ngDevMode ? [{ debugName: "lookupReferenceOptions" }] : []));
|
|
195
|
+
asDetailTypes = signal({}, ...(ngDevMode ? [{ debugName: "asDetailTypes" }] : []));
|
|
196
|
+
asDetailReferenceOptions = signal({}, ...(ngDevMode ? [{ debugName: "asDetailReferenceOptions" }] : []));
|
|
197
|
+
type = '';
|
|
198
|
+
id = '';
|
|
199
|
+
canEdit = signal(false, ...(ngDevMode ? [{ debugName: "canEdit" }] : []));
|
|
200
|
+
canDelete = signal(false, ...(ngDevMode ? [{ debugName: "canDelete" }] : []));
|
|
201
|
+
customActions = signal([], ...(ngDevMode ? [{ debugName: "customActions" }] : []));
|
|
202
|
+
constructor() {
|
|
203
|
+
this.route.paramMap.pipe(takeUntilDestroyed()).subscribe(params => this.onParamsChange(params));
|
|
204
|
+
}
|
|
205
|
+
async onParamsChange(params) {
|
|
206
|
+
this.type = params.get('type') || '';
|
|
207
|
+
this.id = params.get('id') || '';
|
|
208
|
+
try {
|
|
209
|
+
const [entityTypes, item] = await Promise.all([
|
|
210
|
+
this.sparkService.getEntityTypes(),
|
|
211
|
+
this.sparkService.get(this.type, this.id)
|
|
212
|
+
]);
|
|
213
|
+
this.allEntityTypes.set(entityTypes);
|
|
214
|
+
this.entityType.set(entityTypes.find(t => t.id === this.type || t.alias === this.type) || null);
|
|
215
|
+
this.item.set(item);
|
|
216
|
+
this.loadLookupReferenceOptions();
|
|
217
|
+
this.loadAsDetailTypes();
|
|
218
|
+
const et = this.entityType();
|
|
219
|
+
if (et) {
|
|
220
|
+
const [permissions, actions] = await Promise.all([
|
|
221
|
+
this.sparkService.getPermissions(et.id),
|
|
222
|
+
this.sparkService.getCustomActions(et.id)
|
|
223
|
+
]);
|
|
224
|
+
this.canEdit.set(permissions.canEdit);
|
|
225
|
+
this.canDelete.set(permissions.canDelete);
|
|
226
|
+
this.customActions.set(actions.filter(a => a.showedOn === 'detail' || a.showedOn === 'both'));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
const error = e;
|
|
231
|
+
this.errorMessage.set(error.error?.error || error.message || 'An unexpected error occurred');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
visibleAttributes = computed(() => {
|
|
235
|
+
return this.entityType()?.attributes
|
|
236
|
+
.filter(a => a.isVisible && hasShowedOnFlag(a.showedOn, ShowedOn.PersistentObject))
|
|
237
|
+
.sort((a, b) => a.order - b.order) || [];
|
|
238
|
+
}, ...(ngDevMode ? [{ debugName: "visibleAttributes" }] : []));
|
|
239
|
+
static DEFAULT_TAB = { id: '__default__', name: 'Algemeen', label: { nl: 'Algemeen', en: 'General' }, order: 0 };
|
|
240
|
+
ungroupedAttributes = computed(() => {
|
|
241
|
+
const attrs = this.visibleAttributes();
|
|
242
|
+
const groupIds = new Set((this.entityType()?.groups || []).map(g => g.id));
|
|
243
|
+
return attrs.filter(a => !a.group || !groupIds.has(a.group));
|
|
244
|
+
}, ...(ngDevMode ? [{ debugName: "ungroupedAttributes" }] : []));
|
|
245
|
+
resolvedTabs = computed(() => {
|
|
246
|
+
const et = this.entityType();
|
|
247
|
+
const definedTabs = et?.tabs?.length ? [...et.tabs].sort((a, b) => a.order - b.order) : [];
|
|
248
|
+
const hasUngroupedAttrs = this.ungroupedAttributes().length > 0;
|
|
249
|
+
const hasUntabbedGroups = (et?.groups || []).some(g => !g.tab);
|
|
250
|
+
if (hasUngroupedAttrs || hasUntabbedGroups || definedTabs.length === 0) {
|
|
251
|
+
return [SparkPoDetailComponent.DEFAULT_TAB, ...definedTabs];
|
|
252
|
+
}
|
|
253
|
+
return definedTabs;
|
|
254
|
+
}, ...(ngDevMode ? [{ debugName: "resolvedTabs" }] : []));
|
|
255
|
+
groupsForTab(tab) {
|
|
256
|
+
const groups = this.entityType()?.groups || [];
|
|
257
|
+
if (tab.id === '__default__') {
|
|
258
|
+
return groups.filter(g => !g.tab).sort((a, b) => a.order - b.order);
|
|
259
|
+
}
|
|
260
|
+
return groups.filter(g => g.tab === tab.id).sort((a, b) => a.order - b.order);
|
|
261
|
+
}
|
|
262
|
+
attrsForGroup(group) {
|
|
263
|
+
return this.visibleAttributes().filter(a => a.group === group.id);
|
|
264
|
+
}
|
|
265
|
+
getDetailRendererComponent(attr) {
|
|
266
|
+
if (!attr.renderer)
|
|
267
|
+
return null;
|
|
268
|
+
return this.rendererRegistry.find(r => r.name === attr.renderer)?.detailComponent ?? null;
|
|
269
|
+
}
|
|
270
|
+
getDetailRendererInputs(attr, item) {
|
|
271
|
+
const itemAttr = item.attributes.find(a => a.name === attr.name);
|
|
272
|
+
const formData = {};
|
|
273
|
+
for (const a of item.attributes) {
|
|
274
|
+
formData[a.name] = a.value;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
value: itemAttr?.value,
|
|
278
|
+
attribute: attr,
|
|
279
|
+
options: attr.rendererOptions,
|
|
280
|
+
formData,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
async loadLookupReferenceOptions() {
|
|
284
|
+
const lookupAttrs = this.visibleAttributes().filter(a => a.lookupReferenceType);
|
|
285
|
+
if (lookupAttrs.length === 0)
|
|
286
|
+
return;
|
|
287
|
+
const lookupNames = [...new Set(lookupAttrs.map(a => a.lookupReferenceType))];
|
|
288
|
+
const entries = await Promise.all(lookupNames.map(async (name) => {
|
|
289
|
+
const result = await this.sparkService.getLookupReference(name);
|
|
290
|
+
return [name, result];
|
|
291
|
+
}));
|
|
292
|
+
this.lookupReferenceOptions.set(entries.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}));
|
|
293
|
+
}
|
|
294
|
+
async loadAsDetailTypes() {
|
|
295
|
+
const asDetailAttrs = this.visibleAttributes().filter(a => a.dataType === 'AsDetail' && a.isArray && a.asDetailType);
|
|
296
|
+
if (asDetailAttrs.length === 0)
|
|
297
|
+
return;
|
|
298
|
+
const types = this.allEntityTypes();
|
|
299
|
+
const newAsDetailTypes = {};
|
|
300
|
+
for (const attr of asDetailAttrs) {
|
|
301
|
+
const asDetailType = types.find(t => t.clrType === attr.asDetailType);
|
|
302
|
+
if (asDetailType) {
|
|
303
|
+
newAsDetailTypes[attr.name] = asDetailType;
|
|
304
|
+
const refCols = asDetailType.attributes.filter(a => a.dataType === 'Reference' && a.query);
|
|
305
|
+
if (refCols.length > 0) {
|
|
306
|
+
const refEntries = await Promise.all(refCols.map(async (col) => {
|
|
307
|
+
const result = await this.sparkService.executeQueryByName(col.query, {
|
|
308
|
+
parentId: this.id,
|
|
309
|
+
parentType: this.type,
|
|
310
|
+
});
|
|
311
|
+
return [col.name, result.data];
|
|
312
|
+
}));
|
|
313
|
+
this.asDetailReferenceOptions.update(prev => ({
|
|
314
|
+
...prev,
|
|
315
|
+
[attr.name]: refEntries.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
this.asDetailTypes.set(newAsDetailTypes);
|
|
321
|
+
}
|
|
322
|
+
async onCustomAction(action) {
|
|
323
|
+
if (action.confirmationMessageKey) {
|
|
324
|
+
const message = this.lang.t(action.confirmationMessageKey) || 'Are you sure?';
|
|
325
|
+
if (!confirm(message))
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
await this.sparkService.executeCustomAction(this.type, action.name, this.item() || undefined);
|
|
330
|
+
this.customActionExecuted.emit({ action, item: this.item() });
|
|
331
|
+
if (action.refreshOnCompleted) {
|
|
332
|
+
const item = await this.sparkService.get(this.type, this.id);
|
|
333
|
+
this.item.set(item);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
catch (e) {
|
|
337
|
+
const err = e;
|
|
338
|
+
this.errorMessage.set(err.error?.error || err.message || 'Action failed');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
onEdit() {
|
|
342
|
+
this.edited.emit();
|
|
343
|
+
this.router.navigate(['/po', this.type, this.id, 'edit']);
|
|
344
|
+
}
|
|
345
|
+
async onDelete() {
|
|
346
|
+
if (confirm(this.lang.t('confirmDelete'))) {
|
|
347
|
+
await this.sparkService.delete(this.type, this.id);
|
|
348
|
+
this.deleted.emit();
|
|
349
|
+
this.router.navigate(['/']);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
onBack() {
|
|
353
|
+
window.history.back();
|
|
354
|
+
}
|
|
355
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkPoDetailComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
356
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: SparkPoDetailComponent, isStandalone: true, selector: "spark-po-detail", inputs: { showCustomActions: { classPropertyName: "showCustomActions", publicName: "showCustomActions", isSignal: true, isRequired: false, transformFunction: null }, extraActionsTemplate: { classPropertyName: "extraActionsTemplate", publicName: "extraActionsTemplate", isSignal: true, isRequired: false, transformFunction: null }, extraContentTemplate: { classPropertyName: "extraContentTemplate", publicName: "extraContentTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { edited: "edited", deleted: "deleted", customActionExecuted: "customActionExecuted" }, ngImport: i0, template: "<bs-container>\n<div class=\"container\">\n @if (errorMessage(); as err) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">\n {{ err }}\n </bs-alert>\n } @else if (item(); as currentItem) {\n @if (entityType(); as et) {\n <div class=\"d-flex justify-content-between align-items-center mb-4\">\n <h2>{{ currentItem.breadcrumb || currentItem.name }}</h2>\n <bs-button-group>\n <button class=\"btn btn-outline-secondary\" (click)=\"onBack()\">\n <spark-icon name=\"arrow-left\" /> {{ 'common.back' | t }}\n </button>\n @if (canEdit()) {\n <button class=\"btn btn-primary\" (click)=\"onEdit()\">\n <spark-icon name=\"pencil\" /> {{ 'common.edit' | t }}\n </button>\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n }\n @if (showCustomActions()) {\n @for (action of customActions(); track action.name) {\n <button class=\"btn btn-outline-primary\" (click)=\"onCustomAction(action)\">\n {{ action.displayName | resolveTranslation }}\n </button>\n }\n }\n @if (canDelete()) {\n <button class=\"btn btn-danger\" (click)=\"onDelete()\">\n <spark-icon name=\"trash\" /> {{ 'common.delete' | t }}\n </button>\n }\n </bs-button-group>\n </div>\n\n <bs-grid>\n <bs-tab-control>\n @for (tab of resolvedTabs(); track tab.id) {\n <bs-tab-page>\n <ng-template bsTabPageHeader>{{ tab.label | resolveTranslation:tab.name }}</ng-template>\n <ng-container *ngTemplateOutlet=\"detailTabContent; context: { $implicit: tab }\"></ng-container>\n </bs-tab-page>\n }\n </bs-tab-control>\n\n <ng-template #detailTabContent let-tab>\n @if (tab.id === '__default__') {\n @let ungroupedAttrs = ungroupedAttributes();\n @if (ungroupedAttrs.length > 0) {\n <bs-card style=\"display: block; margin: 1rem;\">\n <div class=\"p-3\">\n <dl bsRow>\n @for (attr of ungroupedAttrs; track attr.id) {\n <ng-container *ngTemplateOutlet=\"detailAttrField; context: { $implicit: attr, item: currentItem }\"></ng-container>\n }\n </dl>\n </div>\n </bs-card>\n }\n }\n @for (group of groupsForTab(tab); track group.id) {\n @if (attrsForGroup(group); as groupAttrs) {\n @if (groupAttrs.length > 0) {\n <bs-card style=\"display: block; margin: 1rem;\">\n @if (group.label) {\n <bs-card-header>{{ group.label | resolveTranslation:group.name }}</bs-card-header>\n }\n <div class=\"p-3\">\n <dl bsRow>\n @for (attr of groupAttrs; track attr.id) {\n <ng-container *ngTemplateOutlet=\"detailAttrField; context: { $implicit: attr, item: currentItem }\"></ng-container>\n }\n </dl>\n </div>\n </bs-card>\n }\n }\n }\n </ng-template>\n\n <ng-template #detailAttrField let-attr let-currentItem=\"item\">\n <dt [sm]=\"3\">{{ (attr.label | resolveTranslation) || attr.name }}</dt>\n <dd [sm]=\"9\">\n @if (getDetailRendererComponent(attr); as rendererType) {\n <ng-container *ngComponentOutlet=\"rendererType; inputs: getDetailRendererInputs(attr, currentItem)\"></ng-container>\n } @else if (attr.dataType === 'AsDetail' && attr.isArray) {\n <bs-table [isResponsive]=\"true\">\n <thead>\n <tr>\n @for (col of (attr | asDetailColumns:asDetailTypes()); track col.name) {\n <th>{{ (col.label | resolveTranslation) || col.name }}</th>\n }\n </tr>\n </thead>\n <tbody class=\"align-middle\">\n @for (row of (attr.name | arrayValue:currentItem); track $index) {\n <tr>\n @for (col of (attr | asDetailColumns:asDetailTypes()); track col.name) {\n <td>\n @if (col.dataType === 'Reference' && col.referenceType) {\n @let route = (col.referenceType | referenceLinkRoute:row[col.name]:allEntityTypes());\n @if (route) {\n <a [routerLink]=\"route\">{{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}</a>\n } @else {\n {{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}\n }\n } @else {\n {{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}\n }\n </td>\n }\n </tr>\n } @empty {\n <tr>\n <td [attr.colspan]=\"(attr | asDetailColumns:asDetailTypes()).length\" class=\"text-center text-muted\">\n {{ 'common.noItemsFound' | t }}\n </td>\n </tr>\n }\n </tbody>\n </bs-table>\n } @else if (attr.dataType === 'boolean') {\n <input type=\"checkbox\"\n [checked]=\"(attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) === true\"\n [indeterminate]=\"(attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) == null\"\n disabled\n onclick=\"return false;\"\n style=\"opacity: 1;\">\n } @else if (attr.dataType === 'color') {\n @let colorVal = (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes());\n @if (colorVal) {\n <span class=\"d-inline-block align-middle border rounded me-2\" [style.background-color]=\"colorVal\" style=\"width: 1.5em; height: 1.5em;\"></span>\n {{ colorVal }}\n } @else {\n -\n }\n } @else if (attr.dataType === 'Reference' && attr.referenceType) {\n @let refRoute = (attr.referenceType | referenceLinkRoute:(attr.name | rawAttributeValue:item()):allEntityTypes());\n @if (refRoute && (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes())) {\n <a [routerLink]=\"refRoute\">{{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) }}</a>\n } @else {\n {{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) || '-' }}\n }\n } @else {\n {{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) || '-' }}\n }\n </dd>\n </ng-template>\n </bs-grid>\n @if (et.queries?.length) {\n @for (queryAlias of et.queries; track queryAlias) {\n <spark-sub-query [queryId]=\"queryAlias\" [parentId]=\"currentItem.id!\" [parentType]=\"et.name\" />\n }\n }\n @if (extraContentTemplate(); as extraContentTpl) {\n <ng-container *ngTemplateOutlet=\"extraContentTpl; context: { $implicit: currentItem, entityType: et }\"></ng-container>\n }\n }\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n</bs-container>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: RouterModule }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: BsAlertComponent, selector: "bs-alert", inputs: ["type", "isVisible"], outputs: ["isVisibleChange", "afterOpenedOrClosed"] }, { kind: "component", type: BsButtonGroupComponent, selector: "bs-button-group" }, { kind: "component", type: BsCardComponent, selector: "bs-card", inputs: ["rounded"] }, { kind: "component", type: BsCardHeaderComponent, selector: "bs-card-header", inputs: ["noPadding"] }, { kind: "component", type: BsContainerComponent, selector: "bs-container" }, { kind: "component", type: BsGridComponent, selector: "bs-grid", inputs: ["stopFullWidthAt"] }, { kind: "directive", type: BsGridRowDirective, selector: "[bsRow]" }, { kind: "directive", type: BsGridColumnDirective, selector: "[xxs],[xs],[sm],[md],[lg],[xl],[xxl]", inputs: ["xxs", "xs", "sm", "md", "lg", "xl", "xxl"] }, { kind: "component", type: BsTableComponent, selector: "bs-table", inputs: ["isResponsive", "striped", "hover"] }, { kind: "component", type: BsTabControlComponent, selector: "bs-tab-control", inputs: ["border", "restrictDragging", "selectFirstTab", "tabsPosition", "allowDragDrop"] }, { kind: "component", type: BsTabPageComponent, selector: "bs-tab-page", inputs: ["disabled"] }, { kind: "directive", type: BsTabPageHeaderDirective, selector: "[bsTabPageHeader]" }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "component", type: SparkIconComponent, selector: "spark-icon", inputs: ["name"] }, { kind: "component", type: SparkSubQueryComponent, selector: "spark-sub-query", inputs: ["queryId", "parentId", "parentType"] }, { kind: "pipe", type: ResolveTranslationPipe, name: "resolveTranslation" }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }, { kind: "pipe", type: AttributeValuePipe, name: "attributeValue" }, { kind: "pipe", type: RawAttributeValuePipe, name: "rawAttributeValue" }, { kind: "pipe", type: AsDetailColumnsPipe, name: "asDetailColumns" }, { kind: "pipe", type: AsDetailCellValuePipe, name: "asDetailCellValue" }, { kind: "pipe", type: ArrayValuePipe, name: "arrayValue" }, { kind: "pipe", type: ReferenceLinkRoutePipe, name: "referenceLinkRoute" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
357
|
+
}
|
|
358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: SparkPoDetailComponent, decorators: [{
|
|
359
|
+
type: Component,
|
|
360
|
+
args: [{ selector: 'spark-po-detail', imports: [CommonModule, NgTemplateOutlet, NgComponentOutlet, RouterModule, BsAlertComponent, BsButtonGroupComponent, BsCardComponent, BsCardHeaderComponent, BsContainerComponent, BsGridComponent, BsGridRowDirective, BsGridColumnDirective, BsTableComponent, BsTabControlComponent, BsTabPageComponent, BsTabPageHeaderDirective, BsSpinnerComponent, SparkIconComponent, SparkSubQueryComponent, ResolveTranslationPipe, TranslateKeyPipe, AttributeValuePipe, RawAttributeValuePipe, AsDetailColumnsPipe, AsDetailCellValuePipe, ArrayValuePipe, ReferenceLinkRoutePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-container>\n<div class=\"container\">\n @if (errorMessage(); as err) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">\n {{ err }}\n </bs-alert>\n } @else if (item(); as currentItem) {\n @if (entityType(); as et) {\n <div class=\"d-flex justify-content-between align-items-center mb-4\">\n <h2>{{ currentItem.breadcrumb || currentItem.name }}</h2>\n <bs-button-group>\n <button class=\"btn btn-outline-secondary\" (click)=\"onBack()\">\n <spark-icon name=\"arrow-left\" /> {{ 'common.back' | t }}\n </button>\n @if (canEdit()) {\n <button class=\"btn btn-primary\" (click)=\"onEdit()\">\n <spark-icon name=\"pencil\" /> {{ 'common.edit' | t }}\n </button>\n }\n @if (extraActionsTemplate(); as extraActionsTpl) {\n <ng-container *ngTemplateOutlet=\"extraActionsTpl\"></ng-container>\n }\n @if (showCustomActions()) {\n @for (action of customActions(); track action.name) {\n <button class=\"btn btn-outline-primary\" (click)=\"onCustomAction(action)\">\n {{ action.displayName | resolveTranslation }}\n </button>\n }\n }\n @if (canDelete()) {\n <button class=\"btn btn-danger\" (click)=\"onDelete()\">\n <spark-icon name=\"trash\" /> {{ 'common.delete' | t }}\n </button>\n }\n </bs-button-group>\n </div>\n\n <bs-grid>\n <bs-tab-control>\n @for (tab of resolvedTabs(); track tab.id) {\n <bs-tab-page>\n <ng-template bsTabPageHeader>{{ tab.label | resolveTranslation:tab.name }}</ng-template>\n <ng-container *ngTemplateOutlet=\"detailTabContent; context: { $implicit: tab }\"></ng-container>\n </bs-tab-page>\n }\n </bs-tab-control>\n\n <ng-template #detailTabContent let-tab>\n @if (tab.id === '__default__') {\n @let ungroupedAttrs = ungroupedAttributes();\n @if (ungroupedAttrs.length > 0) {\n <bs-card style=\"display: block; margin: 1rem;\">\n <div class=\"p-3\">\n <dl bsRow>\n @for (attr of ungroupedAttrs; track attr.id) {\n <ng-container *ngTemplateOutlet=\"detailAttrField; context: { $implicit: attr, item: currentItem }\"></ng-container>\n }\n </dl>\n </div>\n </bs-card>\n }\n }\n @for (group of groupsForTab(tab); track group.id) {\n @if (attrsForGroup(group); as groupAttrs) {\n @if (groupAttrs.length > 0) {\n <bs-card style=\"display: block; margin: 1rem;\">\n @if (group.label) {\n <bs-card-header>{{ group.label | resolveTranslation:group.name }}</bs-card-header>\n }\n <div class=\"p-3\">\n <dl bsRow>\n @for (attr of groupAttrs; track attr.id) {\n <ng-container *ngTemplateOutlet=\"detailAttrField; context: { $implicit: attr, item: currentItem }\"></ng-container>\n }\n </dl>\n </div>\n </bs-card>\n }\n }\n }\n </ng-template>\n\n <ng-template #detailAttrField let-attr let-currentItem=\"item\">\n <dt [sm]=\"3\">{{ (attr.label | resolveTranslation) || attr.name }}</dt>\n <dd [sm]=\"9\">\n @if (getDetailRendererComponent(attr); as rendererType) {\n <ng-container *ngComponentOutlet=\"rendererType; inputs: getDetailRendererInputs(attr, currentItem)\"></ng-container>\n } @else if (attr.dataType === 'AsDetail' && attr.isArray) {\n <bs-table [isResponsive]=\"true\">\n <thead>\n <tr>\n @for (col of (attr | asDetailColumns:asDetailTypes()); track col.name) {\n <th>{{ (col.label | resolveTranslation) || col.name }}</th>\n }\n </tr>\n </thead>\n <tbody class=\"align-middle\">\n @for (row of (attr.name | arrayValue:currentItem); track $index) {\n <tr>\n @for (col of (attr | asDetailColumns:asDetailTypes()); track col.name) {\n <td>\n @if (col.dataType === 'Reference' && col.referenceType) {\n @let route = (col.referenceType | referenceLinkRoute:row[col.name]:allEntityTypes());\n @if (route) {\n <a [routerLink]=\"route\">{{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}</a>\n } @else {\n {{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}\n }\n } @else {\n {{ (row | asDetailCellValue:attr:col:asDetailReferenceOptions()) }}\n }\n </td>\n }\n </tr>\n } @empty {\n <tr>\n <td [attr.colspan]=\"(attr | asDetailColumns:asDetailTypes()).length\" class=\"text-center text-muted\">\n {{ 'common.noItemsFound' | t }}\n </td>\n </tr>\n }\n </tbody>\n </bs-table>\n } @else if (attr.dataType === 'boolean') {\n <input type=\"checkbox\"\n [checked]=\"(attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) === true\"\n [indeterminate]=\"(attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) == null\"\n disabled\n onclick=\"return false;\"\n style=\"opacity: 1;\">\n } @else if (attr.dataType === 'color') {\n @let colorVal = (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes());\n @if (colorVal) {\n <span class=\"d-inline-block align-middle border rounded me-2\" [style.background-color]=\"colorVal\" style=\"width: 1.5em; height: 1.5em;\"></span>\n {{ colorVal }}\n } @else {\n -\n }\n } @else if (attr.dataType === 'Reference' && attr.referenceType) {\n @let refRoute = (attr.referenceType | referenceLinkRoute:(attr.name | rawAttributeValue:item()):allEntityTypes());\n @if (refRoute && (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes())) {\n <a [routerLink]=\"refRoute\">{{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) }}</a>\n } @else {\n {{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) || '-' }}\n }\n } @else {\n {{ (attr.name | attributeValue:item():entityType():lookupReferenceOptions():allEntityTypes()) || '-' }}\n }\n </dd>\n </ng-template>\n </bs-grid>\n @if (et.queries?.length) {\n @for (queryAlias of et.queries; track queryAlias) {\n <spark-sub-query [queryId]=\"queryAlias\" [parentId]=\"currentItem.id!\" [parentType]=\"et.name\" />\n }\n }\n @if (extraContentTemplate(); as extraContentTpl) {\n <ng-container *ngTemplateOutlet=\"extraContentTpl; context: { $implicit: currentItem, entityType: et }\"></ng-container>\n }\n }\n } @else {\n <div class=\"text-center p-5\">\n <bs-spinner />\n </div>\n }\n</div>\n</bs-container>\n" }]
|
|
361
|
+
}], ctorParameters: () => [], propDecorators: { showCustomActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCustomActions", required: false }] }], extraActionsTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "extraActionsTemplate", required: false }] }], extraContentTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "extraContentTemplate", required: false }] }], edited: [{ type: i0.Output, args: ["edited"] }], deleted: [{ type: i0.Output, args: ["deleted"] }], customActionExecuted: [{ type: i0.Output, args: ["customActionExecuted"] }] } });
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Generated bundle index. Do not edit.
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
export { SparkPoDetailComponent, SparkSubQueryComponent };
|
|
368
|
+
//# sourceMappingURL=mintplayer-ng-spark-po-detail.mjs.map
|