@yuuvis/client-framework 2.3.30 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/fesm2022/yuuvis-client-framework-forms.mjs +2 -2
  2. package/fesm2022/yuuvis-client-framework-forms.mjs.map +1 -1
  3. package/fesm2022/yuuvis-client-framework-object-relationship.mjs +988 -0
  4. package/fesm2022/yuuvis-client-framework-object-relationship.mjs.map +1 -0
  5. package/fesm2022/yuuvis-client-framework-renderer.mjs +15 -15
  6. package/fesm2022/yuuvis-client-framework-renderer.mjs.map +1 -1
  7. package/lib/assets/i18n/de.json +20 -0
  8. package/lib/assets/i18n/en.json +20 -0
  9. package/object-relationship/README.md +3 -0
  10. package/object-relationship/index.d.ts +4 -0
  11. package/object-relationship/lib/actions/add-relationship/add-relationship.component.d.ts +25 -0
  12. package/object-relationship/lib/actions/relationship-target-search/relationship-target-search.component.d.ts +23 -0
  13. package/object-relationship/lib/node-summary/node-summary.component.d.ts +26 -0
  14. package/object-relationship/lib/object-relationship-graph/object-relationship-graph.component.d.ts +30 -0
  15. package/object-relationship/lib/object-relationship-list/object-relationship-list-item/object-relationship-list-item.component.d.ts +14 -0
  16. package/object-relationship/lib/object-relationship-list/object-relationship-list.component.d.ts +13 -0
  17. package/object-relationship/lib/object-relationship.component.d.ts +23 -0
  18. package/object-relationship/lib/object-relationship.const.d.ts +7 -0
  19. package/object-relationship/lib/object-relationship.interface.d.ts +38 -0
  20. package/object-relationship/lib/object-relationship.module.d.ts +7 -0
  21. package/object-relationship/lib/object-relationship.service.d.ts +26 -0
  22. package/package.json +13 -8
  23. package/renderer/lib/renderer.directive.d.ts +0 -5
@@ -0,0 +1,988 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, signal, Injectable, input, computed, Component, forwardRef, viewChild, effect, output, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { MatButtonToggleModule } from '@angular/material/button-toggle';
6
+ import * as i1$3 from '@angular/material/icon';
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import * as i2 from '@angular/material/tooltip';
9
+ import { MatTooltipModule } from '@angular/material/tooltip';
10
+ import * as i3 from '@yuuvis/client-core';
11
+ import { SearchService, DmsService, EventService, TranslateService, YuvEventType, SystemType, RelationshipTypeField, DmsObject, BaseObjectTypeField, SystemService, TranslateModule } from '@yuuvis/client-core';
12
+ import { YmtButtonDirective, YmtIconButtonDirective } from '@yuuvis/material';
13
+ import * as i4$1 from '@yuuvis/material/panes';
14
+ import { YmtPanesModule } from '@yuuvis/material/panes';
15
+ import { ConfirmService, DialogComponent, BusyOverlayDirective, LayoutSettingsService } from '@yuuvis/client-framework/common';
16
+ import { DataSet, Network } from 'vis-network/standalone';
17
+ import { rxResource, takeUntilDestroyed } from '@angular/core/rxjs-interop';
18
+ import { switchMap, map, of, catchError, tap } from 'rxjs';
19
+ import { RendererDirective } from '@yuuvis/client-framework/renderer';
20
+ import { Router } from '@angular/router';
21
+ import * as i1$2 from '@angular/forms';
22
+ import { FormControl, Validators, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormGroup } from '@angular/forms';
23
+ import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
24
+ import * as i3$1 from '@angular/material/form-field';
25
+ import { MatFormFieldModule, MatError } from '@angular/material/form-field';
26
+ import * as i4 from '@angular/material/select';
27
+ import { MatSelectModule } from '@angular/material/select';
28
+ import * as i1$1 from '@yuuvis/client-framework/autocomplete';
29
+ import { YuvAutocompleteModule } from '@yuuvis/client-framework/autocomplete';
30
+ import { SnackBarService } from '@yuuvis/client-framework';
31
+
32
+ const ROOT_NODE_SETTINGS = {
33
+ size: 30,
34
+ borderWidth: 4,
35
+ borderWidthSelected: 6,
36
+ };
37
+ const ROOT_NODE_FONT_SETTINGS = {
38
+ size: 14,
39
+ };
40
+ const NODE_SETTINGS = {
41
+ borderWidthSelected: 2,
42
+ };
43
+ const NODE_FONT_SETTINGS = {
44
+ size: 12,
45
+ };
46
+ const EDGE_SETTINGS = {};
47
+ const EDGE_FONT_SETTINGS = {
48
+ size: 10,
49
+ };
50
+
51
+ class ObjectRelationshipService {
52
+ #search;
53
+ #dmsService;
54
+ #eventService;
55
+ #confirm;
56
+ #relationQA;
57
+ #relationsResource;
58
+ constructor() {
59
+ this.#search = inject(SearchService);
60
+ this.#dmsService = inject(DmsService);
61
+ this.#eventService = inject(EventService);
62
+ this.#confirm = inject(ConfirmService);
63
+ this.translate = inject(TranslateService);
64
+ this.#relationQA = {};
65
+ this.objectId = signal(undefined);
66
+ this.#relationsResource = rxResource({
67
+ request: this.objectId,
68
+ loader: ({ request }) => this.fetchRelations(request)
69
+ });
70
+ this.relations = this.#relationsResource.value;
71
+ this.busy = signal(false);
72
+ // the DmsObject representing the originId
73
+ this.object = signal(null);
74
+ this.#eventService
75
+ .on(YuvEventType.RELATIONSHIP_CREATED, YuvEventType.RELATIONSHIP_DELETED)
76
+ .pipe(takeUntilDestroyed())
77
+ .subscribe({
78
+ next: (e) => {
79
+ if (e.data?.sourceObjectId === this.objectId()) {
80
+ this.#relationsResource.reload();
81
+ }
82
+ }
83
+ });
84
+ }
85
+ fetchRelations(originId) {
86
+ this.busy.set(true);
87
+ // search for relations that have this object as source or target
88
+ const query = `SELECT * FROM ${SystemType.RELATIONSHIP} WHERE ${RelationshipTypeField.SOURCE_ID} = '${originId}' OR ${RelationshipTypeField.TARGET_ID} = '${originId}'`;
89
+ return this.#search
90
+ .searchCmis(query)
91
+ .pipe(switchMap((resRelations) => {
92
+ // collect source and target ids and ensure uniqueness
93
+ const o = {};
94
+ resRelations.items.forEach((i) => {
95
+ this.#relationQA[i.fields.get(BaseObjectTypeField.OBJECT_ID)] = new DmsObject(i);
96
+ o[i.fields.get(RelationshipTypeField.SOURCE_ID)] = null;
97
+ o[i.fields.get(RelationshipTypeField.TARGET_ID)] = null;
98
+ });
99
+ // get the data for these object ids
100
+ const ids = Object.keys(o)
101
+ .map((id) => `'${id}'`)
102
+ .join(',');
103
+ const q = `SELECT * FROM system:object WHERE ${BaseObjectTypeField.OBJECT_ID} IN (${ids})`;
104
+ return this.#search.searchCmis(q).pipe(map((resObjects) => ({
105
+ relations: resRelations,
106
+ objects: resObjects
107
+ })));
108
+ }))
109
+ .pipe(
110
+ // catchError
111
+ map((res) => {
112
+ this.busy.set(false);
113
+ return { originId, relations: res.relations, objects: res.objects };
114
+ }));
115
+ }
116
+ /**
117
+ * Deletes a relationship by its ID. Will ask for confirmation before deletion.
118
+ * @param relationId ID of the relationship to delete
119
+ * @param reloadResource Whether to reload the resource after deletion
120
+ */
121
+ deleteRelationship(relationId, reloadResource) {
122
+ return this.#confirm
123
+ .confirm({
124
+ message: this.translate.instant('yuv.object-relationship.delete-relation.confirm-message')
125
+ })
126
+ .pipe(switchMap((confirmed) => (confirmed ? this.#deleteRelationship(relationId, reloadResource) : of(false))));
127
+ }
128
+ #deleteRelationship(relationId, reloadResource) {
129
+ this.busy.set(true);
130
+ return this.#dmsService.deleteDmsObject(relationId).pipe(catchError(() => of(false)), map((err) => (err === false ? false : true)), tap((success) => {
131
+ this.busy.set(false);
132
+ if (success) {
133
+ this.#eventService.trigger(YuvEventType.RELATIONSHIP_DELETED, { relationId });
134
+ if (reloadResource) {
135
+ this.#relationsResource.reload();
136
+ }
137
+ }
138
+ }));
139
+ }
140
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
141
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipService }); }
142
+ }
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipService, decorators: [{
144
+ type: Injectable
145
+ }], ctorParameters: () => [] });
146
+
147
+ /**
148
+ * Component to display a summary of a node's object properties.
149
+ */
150
+ class NodeSummaryComponent {
151
+ constructor() {
152
+ this.#system = inject(SystemService);
153
+ this.#router = inject(Router);
154
+ this.object = input();
155
+ this.nodeConfig = input();
156
+ this.actions = input(null);
157
+ this.nodeSummary = computed(() => {
158
+ const obj = this.object();
159
+ const config = this.nodeConfig();
160
+ return obj && config
161
+ ? {
162
+ title: obj.data[config.labelField],
163
+ description: config.descriptionField ? obj.data[config.descriptionField] : undefined,
164
+ properties: (config.summaryFields || []).map((field) => this.#propertyToRendererInput(field, obj)).filter((p) => !!p),
165
+ link: config.objectLink ? config.objectLink.replace('{{id}}', obj.id) : undefined
166
+ }
167
+ : null;
168
+ });
169
+ }
170
+ #system;
171
+ #router;
172
+ openObject(link) {
173
+ console.log('Navigating to link:', link);
174
+ this.#router.navigateByUrl(link);
175
+ }
176
+ #propertyToRendererInput(propertyName, object) {
177
+ const metaKeys = Object.keys(object.data).filter((key) => {
178
+ return key.startsWith(`${propertyName}_`);
179
+ });
180
+ const sr = this.#system.system?.allFields[propertyName];
181
+ if (!sr)
182
+ return undefined;
183
+ return {
184
+ label: this.#system.getLocalizedLabel(propertyName.replace('_title', '')) || propertyName,
185
+ rendererInput: {
186
+ propertyName,
187
+ value: object.data[propertyName],
188
+ rendererType: this.#system.getInternalFormElementType(propertyName, sr.classifications || []),
189
+ meta: metaKeys.reduce((metaObj, key) => {
190
+ metaObj[key] = object.data[key];
191
+ return metaObj;
192
+ }, {})
193
+ }
194
+ };
195
+ }
196
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NodeSummaryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
197
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: NodeSummaryComponent, isStandalone: true, selector: "yuv-node-summary", inputs: { object: { classPropertyName: "object", publicName: "object", isSignal: true, isRequired: false, transformFunction: null }, nodeConfig: { classPropertyName: "nodeConfig", publicName: "nodeConfig", isSignal: true, isRequired: false, transformFunction: null }, actions: { classPropertyName: "actions", publicName: "actions", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@let ns = nodeSummary();\n@if (ns) {\n <header>\n <h2>{{ ns?.title }}</h2>\n <p class=\"desc\">{{ ns?.description }}</p>\n </header>\n <main>\n <div class=\"properties\">\n @for (p of ns?.properties; track $index) {\n <div class=\"row\">\n <div class=\"label\">{{ p.label }}</div>\n <div class=\"value\">\n <ng-container *yuvRenderer=\"p.rendererInput\"></ng-container>\n </div>\n </div>\n }\n </div>\n </main>\n <footer>\n <div class=\"actions\">\n <ng-container *ngTemplateOutlet=\"actions()\"></ng-container>\n </div>\n\n @if (ns.link) {\n <button ymtButton=\"primary\" (click)=\"openObject(ns.link)\">\n {{ 'yuv.object-relationship.node-summary.open-object.button' | translate }}\n </button>\n }\n </footer>\n}\n", styles: [":host{display:flex;flex-direction:column}:host header{flex:0 0 auto}:host header h2{margin-block-end:0}:host header .desc{margin:0;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host main{flex:1;overflow-y:auto}:host footer{flex:0 0 auto;align-items:center;display:flex}:host footer .actions{flex:1;display:flex;align-items:center}:host .properties{container:section/inline-size;margin-block-start:var(--ymt-spacing-xl);display:flex;flex-direction:column}:host .properties .row{display:flex;flex-flow:column}:host .properties .row .label{font:var(--ymt-font-body-subtle);flex:0 1 33%;font-weight:700;padding-inline-end:var(--ymt-spacing-m);margin-block-end:var(--ymt-spacing-3xs);text-overflow:ellipsis;overflow:hidden;white-space:nowrap}:host .properties .row .value{flex:1;word-break:break-all;font:var(--ymt-font-body-subtle);margin-block-end:var(--ymt-spacing-xs)}@container section (min-width: 300px){:host .properties .row{flex-flow:row}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RendererDirective, selector: "[yuvRenderer]", inputs: ["yuvRenderer"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }] }); }
198
+ }
199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NodeSummaryComponent, decorators: [{
200
+ type: Component,
201
+ args: [{ selector: 'yuv-node-summary', imports: [CommonModule, RendererDirective, TranslateModule, YmtButtonDirective], template: "@let ns = nodeSummary();\n@if (ns) {\n <header>\n <h2>{{ ns?.title }}</h2>\n <p class=\"desc\">{{ ns?.description }}</p>\n </header>\n <main>\n <div class=\"properties\">\n @for (p of ns?.properties; track $index) {\n <div class=\"row\">\n <div class=\"label\">{{ p.label }}</div>\n <div class=\"value\">\n <ng-container *yuvRenderer=\"p.rendererInput\"></ng-container>\n </div>\n </div>\n }\n </div>\n </main>\n <footer>\n <div class=\"actions\">\n <ng-container *ngTemplateOutlet=\"actions()\"></ng-container>\n </div>\n\n @if (ns.link) {\n <button ymtButton=\"primary\" (click)=\"openObject(ns.link)\">\n {{ 'yuv.object-relationship.node-summary.open-object.button' | translate }}\n </button>\n }\n </footer>\n}\n", styles: [":host{display:flex;flex-direction:column}:host header{flex:0 0 auto}:host header h2{margin-block-end:0}:host header .desc{margin:0;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host main{flex:1;overflow-y:auto}:host footer{flex:0 0 auto;align-items:center;display:flex}:host footer .actions{flex:1;display:flex;align-items:center}:host .properties{container:section/inline-size;margin-block-start:var(--ymt-spacing-xl);display:flex;flex-direction:column}:host .properties .row{display:flex;flex-flow:column}:host .properties .row .label{font:var(--ymt-font-body-subtle);flex:0 1 33%;font-weight:700;padding-inline-end:var(--ymt-spacing-m);margin-block-end:var(--ymt-spacing-3xs);text-overflow:ellipsis;overflow:hidden;white-space:nowrap}:host .properties .row .value{flex:1;word-break:break-all;font:var(--ymt-font-body-subtle);margin-block-end:var(--ymt-spacing-xs)}@container section (min-width: 300px){:host .properties .row{flex-flow:row}}\n"] }]
202
+ }] });
203
+
204
+ class RelationshipTargetSearchComponent {
205
+ #searchService;
206
+ #configQA;
207
+ #value;
208
+ constructor() {
209
+ this.#searchService = inject(SearchService);
210
+ this.supportedRelationships = input.required();
211
+ this.availableTargetTypes = input([]);
212
+ this.config = input.required();
213
+ this.#configQA = computed(() => {
214
+ const qa = {};
215
+ this.config().nodes.forEach((c) => {
216
+ qa[c.objectType] = c;
217
+ });
218
+ return qa;
219
+ });
220
+ this.autocompleteRes = [];
221
+ this.busy = signal(false);
222
+ this.acFormControl = new FormControl([], Validators.required);
223
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
224
+ this.propagateChange = (_) => { };
225
+ this.acFormControl.valueChanges.subscribe((val) => {
226
+ this.#value = val && val.length > 0 ? val[0] : undefined;
227
+ this.propagateChange(this.#value?.value);
228
+ });
229
+ }
230
+ autocompleteFn(term) {
231
+ if (term.length >= 2) {
232
+ this.busy.set(true);
233
+ this.#searchService.search(this.#termToQuery(term)).subscribe({
234
+ next: (res) => {
235
+ this.busy.set(false);
236
+ this.autocompleteRes = res.items.map((item) => ({
237
+ label: this.#getLabel(item),
238
+ value: this.#searchResultItemToRecord(item)
239
+ }));
240
+ },
241
+ error: () => {
242
+ this.busy.set(false);
243
+ this.autocompleteRes = [];
244
+ }
245
+ });
246
+ }
247
+ else {
248
+ this.autocompleteRes = [];
249
+ }
250
+ }
251
+ #getLabel(sri) {
252
+ // determine the object type
253
+ const configType = this.availableTargetTypes().find((tt) => {
254
+ const objectType = sri.fields.get(BaseObjectTypeField.OBJECT_TYPE_ID);
255
+ const sots = sri.fields.get(BaseObjectTypeField.SECONDARY_OBJECT_TYPE_IDS);
256
+ return tt === objectType || (sots && sots.includes(tt));
257
+ });
258
+ const config = configType ? this.#configQA()[configType] : undefined;
259
+ return config ? sri.fields.get(config.labelField) : sri.fields.get(BaseObjectTypeField.OBJECT_ID);
260
+ }
261
+ #searchResultItemToRecord(item) {
262
+ return Array.from(item.fields.entries()).reduce((obj, [key, value]) => {
263
+ obj[key] = value;
264
+ return obj;
265
+ }, {});
266
+ }
267
+ #termToQuery(term) {
268
+ return {
269
+ term,
270
+ // filters: [
271
+ // {
272
+ // f: this.#targetTitleProperty,
273
+ // o: Operator.CONTAINS,
274
+ // v1: term
275
+ // }
276
+ // ],
277
+ types: this.availableTargetTypes()
278
+ };
279
+ }
280
+ writeValue(value) {
281
+ // this component is not supposed to accept values from outside
282
+ }
283
+ registerOnChange(fn) {
284
+ this.propagateChange = fn;
285
+ }
286
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
287
+ registerOnTouched(fn) { }
288
+ setDisabledState(isDisabled) {
289
+ if (isDisabled) {
290
+ this.acFormControl.disable();
291
+ }
292
+ else {
293
+ this.acFormControl.enable();
294
+ }
295
+ }
296
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: RelationshipTargetSearchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
297
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.15", type: RelationshipTargetSearchComponent, isStandalone: true, selector: "yuv-relationship-target-search", inputs: { supportedRelationships: { classPropertyName: "supportedRelationships", publicName: "supportedRelationships", isSignal: true, isRequired: true, transformFunction: null }, availableTargetTypes: { classPropertyName: "availableTargetTypes", publicName: "availableTargetTypes", isSignal: true, isRequired: false, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
298
+ {
299
+ provide: NG_VALUE_ACCESSOR,
300
+ useExisting: forwardRef(() => RelationshipTargetSearchComponent),
301
+ multi: true
302
+ }
303
+ ], ngImport: i0, template: "<mat-form-field>\n <mat-label>{{ 'yuv.object-relationship.add-relationship.target-search.label' | translate }}</mat-label>\n\n <yuv-autocomplete\n [required]=\"true\"\n [busy]=\"busy()\"\n [formControl]=\"acFormControl\"\n [autocompleteValues]=\"autocompleteRes\"\n [forceSelection]=\"true\"\n (autocompleteFnc)=\"autocompleteFn($event)\"\n [multiple]=\"true\"\n [maxItems]=\"1\"\n >\n <!-- template for chip -->\n <ng-template #chipTemplate let-item>\n <div class=\"label\">{{ item.label }}</div>\n <!-- <div class=\"meta\">{{ item.value[metaFieldProperty] }}</div> -->\n </ng-template>\n </yuv-autocomplete>\n</mat-form-field>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: YuvAutocompleteModule }, { kind: "component", type: i1$1.AutocompleteComponent, selector: "yuv-autocomplete", inputs: ["ariaLabel", "busy", "multiple", "distinctValues", "addOnBlur", "minLength", "maxItems", "forceSelection", "autocompleteValues"], outputs: ["autocompleteFnc", "acBlur"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1$2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }] }); }
304
+ }
305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: RelationshipTargetSearchComponent, decorators: [{
306
+ type: Component,
307
+ args: [{ selector: 'yuv-relationship-target-search', imports: [YuvAutocompleteModule, ReactiveFormsModule, TranslateModule, MatFormFieldModule], providers: [
308
+ {
309
+ provide: NG_VALUE_ACCESSOR,
310
+ useExisting: forwardRef(() => RelationshipTargetSearchComponent),
311
+ multi: true
312
+ }
313
+ ], template: "<mat-form-field>\n <mat-label>{{ 'yuv.object-relationship.add-relationship.target-search.label' | translate }}</mat-label>\n\n <yuv-autocomplete\n [required]=\"true\"\n [busy]=\"busy()\"\n [formControl]=\"acFormControl\"\n [autocompleteValues]=\"autocompleteRes\"\n [forceSelection]=\"true\"\n (autocompleteFnc)=\"autocompleteFn($event)\"\n [multiple]=\"true\"\n [maxItems]=\"1\"\n >\n <!-- template for chip -->\n <ng-template #chipTemplate let-item>\n <div class=\"label\">{{ item.label }}</div>\n <!-- <div class=\"meta\">{{ item.value[metaFieldProperty] }}</div> -->\n </ng-template>\n </yuv-autocomplete>\n</mat-form-field>\n" }]
314
+ }], ctorParameters: () => [] });
315
+
316
+ class AddRelationshipComponent {
317
+ constructor() {
318
+ this.#system = inject(SystemService);
319
+ this.#dialogData = inject(MAT_DIALOG_DATA);
320
+ this.#dialogRef = inject((MatDialogRef));
321
+ this.#dmsService = inject(DmsService);
322
+ this.#eventService = inject(EventService);
323
+ this.object = input(this.#dialogData.object);
324
+ this.config = input(this.#dialogData.config);
325
+ this.supportedRelationships = computed(() => {
326
+ const obj = this.object();
327
+ return obj ? this.#system.getSupportedRelationships(obj, true) : [];
328
+ });
329
+ // get the target types from the relationships
330
+ this.availableTargetTypes = computed(() => {
331
+ const rel = this.supportedRelationships();
332
+ return Array.from(new Set(rel.map((r) => r.allowedTargetTypes).flat()));
333
+ });
334
+ this.sourceNode = computed(() => {
335
+ const obj = this.object();
336
+ const config = this.config();
337
+ return {
338
+ title: obj.data[config.rootNode.labelField],
339
+ description: obj.data[config.rootNode.descriptionField || '']
340
+ };
341
+ });
342
+ this.#relationMatchesTargetObjectValidator = (control) => {
343
+ const targetObject = control.get('targetObject')?.value;
344
+ const relation = control.get('relation')?.value;
345
+ let valid = true;
346
+ if (relation && targetObject) {
347
+ // the allowed target types of the relation should be included in the selected objects
348
+ // SOTs or the selected object's type should include one of the allowed target types
349
+ const targetTypes = relation.allowedTargetTypes || [];
350
+ const objectType = targetObject[BaseObjectTypeField.OBJECT_TYPE_ID];
351
+ const sots = targetObject[BaseObjectTypeField.SECONDARY_OBJECT_TYPE_IDS];
352
+ valid = targetTypes.includes(objectType) || targetTypes.some((t) => sots?.includes(t));
353
+ }
354
+ return valid ? null : { invalidRelationTargetCombination: true };
355
+ };
356
+ this.form = new FormGroup({
357
+ relation: new FormControl(null, { nonNullable: true, validators: [Validators.required] }),
358
+ targetObject: new FormControl(null, { nonNullable: true, validators: [Validators.required] })
359
+ }, { validators: this.#relationMatchesTargetObjectValidator });
360
+ this.busy = signal(false);
361
+ }
362
+ #system;
363
+ #dialogData;
364
+ #dialogRef;
365
+ #dmsService;
366
+ #eventService;
367
+ #relationMatchesTargetObjectValidator;
368
+ optionCompareWith(o1, o2) {
369
+ return o1?.id === o2?.id;
370
+ }
371
+ submit() {
372
+ this.#addRelationship(this.form.value.relation.id, this.form.value.targetObject).subscribe({
373
+ next: () => this.close(),
374
+ error: () => {
375
+ // TODO: Handle error appropriately
376
+ }
377
+ });
378
+ }
379
+ #addRelationship(relationId, target) {
380
+ const data = {
381
+ [RelationshipTypeField.SOURCE_ID]: this.object().id,
382
+ [RelationshipTypeField.TARGET_ID]: target[BaseObjectTypeField.OBJECT_ID]
383
+ };
384
+ return this.#dmsService
385
+ .createDmsObject(relationId, data, [])
386
+ .pipe(tap(() => this.#eventService.trigger(YuvEventType.RELATIONSHIP_CREATED, { sourceObjectId: this.object().id })));
387
+ }
388
+ close() {
389
+ this.#dialogRef.close();
390
+ }
391
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AddRelationshipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
392
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: AddRelationshipComponent, isStandalone: true, selector: "yuv-add-relationship", inputs: { object: { classPropertyName: "object", publicName: "object", isSignal: true, isRequired: false, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<yuv-dialog class=\"not-separated\" [headertitel]=\"'yuv.object-relationship.add-relationship.headline' | translate\">\n <main [yuvBusyOverlay]=\"busy()\">\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n @let sn = sourceNode();\n @if (sn) {\n <div class=\"source\">\n {{ sn.title }}\n @if (sn.description) {\n <em>{{ sn.description }}</em>\n }\n </div>\n <div class=\"line\"></div>\n }\n <mat-form-field>\n <mat-label>{{ 'cm.app.cases.action.add-link.search.relation.label' | translate }}</mat-label>\n <mat-select formControlName=\"relation\" [compareWith]=\"optionCompareWith\">\n @for (r of supportedRelationships(); track r.id) {\n <mat-option [value]=\"r\">{{ r.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <div class=\"line\"></div>\n\n <yuv-relationship-target-search formControlName=\"targetObject\"\n [config]=\"config()\"\n [availableTargetTypes]=\"availableTargetTypes()\"\n [supportedRelationships]=\"supportedRelationships()\"\n ></yuv-relationship-target-search>\n\n @if (form.hasError('invalidRelationTargetCombination') && (form.touched || form.dirty)) {\n <mat-error class=\"error\">{{ 'yuv.object-relationship.add-relationship.error.invalidRelationTargetCombination' | translate }}</mat-error>\n }\n </form>\n </main>\n\n <footer>\n <button ymtButton=\"secondary\" type=\"button\" (click)=\"close()\" [disabled]=\"busy()\">\n {{ 'yuv.object-relationship.add-relationship.action.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" type=\"button\" (click)=\"submit()\" [disabled]=\"form.invalid || busy()\">\n {{ 'yuv.object-relationship.add-relationship.action.submit' | translate }}\n </button>\n </footer>\n</yuv-dialog>\n", styles: [":host main form{padding:var(--ymt-spacing-m);display:flex;flex-direction:column;gap:var(--ymt-spacing-xs);align-items:center}:host main form .source{border:2px solid var(--ymt-outline);border-radius:var(--ymt-corner-s);padding:var(--ymt-spacing-xs);display:flex;flex-direction:column}:host main form .source em{font-style:normal;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host main form .line{width:2px;background-color:var(--ymt-outline);min-height:2em;position:relative}:host main form .line:before{content:\"\";position:absolute;transform:rotate(135deg);width:8px;inset-block-end:0;translate:-3px 2px;height:8px;border:4px solid transparent;border-block-start-color:var(--ymt-outline);border-inline-end-color:var(--ymt-outline)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "component", type: DialogComponent, selector: "yuv-dialog", inputs: ["headertitel"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }, { kind: "component", type: RelationshipTargetSearchComponent, selector: "yuv-relationship-target-search", inputs: ["supportedRelationships", "availableTargetTypes", "config"] }, { kind: "directive", type: BusyOverlayDirective, selector: "[yuvBusyOverlay]", inputs: ["yuvBusyOverlay", "yuvBusyOverlayConfig"] }] }); }
393
+ }
394
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AddRelationshipComponent, decorators: [{
395
+ type: Component,
396
+ args: [{ selector: 'yuv-add-relationship', imports: [
397
+ CommonModule,
398
+ ReactiveFormsModule,
399
+ TranslateModule,
400
+ DialogComponent,
401
+ MatSelectModule,
402
+ MatFormFieldModule,
403
+ MatError,
404
+ YmtButtonDirective,
405
+ RelationshipTargetSearchComponent,
406
+ BusyOverlayDirective
407
+ ], template: "<yuv-dialog class=\"not-separated\" [headertitel]=\"'yuv.object-relationship.add-relationship.headline' | translate\">\n <main [yuvBusyOverlay]=\"busy()\">\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n @let sn = sourceNode();\n @if (sn) {\n <div class=\"source\">\n {{ sn.title }}\n @if (sn.description) {\n <em>{{ sn.description }}</em>\n }\n </div>\n <div class=\"line\"></div>\n }\n <mat-form-field>\n <mat-label>{{ 'cm.app.cases.action.add-link.search.relation.label' | translate }}</mat-label>\n <mat-select formControlName=\"relation\" [compareWith]=\"optionCompareWith\">\n @for (r of supportedRelationships(); track r.id) {\n <mat-option [value]=\"r\">{{ r.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <div class=\"line\"></div>\n\n <yuv-relationship-target-search formControlName=\"targetObject\"\n [config]=\"config()\"\n [availableTargetTypes]=\"availableTargetTypes()\"\n [supportedRelationships]=\"supportedRelationships()\"\n ></yuv-relationship-target-search>\n\n @if (form.hasError('invalidRelationTargetCombination') && (form.touched || form.dirty)) {\n <mat-error class=\"error\">{{ 'yuv.object-relationship.add-relationship.error.invalidRelationTargetCombination' | translate }}</mat-error>\n }\n </form>\n </main>\n\n <footer>\n <button ymtButton=\"secondary\" type=\"button\" (click)=\"close()\" [disabled]=\"busy()\">\n {{ 'yuv.object-relationship.add-relationship.action.cancel' | translate }}\n </button>\n <button ymtButton=\"primary\" type=\"button\" (click)=\"submit()\" [disabled]=\"form.invalid || busy()\">\n {{ 'yuv.object-relationship.add-relationship.action.submit' | translate }}\n </button>\n </footer>\n</yuv-dialog>\n", styles: [":host main form{padding:var(--ymt-spacing-m);display:flex;flex-direction:column;gap:var(--ymt-spacing-xs);align-items:center}:host main form .source{border:2px solid var(--ymt-outline);border-radius:var(--ymt-corner-s);padding:var(--ymt-spacing-xs);display:flex;flex-direction:column}:host main form .source em{font-style:normal;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host main form .line{width:2px;background-color:var(--ymt-outline);min-height:2em;position:relative}:host main form .line:before{content:\"\";position:absolute;transform:rotate(135deg);width:8px;inset-block-end:0;translate:-3px 2px;height:8px;border:4px solid transparent;border-block-start-color:var(--ymt-outline);border-inline-end-color:var(--ymt-outline)}\n"] }]
408
+ }] });
409
+
410
+ class ObjectRelationshipGraphComponent {
411
+ constructor() {
412
+ this.#dialog = inject(MatDialog);
413
+ this.#system = inject(SystemService);
414
+ this.#layoutSettings = inject(LayoutSettingsService);
415
+ this.#objectRelationshipService = inject(ObjectRelationshipService);
416
+ this.#snack = inject(SnackBarService);
417
+ this.translate = inject(TranslateService);
418
+ this.container = viewChild.required('graphContainer');
419
+ this.#mode = computed(() => {
420
+ const m = this.#layoutSettings.mode();
421
+ switch (m) {
422
+ case 'dark': {
423
+ return 'dark';
424
+ }
425
+ case 'system': {
426
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
427
+ }
428
+ default: {
429
+ return 'light';
430
+ }
431
+ }
432
+ });
433
+ this.#relations = this.#objectRelationshipService.relations;
434
+ this.#relationsEffect = effect(() => {
435
+ const rel = this.#relations();
436
+ if (!rel)
437
+ return;
438
+ // this.#outerObjectNodeIds = rel.objects.items.map((i) => i.fields.get(BaseObjectTypeField.OBJECT_ID) as string);
439
+ this.#_updateGraph(rel.originId, rel.relations, rel.objects);
440
+ });
441
+ /**
442
+ * Configuration for the relations component.
443
+ */
444
+ this.config = input.required();
445
+ this.objectSelected = output();
446
+ this.relationSelected = output();
447
+ this.#network = null;
448
+ this.#objectQA = {};
449
+ this.#relationQA = {};
450
+ this.#nodes = new DataSet([]);
451
+ this.#edges = new DataSet([]);
452
+ this.busy = signal(false);
453
+ this.selectedRelation = signal(null);
454
+ this.#selectedRelationEffect = effect(() => {
455
+ this.relationSelected.emit(this.selectedRelation());
456
+ });
457
+ this.selectedObject = signal(null);
458
+ this.#selectedObjectEffect = effect(() => {
459
+ const so = this.selectedObject();
460
+ if (so)
461
+ this.selectedRelation.set(null);
462
+ this.objectSelected.emit(so);
463
+ });
464
+ this.detailsNode = computed(() => {
465
+ const object = this.selectedObject();
466
+ const config = this.#getNodeConfig(object);
467
+ return object && config ? { object, config } : null;
468
+ });
469
+ }
470
+ #dialog;
471
+ #system;
472
+ #layoutSettings;
473
+ #objectRelationshipService;
474
+ #snack;
475
+ #mode;
476
+ #relations;
477
+ #relationsEffect;
478
+ #network;
479
+ #objectQA;
480
+ #relationQA;
481
+ #nodes;
482
+ #edges;
483
+ #selectedRelationEffect;
484
+ #selectedObjectEffect;
485
+ download() {
486
+ const canvas = this.container().nativeElement.querySelector('canvas');
487
+ const image = canvas.toDataURL('image/png');
488
+ const link = document.createElement('a');
489
+ link.href = image;
490
+ link.download = 'canvas-image.png';
491
+ link.click();
492
+ link.remove();
493
+ }
494
+ addRelationship() {
495
+ this.#dialog
496
+ .open(AddRelationshipComponent, {
497
+ data: {
498
+ object: this.selectedObject(),
499
+ config: this.config()
500
+ }
501
+ })
502
+ .afterClosed()
503
+ .subscribe((result) => {
504
+ this.expandSelected();
505
+ });
506
+ }
507
+ deleteRelationship() {
508
+ this.#objectRelationshipService.deleteRelationship(this.selectedRelation().id, false).subscribe((success) => {
509
+ if (success) {
510
+ this.#edges.remove(this.selectedRelation().id);
511
+ }
512
+ else {
513
+ this.#snack.danger(this.translate.instant('yuv.object-relationship.delete-relation.error-message'));
514
+ }
515
+ });
516
+ }
517
+ expandSelected() {
518
+ const selected = this.selectedObject();
519
+ if (selected) {
520
+ this.#expand(selected.id);
521
+ }
522
+ }
523
+ #expand(nodeId) {
524
+ if (nodeId) {
525
+ this.busy.set(true);
526
+ this.#objectRelationshipService.fetchRelations(nodeId).subscribe({
527
+ next: (res) => {
528
+ this.#_updateGraph(nodeId, res.relations, res.objects);
529
+ this.busy.set(false);
530
+ },
531
+ error: (err) => {
532
+ console.error('Error fetching relations for node:', err);
533
+ this.busy.set(false);
534
+ }
535
+ });
536
+ }
537
+ }
538
+ #_updateGraph(originId, relations, objects) {
539
+ objects.items.forEach((item) => {
540
+ const id = item.fields.get(BaseObjectTypeField.OBJECT_ID);
541
+ this.#objectQA[id] = new DmsObject(item);
542
+ });
543
+ relations.items.forEach((item) => {
544
+ const id = item.fields.get(BaseObjectTypeField.OBJECT_ID);
545
+ this.#relationQA[id] = new DmsObject(item);
546
+ });
547
+ // group by incoming and outgoing relations
548
+ const incoming = relations.items.filter((item) => item.fields.get(RelationshipTypeField.TARGET_ID) === originId);
549
+ const outgoing = relations.items.filter((item) => item.fields.get(RelationshipTypeField.SOURCE_ID) === originId);
550
+ const rootNode = this.#toNode(originId);
551
+ const _nodes = originId === this.#relations()?.originId
552
+ ? [
553
+ {
554
+ ...rootNode,
555
+ ...ROOT_NODE_SETTINGS,
556
+ font: {
557
+ ...ROOT_NODE_FONT_SETTINGS,
558
+ ...this.#getNodeFont()
559
+ }
560
+ }
561
+ ]
562
+ : [];
563
+ const _edges = [];
564
+ // add nodes and edges from search result
565
+ outgoing.forEach((item) => {
566
+ const relatedObjectId = item.fields.get(RelationshipTypeField.TARGET_ID);
567
+ const n = this.#toNode(relatedObjectId);
568
+ const e = this.#toEdge(item, originId, relatedObjectId, 'from');
569
+ if (n) {
570
+ // check if the node is already in the rendered graph
571
+ const nodeExists = _nodes.some((node) => node.id === n.id) || this.#nodes.get([n.id]).length > 0;
572
+ if (!nodeExists)
573
+ _nodes.push(n);
574
+ // check if edge already exists
575
+ const edgeExists = _edges.some((edge) => edge.id === e.id) || this.#edges.get([e.id]).length > 0;
576
+ if (!edgeExists)
577
+ _edges.push(e);
578
+ }
579
+ });
580
+ incoming.forEach((item) => {
581
+ const relatedObjectId = item.fields.get(RelationshipTypeField.SOURCE_ID);
582
+ const n = this.#toNode(relatedObjectId);
583
+ const e = this.#toEdge(item, relatedObjectId, originId, 'to');
584
+ if (n) {
585
+ // check if the node is already in the rendered graph
586
+ const nodeExists = _nodes.some((node) => node.id === n.id) || this.#nodes.get([n.id]).length > 0;
587
+ if (!nodeExists)
588
+ _nodes.push(n);
589
+ // check if edge already exists
590
+ const edgeExists = _edges.some((edge) => edge.id === e.id) || this.#edges.get([e.id]).length > 0;
591
+ if (!edgeExists)
592
+ _edges.push(e);
593
+ }
594
+ });
595
+ this.#nodes.add(_nodes);
596
+ this.#edges.add(_edges);
597
+ }
598
+ #getNodeConfig(o) {
599
+ const cfg = this.config();
600
+ if (!o)
601
+ return undefined;
602
+ const objectTypeIds = [...o.sots, o.objectTypeId];
603
+ return [cfg.rootNode, ...cfg.nodes].find((n) => objectTypeIds.includes(n.objectType));
604
+ }
605
+ // convert search result item to vis node
606
+ // will return NULL if the item object type is not configured in the component config
607
+ #toNode(objectId) {
608
+ const cfg = this.config();
609
+ const o = this.#objectQA[objectId];
610
+ if (!o)
611
+ return null;
612
+ const cfgNode = this.#getNodeConfig(o);
613
+ if (!cfgNode)
614
+ return null;
615
+ return {
616
+ ...NODE_SETTINGS,
617
+ objectType: cfgNode.objectType,
618
+ color: this.#getNodeColor(),
619
+ id: objectId,
620
+ label: this.#maxLength(o.data[cfgNode.labelField], 30),
621
+ icon: {
622
+ face: 'Material Symbols Sharp',
623
+ code: cfgNode.icon,
624
+ color: this.#getNodeColor().border
625
+ },
626
+ font: {
627
+ ...NODE_FONT_SETTINGS,
628
+ ...this.#getNodeFont()
629
+ }
630
+ };
631
+ }
632
+ #toEdge(item, from, to, direction) {
633
+ const label = this.#system.getLocalizedLabel(item.fields.get(BaseObjectTypeField.OBJECT_TYPE_ID)) || item.fields.get(BaseObjectTypeField.OBJECT_TYPE_ID);
634
+ return {
635
+ ...EDGE_SETTINGS,
636
+ id: item.fields.get(BaseObjectTypeField.OBJECT_ID),
637
+ label: this.#maxLength(label, 30),
638
+ color: this.#getEdgeColor(),
639
+ font: {
640
+ ...EDGE_FONT_SETTINGS,
641
+ ...this.#getEdgeFont()
642
+ },
643
+ arrows: direction,
644
+ from,
645
+ to
646
+ };
647
+ }
648
+ #maxLength(s, max) {
649
+ if (s.length > max) {
650
+ return s.substring(0, max - 3) + '...';
651
+ }
652
+ return s;
653
+ }
654
+ #getNodeColor() {
655
+ const computedStyle = this.#getComputedStyle();
656
+ return {
657
+ background: this.#resolveLightDark(computedStyle.getPropertyValue('--_node-background-color').trim()),
658
+ border: this.#resolveLightDark(computedStyle.getPropertyValue('--_node-border-color').trim()),
659
+ highlight: {
660
+ background: this.#resolveLightDark(computedStyle.getPropertyValue('--_node-background-color-highlight').trim()),
661
+ border: this.#resolveLightDark(computedStyle.getPropertyValue('--_node-color-highlight').trim())
662
+ }
663
+ };
664
+ }
665
+ #getNodeFont() {
666
+ const computedStyle = this.#getComputedStyle();
667
+ return {
668
+ color: this.#resolveLightDark(computedStyle.getPropertyValue('--_node-font-color').trim()),
669
+ strokeWidth: 4,
670
+ strokeColor: this.#resolveLightDark(computedStyle.getPropertyValue('--_container-background-color').trim())
671
+ };
672
+ }
673
+ #getEdgeColor() {
674
+ const computedStyle = this.#getComputedStyle();
675
+ return {
676
+ color: this.#resolveLightDark(computedStyle.getPropertyValue('--_edge-color').trim()),
677
+ highlight: this.#resolveLightDark(computedStyle.getPropertyValue('--_edge-color-highlight').trim()),
678
+ hover: this.#resolveLightDark(computedStyle.getPropertyValue('--_edge-color-hover').trim())
679
+ };
680
+ }
681
+ #getEdgeFont() {
682
+ const computedStyle = this.#getComputedStyle();
683
+ return {
684
+ strokeWidth: 4,
685
+ strokeColor: this.#resolveLightDark(computedStyle.getPropertyValue('--_container-background-color').trim()),
686
+ color: this.#resolveLightDark(computedStyle.getPropertyValue('--_edge-font-color').trim())
687
+ };
688
+ }
689
+ #getComputedStyle() {
690
+ const container = this.container().nativeElement;
691
+ return getComputedStyle(container);
692
+ }
693
+ // grab color values for light-dark(...,...) notation
694
+ #resolveLightDark(s) {
695
+ if (s.startsWith('light-dark(')) {
696
+ const regex = /light-dark\(\s*(#[0-9a-fA-F]{6})\s*,\s*(#[0-9a-fA-F]{6})\s*\)/;
697
+ const match = s.match(regex);
698
+ if (match) {
699
+ const lightColor = match[1];
700
+ const darkColor = match[2];
701
+ return this.#mode() === 'dark' ? darkColor : lightColor;
702
+ }
703
+ else
704
+ return s;
705
+ }
706
+ else
707
+ return s;
708
+ }
709
+ ngAfterViewInit() {
710
+ const options = {
711
+ physics: {
712
+ enabled: true,
713
+ solver: 'forceAtlas2Based',
714
+ forceAtlas2Based: {
715
+ // gravitationalConstant: -50,
716
+ // centralGravity: 0.01,
717
+ springLength: 200,
718
+ }
719
+ },
720
+ nodes: {
721
+ shape: 'dot',
722
+ size: 20,
723
+ font: { size: 12 }
724
+ }
725
+ };
726
+ this.#network = new Network(this.container().nativeElement, {
727
+ nodes: this.#nodes,
728
+ edges: this.#edges
729
+ }, options);
730
+ this.#network.on('selectNode', (params) => {
731
+ const selectedNodeId = params.nodes[0];
732
+ this.selectedObject.set(this.#objectQA[selectedNodeId]);
733
+ });
734
+ this.#network.on('deselectNode', (params) => {
735
+ this.selectedObject.set(null);
736
+ });
737
+ this.#network.on('dragEnd', (params) => {
738
+ const selectedNodeId = params.nodes[0];
739
+ this.selectedObject.set(this.#objectQA[selectedNodeId]);
740
+ });
741
+ this.#network.on('selectEdge', (params) => {
742
+ const selectedEdgeId = params.edges[0];
743
+ const nodesSelected = params.nodes.length > 0;
744
+ this.selectedRelation.set(params.edges.length === 1 && !nodesSelected ? this.#relationQA[selectedEdgeId] : null);
745
+ });
746
+ this.#network.on('deselectEdge', (params) => {
747
+ const selectedEdgeId = params.edges[0];
748
+ const nodesSelected = params.nodes.length > 0;
749
+ this.selectedRelation.set(params.edges.length === 1 && !nodesSelected ? this.#relationQA[selectedEdgeId] : null);
750
+ });
751
+ this.#network.on('click', (params) => {
752
+ const selectedNodeId = params.nodes[0];
753
+ this.selectedObject.set(this.#objectQA[selectedNodeId]);
754
+ });
755
+ this.#network.on('doubleClick', (params) => {
756
+ const selectedNodeId = params.nodes[0];
757
+ this.#expand(selectedNodeId);
758
+ });
759
+ }
760
+ ngOnDestroy() {
761
+ if (this.#network) {
762
+ this.#network.destroy();
763
+ }
764
+ }
765
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipGraphComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
766
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: ObjectRelationshipGraphComponent, isStandalone: true, selector: "yuv-object-relationship-graph", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { objectSelected: "objectSelected", relationSelected: "relationSelected" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["graphContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"relations\" [yuvBusyOverlay]=\"busy()\">\n <div class=\"toolbar\">\n <button ymtIconButton (click)=\"download()\" [matTooltip]=\"'yuv.object-relationship.download.tooltip' | translate\">\n <mat-icon>download</mat-icon>\n </button>\n @if (selectedRelation()) {\n <button ymtIconButton (click)=\"deleteRelationship()\" [matTooltip]=\"'yuv.object-relationship.delete-relation.tooltip' | translate\">\n <mat-icon>delete</mat-icon>\n </button>\n }\n </div>\n <div class=\"graph-container\" #graphContainer></div>\n\n @let dn = detailsNode();\n @if (dn) {\n <div class=\"selected\">\n <yuv-node-summary [object]=\"dn.object\" [nodeConfig]=\"dn.config\" [actions]=\"additionalSummaryActions\"></yuv-node-summary>\n </div>\n }\n</div>\n\n<ng-template #additionalSummaryActions>\n <button\n ymt-icon-button\n icon-button-size=\"small\"\n [matTooltip]=\"'yuv.object-relationship.selected.add-relationship.tooltip' | translate\"\n (click)=\"addRelationship()\"\n >\n <mat-icon>add</mat-icon>\n </button>\n <button ymt-icon-button icon-button-size=\"small\" [matTooltip]=\"'yuv.object-relationship.selected.expand.tooltip' | translate\" (click)=\"expandSelected()\">\n <mat-icon>open_with</mat-icon>\n </button>\n</ng-template>\n", styles: [":host{--_container-background-color: var(--container-background-color, var(--ymt-surface));--_node-background-color: var(--node-background-color, var(--ymt-surface-container));--_node-border-color: var(--node-border-color, var(--ymt-outline));--_node-font-color: var(--node-font-color, var(--ymt-text-color));--_node-background-color-highlight: var(--node-background-color-highlight, var(--ymt-primary-container));--_node-color-highlight: var(--node-color-highlight, var(--ymt-on-primary-container));--_edge-font-color: var(--edge-font-color, var(--ymt-text-color-subtle));--_edge-color: var(--edge-color, var(--ymt-outline));--_edge-color-highlight: var(--edge-color-highlight, var(--ymt-primary));--_edge-color-hover: var(--edge-color-hover, var(--ymt-primary))}:host .relations{position:relative;display:block;height:100%}:host .relations .toolbar{position:absolute;inset-block-start:var(--ymt-spacing-s);inset-inline-start:var(--ymt-spacing-s);z-index:10}:host .relations .graph-container{background-color:var(--_container-background-color);width:100%;height:100%}:host .relations .selected{position:absolute;inset-inline-end:var(--ymt-spacing-m);inset-block-start:var(--ymt-spacing-m);inset-block-end:var(--ymt-spacing-m);padding:var(--ymt-spacing-s) var(--ymt-spacing-m);backdrop-filter:blur(2px);background-color:rgb(from var(--ymt-surface) r g b/.8);border:1px solid var(--ymt-outline-variant);border-radius:var(--ymt-corner-s);max-width:33%;z-index:10;min-width:200px}:host .relations .selected yuv-node-summary{height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: NodeSummaryComponent, selector: "yuv-node-summary", inputs: ["object", "nodeConfig", "actions"] }, { kind: "directive", type: BusyOverlayDirective, selector: "[yuvBusyOverlay]", inputs: ["yuvBusyOverlay", "yuvBusyOverlayConfig"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1$3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i2.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "directive", type: YmtIconButtonDirective, selector: "button[ymtIconButton],button[ymt-icon-button],a[ymtIconButton],a[ymt-icon-button]", inputs: ["disabled", "disableRipple", "aria-disabled", "disabledInteractive", "icon-button-size"] }] }); }
767
+ }
768
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipGraphComponent, decorators: [{
769
+ type: Component,
770
+ args: [{ selector: 'yuv-object-relationship-graph', imports: [CommonModule, NodeSummaryComponent, BusyOverlayDirective, MatIconModule, MatTooltipModule, TranslateModule, YmtIconButtonDirective], template: "<div class=\"relations\" [yuvBusyOverlay]=\"busy()\">\n <div class=\"toolbar\">\n <button ymtIconButton (click)=\"download()\" [matTooltip]=\"'yuv.object-relationship.download.tooltip' | translate\">\n <mat-icon>download</mat-icon>\n </button>\n @if (selectedRelation()) {\n <button ymtIconButton (click)=\"deleteRelationship()\" [matTooltip]=\"'yuv.object-relationship.delete-relation.tooltip' | translate\">\n <mat-icon>delete</mat-icon>\n </button>\n }\n </div>\n <div class=\"graph-container\" #graphContainer></div>\n\n @let dn = detailsNode();\n @if (dn) {\n <div class=\"selected\">\n <yuv-node-summary [object]=\"dn.object\" [nodeConfig]=\"dn.config\" [actions]=\"additionalSummaryActions\"></yuv-node-summary>\n </div>\n }\n</div>\n\n<ng-template #additionalSummaryActions>\n <button\n ymt-icon-button\n icon-button-size=\"small\"\n [matTooltip]=\"'yuv.object-relationship.selected.add-relationship.tooltip' | translate\"\n (click)=\"addRelationship()\"\n >\n <mat-icon>add</mat-icon>\n </button>\n <button ymt-icon-button icon-button-size=\"small\" [matTooltip]=\"'yuv.object-relationship.selected.expand.tooltip' | translate\" (click)=\"expandSelected()\">\n <mat-icon>open_with</mat-icon>\n </button>\n</ng-template>\n", styles: [":host{--_container-background-color: var(--container-background-color, var(--ymt-surface));--_node-background-color: var(--node-background-color, var(--ymt-surface-container));--_node-border-color: var(--node-border-color, var(--ymt-outline));--_node-font-color: var(--node-font-color, var(--ymt-text-color));--_node-background-color-highlight: var(--node-background-color-highlight, var(--ymt-primary-container));--_node-color-highlight: var(--node-color-highlight, var(--ymt-on-primary-container));--_edge-font-color: var(--edge-font-color, var(--ymt-text-color-subtle));--_edge-color: var(--edge-color, var(--ymt-outline));--_edge-color-highlight: var(--edge-color-highlight, var(--ymt-primary));--_edge-color-hover: var(--edge-color-hover, var(--ymt-primary))}:host .relations{position:relative;display:block;height:100%}:host .relations .toolbar{position:absolute;inset-block-start:var(--ymt-spacing-s);inset-inline-start:var(--ymt-spacing-s);z-index:10}:host .relations .graph-container{background-color:var(--_container-background-color);width:100%;height:100%}:host .relations .selected{position:absolute;inset-inline-end:var(--ymt-spacing-m);inset-block-start:var(--ymt-spacing-m);inset-block-end:var(--ymt-spacing-m);padding:var(--ymt-spacing-s) var(--ymt-spacing-m);backdrop-filter:blur(2px);background-color:rgb(from var(--ymt-surface) r g b/.8);border:1px solid var(--ymt-outline-variant);border-radius:var(--ymt-corner-s);max-width:33%;z-index:10;min-width:200px}:host .relations .selected yuv-node-summary{height:100%}\n"] }]
771
+ }] });
772
+
773
+ class ObjectRelationshipListItemComponent {
774
+ constructor() {
775
+ this.#router = inject(Router);
776
+ this.#snack = inject(SnackBarService);
777
+ this.#objectRelationshipService = inject(ObjectRelationshipService);
778
+ this.translate = inject(TranslateService);
779
+ this.link = input.required();
780
+ this.direction = input.required();
781
+ this.enableSourceLink = input(false);
782
+ this.enableTargetLink = input(false);
783
+ }
784
+ #router;
785
+ #snack;
786
+ #objectRelationshipService;
787
+ deleteRelationship() {
788
+ this.#objectRelationshipService.deleteRelationship(this.link().id, true).subscribe((success) => {
789
+ if (!success) {
790
+ this.#snack.danger(this.translate.instant('yuv.object-relationship.delete-relation.error-message'));
791
+ }
792
+ });
793
+ }
794
+ open(link, skip) {
795
+ if (link && !skip)
796
+ this.#router.navigateByUrl(link);
797
+ }
798
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
799
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: ObjectRelationshipListItemComponent, isStandalone: true, selector: "yuv-object-relationship-list-item", inputs: { link: { classPropertyName: "link", publicName: "link", isSignal: true, isRequired: true, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: true, transformFunction: null }, enableSourceLink: { classPropertyName: "enableSourceLink", publicName: "enableSourceLink", isSignal: true, isRequired: false, transformFunction: null }, enableTargetLink: { classPropertyName: "enableTargetLink", publicName: "enableTargetLink", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@let lnk = link();\n\n<button\n class=\"node source\"\n (click)=\"open(lnk.source.objectLink, !enableSourceLink())\"\n [attr.aria-readonly]=\"!enableSourceLink() || !lnk.source.objectLink\"\n [class.self]=\"direction() === 'out'\"\n>\n @if (lnk.source.icon) {\n <mat-icon>{{ lnk.source.icon }}</mat-icon>\n }\n <span class=\"title\">{{ lnk.source.label }}</span>\n <span class=\"description\">{{ lnk.source.description }}</span>\n</button>\n\n<div class=\"line\" [class.arr]=\"direction() === 'in'\"></div>\n<div class=\"relation\">{{ lnk.type.label }}</div>\n<div class=\"line\" [class.arr]=\"direction() === 'out'\"></div>\n\n<button\n class=\"node target\"\n (click)=\"open(lnk.target.objectLink, !enableTargetLink())\"\n [attr.aria-readonly]=\"!enableTargetLink() || !lnk.target.objectLink\"\n [class.self]=\"direction() === 'in'\"\n>\n @if (lnk.target.icon) {\n <mat-icon>{{ lnk.target.icon }}</mat-icon>\n }\n <span class=\"title\">{{ lnk.target.label }}</span>\n <span class=\"description\">{{ lnk.target.description }}</span>\n</button>\n\n<div class=\"actions\"> \n <button ymtIconButton icon-button-size=\"small\" (click)=\"deleteRelationship()\"><mat-icon>delete</mat-icon></button>\n</div>\n", styles: [":host{margin-block-end:var(--ymt-spacing-xs);display:grid;grid-template-columns:auto 1fr auto 1fr auto auto;align-items:center;grid-template-areas:\"source line relation arrow target actions\";column-gap:var(--ymt-spacing-xs);background-color:var(--ymt-surface);border-radius:var(--ymt-corner-s);padding:var(--ymt-spacing-2xs);border:1px solid var(--ymt-outline-variant)}:host .relation{color:var(--ymt-text-color-subtle);text-align:center;line-height:1.1em}:host>button{grid-area:source;display:grid;grid-template-rows:auto auto;grid-template-columns:auto 1fr;align-items:center;grid-template-areas:\"icon label\" \"icon desc\";border-radius:var(--ymt-corner-xs);border:2px solid var(--ymt-outline-variant);padding:var(--ymt-spacing-xs);font:var(--ymt-font-title-smallest);background-color:transparent;text-align:start}:host>button mat-icon{grid-area:icon;scale:.6;margin-inline-end:var(--ymt-spacing-xs)}:host>button .title{grid-area:label}:host>button .description{grid-area:desc;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host>button.self{background-color:var(--ymt-surface-container);color:var(--ymt-on-surface)}:host>button:not(.self):hover{background-color:var(--ymt-hover-background)}:host>button:not([aria-readonly=true]){cursor:pointer}:host>button.target{grid-area:target}:host>button:not([aria-readonly]){cursor:pointer}:host .line{grid-area:line;height:2px;position:relative;background-color:var(--ymt-outline);opacity:.5;min-width:1em}:host .line.arr{grid-area:arrow}:host .line.arr:before{content:\"\";position:absolute;transform:rotate(45deg);transform-origin:top right;width:7px;inset-inline-end:0;translate:2px 1px;height:7px;border:3.5px solid transparent;border-block-start-color:var(--ymt-outline);border-inline-end-color:var(--ymt-outline)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1$3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: YmtIconButtonDirective, selector: "button[ymtIconButton],button[ymt-icon-button],a[ymtIconButton],a[ymt-icon-button]", inputs: ["disabled", "disableRipple", "aria-disabled", "disabledInteractive", "icon-button-size"] }] }); }
800
+ }
801
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipListItemComponent, decorators: [{
802
+ type: Component,
803
+ args: [{ selector: 'yuv-object-relationship-list-item', imports: [CommonModule, MatIconModule, YmtIconButtonDirective], template: "@let lnk = link();\n\n<button\n class=\"node source\"\n (click)=\"open(lnk.source.objectLink, !enableSourceLink())\"\n [attr.aria-readonly]=\"!enableSourceLink() || !lnk.source.objectLink\"\n [class.self]=\"direction() === 'out'\"\n>\n @if (lnk.source.icon) {\n <mat-icon>{{ lnk.source.icon }}</mat-icon>\n }\n <span class=\"title\">{{ lnk.source.label }}</span>\n <span class=\"description\">{{ lnk.source.description }}</span>\n</button>\n\n<div class=\"line\" [class.arr]=\"direction() === 'in'\"></div>\n<div class=\"relation\">{{ lnk.type.label }}</div>\n<div class=\"line\" [class.arr]=\"direction() === 'out'\"></div>\n\n<button\n class=\"node target\"\n (click)=\"open(lnk.target.objectLink, !enableTargetLink())\"\n [attr.aria-readonly]=\"!enableTargetLink() || !lnk.target.objectLink\"\n [class.self]=\"direction() === 'in'\"\n>\n @if (lnk.target.icon) {\n <mat-icon>{{ lnk.target.icon }}</mat-icon>\n }\n <span class=\"title\">{{ lnk.target.label }}</span>\n <span class=\"description\">{{ lnk.target.description }}</span>\n</button>\n\n<div class=\"actions\"> \n <button ymtIconButton icon-button-size=\"small\" (click)=\"deleteRelationship()\"><mat-icon>delete</mat-icon></button>\n</div>\n", styles: [":host{margin-block-end:var(--ymt-spacing-xs);display:grid;grid-template-columns:auto 1fr auto 1fr auto auto;align-items:center;grid-template-areas:\"source line relation arrow target actions\";column-gap:var(--ymt-spacing-xs);background-color:var(--ymt-surface);border-radius:var(--ymt-corner-s);padding:var(--ymt-spacing-2xs);border:1px solid var(--ymt-outline-variant)}:host .relation{color:var(--ymt-text-color-subtle);text-align:center;line-height:1.1em}:host>button{grid-area:source;display:grid;grid-template-rows:auto auto;grid-template-columns:auto 1fr;align-items:center;grid-template-areas:\"icon label\" \"icon desc\";border-radius:var(--ymt-corner-xs);border:2px solid var(--ymt-outline-variant);padding:var(--ymt-spacing-xs);font:var(--ymt-font-title-smallest);background-color:transparent;text-align:start}:host>button mat-icon{grid-area:icon;scale:.6;margin-inline-end:var(--ymt-spacing-xs)}:host>button .title{grid-area:label}:host>button .description{grid-area:desc;font:var(--ymt-font-body-subtle);color:var(--ymt-text-color-subtle)}:host>button.self{background-color:var(--ymt-surface-container);color:var(--ymt-on-surface)}:host>button:not(.self):hover{background-color:var(--ymt-hover-background)}:host>button:not([aria-readonly=true]){cursor:pointer}:host>button.target{grid-area:target}:host>button:not([aria-readonly]){cursor:pointer}:host .line{grid-area:line;height:2px;position:relative;background-color:var(--ymt-outline);opacity:.5;min-width:1em}:host .line.arr{grid-area:arrow}:host .line.arr:before{content:\"\";position:absolute;transform:rotate(45deg);transform-origin:top right;width:7px;inset-inline-end:0;translate:2px 1px;height:7px;border:3.5px solid transparent;border-block-start-color:var(--ymt-outline);border-inline-end-color:var(--ymt-outline)}\n"] }]
804
+ }] });
805
+
806
+ class ObjectRelationshipListComponent {
807
+ constructor() {
808
+ this.#search = inject(SearchService);
809
+ this.#system = inject(SystemService);
810
+ this.#objectRelationshipService = inject(ObjectRelationshipService);
811
+ /**
812
+ * Configuration for the relations component.
813
+ */
814
+ this.config = input.required();
815
+ this.incomingLinks = signal([]);
816
+ this.outgoingLinks = signal([]);
817
+ this.#relations = this.#objectRelationshipService.relations;
818
+ this.#relationsEffect = effect(() => {
819
+ const rel = this.#relations();
820
+ if (!rel)
821
+ return;
822
+ this.#createLists(rel.originId, rel.relations, rel.objects);
823
+ });
824
+ this.#objectQA = {};
825
+ }
826
+ #search;
827
+ #system;
828
+ #objectRelationshipService;
829
+ #relations;
830
+ #relationsEffect;
831
+ #objectQA;
832
+ #createLists(objectId, relations, objects) {
833
+ const incoming = relations.items.filter((item) => item.fields.get(RelationshipTypeField.TARGET_ID) === objectId);
834
+ const outgoing = relations.items.filter((item) => item.fields.get(RelationshipTypeField.SOURCE_ID) === objectId);
835
+ objects.items.forEach((item) => {
836
+ const id = item.fields.get(BaseObjectTypeField.OBJECT_ID);
837
+ this.#objectQA[id] = new DmsObject(item);
838
+ });
839
+ this.incomingLinks.set(incoming.map((rel) => this.#map(rel)).filter((l) => l !== undefined));
840
+ this.outgoingLinks.set(outgoing.map((rel) => this.#map(rel)).filter((l) => l !== undefined));
841
+ }
842
+ #map(relation) {
843
+ const sourceObject = this.#objectQA[relation.fields.get(RelationshipTypeField.SOURCE_ID)];
844
+ const targetObject = this.#objectQA[relation.fields.get(RelationshipTypeField.TARGET_ID)];
845
+ const relID = relation.fields.get(BaseObjectTypeField.OBJECT_ID);
846
+ const relObjectTypeID = relation.fields.get(BaseObjectTypeField.OBJECT_TYPE_ID);
847
+ const sourceCfg = this.#getConfigNode(sourceObject);
848
+ const targetCfg = this.#getConfigNode(targetObject);
849
+ // if no config found, this means that the relation is not configured to be shown
850
+ // Only nodes provided with the config are mapped to links
851
+ if (!sourceCfg || !targetCfg)
852
+ return undefined;
853
+ const sourceLabel = sourceObject.data[sourceCfg?.labelField || ''];
854
+ const sourceDescription = sourceObject.data[sourceCfg?.descriptionField || ''];
855
+ const sourceIcon = sourceCfg?.icon;
856
+ const targetLabel = targetObject.data[targetCfg?.labelField || ''];
857
+ const targetDescription = targetObject.data[targetCfg?.descriptionField || ''];
858
+ const targetIcon = targetCfg?.icon;
859
+ return {
860
+ id: relID,
861
+ type: {
862
+ id: relObjectTypeID,
863
+ label: this.#system.getLocalizedLabel(relObjectTypeID) || relObjectTypeID
864
+ },
865
+ source: {
866
+ id: relation.fields.get(RelationshipTypeField.SOURCE_ID),
867
+ label: sourceLabel,
868
+ description: sourceDescription,
869
+ icon: sourceIcon,
870
+ objectLink: sourceCfg.objectLink ? sourceCfg.objectLink.replace('{{id}}', sourceObject.id) : undefined
871
+ },
872
+ target: {
873
+ id: relation.fields.get(RelationshipTypeField.TARGET_ID),
874
+ label: targetLabel,
875
+ description: targetDescription,
876
+ icon: targetIcon,
877
+ objectLink: targetCfg.objectLink ? targetCfg.objectLink.replace('{{id}}', targetObject.id) : undefined
878
+ }
879
+ };
880
+ }
881
+ #getConfigNode(object) {
882
+ const cfg = this.config();
883
+ return cfg.nodes.find((n) => object.data[BaseObjectTypeField.SECONDARY_OBJECT_TYPE_IDS].includes(n.objectType));
884
+ }
885
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
886
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: ObjectRelationshipListComponent, isStandalone: true, selector: "yuv-object-relationship-list", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@let incoming = incomingLinks();\n@let outgoing = outgoingLinks();\n\n@if (incoming.length > 0) {\n <h3>{{ 'yuv.object-relationship.list.incoming' | translate }}</h3>\n @for (n of incoming; track n.id) {\n <yuv-object-relationship-list-item\n [enableSourceLink]=\"true\"\n [enableTargetLink]=\"false\"\n [link]=\"n\"\n direction=\"in\"\n ></yuv-object-relationship-list-item>\n }\n}\n@if (outgoing.length > 0) {\n <h3>{{ 'yuv.object-relationship.list.outgoing' | translate }}</h3>\n @for (n of outgoing; track n.id) {\n <yuv-object-relationship-list-item\n [enableSourceLink]=\"false\"\n [enableTargetLink]=\"true\"\n [link]=\"n\"\n direction=\"out\"\n ></yuv-object-relationship-list-item>\n }\n}\n", styles: [":host{display:block;padding:var(--ymt-spacing-m)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: ObjectRelationshipListItemComponent, selector: "yuv-object-relationship-list-item", inputs: ["link", "direction", "enableSourceLink", "enableTargetLink"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }] }); }
887
+ }
888
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipListComponent, decorators: [{
889
+ type: Component,
890
+ args: [{ selector: 'yuv-object-relationship-list', imports: [CommonModule, ObjectRelationshipListItemComponent, TranslateModule], template: "@let incoming = incomingLinks();\n@let outgoing = outgoingLinks();\n\n@if (incoming.length > 0) {\n <h3>{{ 'yuv.object-relationship.list.incoming' | translate }}</h3>\n @for (n of incoming; track n.id) {\n <yuv-object-relationship-list-item\n [enableSourceLink]=\"true\"\n [enableTargetLink]=\"false\"\n [link]=\"n\"\n direction=\"in\"\n ></yuv-object-relationship-list-item>\n }\n}\n@if (outgoing.length > 0) {\n <h3>{{ 'yuv.object-relationship.list.outgoing' | translate }}</h3>\n @for (n of outgoing; track n.id) {\n <yuv-object-relationship-list-item\n [enableSourceLink]=\"false\"\n [enableTargetLink]=\"true\"\n [link]=\"n\"\n direction=\"out\"\n ></yuv-object-relationship-list-item>\n }\n}\n", styles: [":host{display:block;padding:var(--ymt-spacing-m)}\n"] }]
891
+ }] });
892
+
893
+ class ObjectRelationshipComponent {
894
+ constructor() {
895
+ this.#objectRelationshipService = inject(ObjectRelationshipService);
896
+ this.#system = inject(SystemService);
897
+ this.#dialog = inject(MatDialog);
898
+ this.#DEFAULT_MODE = 'graph';
899
+ this.mode = signal(this.#DEFAULT_MODE);
900
+ /**
901
+ * ID of the object to display relations for.
902
+ */
903
+ this.objectId = input.required();
904
+ this.#objectIdEffect = effect(() => {
905
+ const oid = this.objectId();
906
+ this.#objectRelationshipService.objectId.set(oid);
907
+ });
908
+ /**
909
+ * Configuration for the relations component.
910
+ */
911
+ this.config = input.required();
912
+ // the DmsObject representing the originId
913
+ this.originObject = signal(null);
914
+ this.supportedRelationships = computed(() => {
915
+ const obj = this.originObject();
916
+ return obj ? this.#system.getSupportedRelationships(obj) : [];
917
+ });
918
+ this.#relations = this.#objectRelationshipService.relations;
919
+ this.#relationsEffect = effect(() => {
920
+ const rel = this.#relations();
921
+ if (!rel) {
922
+ this.originObject.set(null);
923
+ return;
924
+ }
925
+ const originId = rel.originId;
926
+ const originItem = rel.objects.items.find((item) => item.fields.get(BaseObjectTypeField.OBJECT_ID) === originId);
927
+ this.originObject.set(originItem ? new DmsObject(originItem) : null);
928
+ });
929
+ this.relationActions = input(null);
930
+ }
931
+ #objectRelationshipService;
932
+ #system;
933
+ #dialog;
934
+ #DEFAULT_MODE;
935
+ #objectIdEffect;
936
+ #relations;
937
+ #relationsEffect;
938
+ toggleMode() {
939
+ const newMode = this.mode() === 'list' ? 'graph' : 'list';
940
+ this.mode.set(newMode);
941
+ }
942
+ addRelationship() {
943
+ this.#dialog.open(AddRelationshipComponent, {
944
+ data: {
945
+ object: this.originObject(),
946
+ config: this.config()
947
+ }
948
+ });
949
+ }
950
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
951
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: ObjectRelationshipComponent, isStandalone: true, selector: "yuv-object-relationship", inputs: { objectId: { classPropertyName: "objectId", publicName: "objectId", isSignal: true, isRequired: true, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, relationActions: { classPropertyName: "relationActions", publicName: "relationActions", isSignal: true, isRequired: false, transformFunction: null } }, providers: [ObjectRelationshipService], ngImport: i0, template: "<ymt-pane [plain]=\"true\" [topBarActions]=\"topBarActions\">\n <ymt-pane-body>\n @switch (mode()) {\n @case ('graph') {\n <yuv-object-relationship-graph [config]=\"config()\"></yuv-object-relationship-graph>\n }\n @case ('list') {\n <yuv-object-relationship-list [config]=\"config()\"> </yuv-object-relationship-list>\n }\n }\n </ymt-pane-body>\n</ymt-pane>\n\n<ng-template #topBarActions>\n @if (supportedRelationships().length > 0) {\n <button ymt-icon-button icon-button-size=\"small\" [matTooltip]=\"'yuv.object-relationship.add.tooltip' | translate\" (click)=\"addRelationship()\">\n <mat-icon>add</mat-icon>\n </button>\n }\n <button\n ymt-icon-button\n icon-button-size=\"small\"\n [matTooltip]=\"mode() === 'list' ? ('yuv.object-relationship.mode.graph.tooltip' | translate) : ('yuv.object-relationship.mode.list.tooltip' | translate)\"\n (click)=\"toggleMode()\"\n >\n <mat-icon>{{ mode() === 'list' ? 'graph_3' : 'list' }}</mat-icon>\n </button>\n</ng-template>\n", styles: [":host{display:block;position:relative;height:100%;background-color:var(--ymt-surface)}:host .toggle{position:absolute;inset-block-start:var(--ymt-spacing-s);inset-inline-end:var(--ymt-spacing-s);z-index:10;background-color:var(--ymt-surface);padding:var(--ymt-spacing-xs);border-radius:var(--ymt-corner-full)}:host yuv-object-relationship-list,:host yuv-object-relationship-graph{height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1$3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i2.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "ngmodule", type: YmtPanesModule }, { kind: "component", type: i4$1.YmtPaneComponent, selector: "ymt-pane", inputs: ["topBarActions", "plain", "mode", "modeAlign"], outputs: ["paneToggled", "navigationClicked"] }, { kind: "component", type: i4$1.YmtPaneBodyComponent, selector: "ymt-pane-body" }, { kind: "directive", type: YmtIconButtonDirective, selector: "button[ymtIconButton],button[ymt-icon-button],a[ymtIconButton],a[ymt-icon-button]", inputs: ["disabled", "disableRipple", "aria-disabled", "disabledInteractive", "icon-button-size"] }, { kind: "component", type: ObjectRelationshipGraphComponent, selector: "yuv-object-relationship-graph", inputs: ["config"], outputs: ["objectSelected", "relationSelected"] }, { kind: "component", type: ObjectRelationshipListComponent, selector: "yuv-object-relationship-list", inputs: ["config"] }] }); }
952
+ }
953
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ObjectRelationshipComponent, decorators: [{
954
+ type: Component,
955
+ args: [{ selector: 'yuv-object-relationship', imports: [
956
+ CommonModule,
957
+ MatIconModule,
958
+ MatTooltipModule,
959
+ TranslateModule,
960
+ MatButtonToggleModule,
961
+ YmtPanesModule,
962
+ YmtIconButtonDirective,
963
+ ObjectRelationshipGraphComponent,
964
+ ObjectRelationshipListComponent,
965
+ YmtIconButtonDirective
966
+ ], providers: [ObjectRelationshipService], template: "<ymt-pane [plain]=\"true\" [topBarActions]=\"topBarActions\">\n <ymt-pane-body>\n @switch (mode()) {\n @case ('graph') {\n <yuv-object-relationship-graph [config]=\"config()\"></yuv-object-relationship-graph>\n }\n @case ('list') {\n <yuv-object-relationship-list [config]=\"config()\"> </yuv-object-relationship-list>\n }\n }\n </ymt-pane-body>\n</ymt-pane>\n\n<ng-template #topBarActions>\n @if (supportedRelationships().length > 0) {\n <button ymt-icon-button icon-button-size=\"small\" [matTooltip]=\"'yuv.object-relationship.add.tooltip' | translate\" (click)=\"addRelationship()\">\n <mat-icon>add</mat-icon>\n </button>\n }\n <button\n ymt-icon-button\n icon-button-size=\"small\"\n [matTooltip]=\"mode() === 'list' ? ('yuv.object-relationship.mode.graph.tooltip' | translate) : ('yuv.object-relationship.mode.list.tooltip' | translate)\"\n (click)=\"toggleMode()\"\n >\n <mat-icon>{{ mode() === 'list' ? 'graph_3' : 'list' }}</mat-icon>\n </button>\n</ng-template>\n", styles: [":host{display:block;position:relative;height:100%;background-color:var(--ymt-surface)}:host .toggle{position:absolute;inset-block-start:var(--ymt-spacing-s);inset-inline-end:var(--ymt-spacing-s);z-index:10;background-color:var(--ymt-surface);padding:var(--ymt-spacing-xs);border-radius:var(--ymt-corner-full)}:host yuv-object-relationship-list,:host yuv-object-relationship-graph{height:100%}\n"] }]
967
+ }] });
968
+
969
+ const cmp = [ObjectRelationshipComponent];
970
+ class YuvObjectRelationshipModule {
971
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: YuvObjectRelationshipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
972
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: YuvObjectRelationshipModule, imports: [ObjectRelationshipComponent], exports: [ObjectRelationshipComponent] }); }
973
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: YuvObjectRelationshipModule, imports: [cmp] }); }
974
+ }
975
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: YuvObjectRelationshipModule, decorators: [{
976
+ type: NgModule,
977
+ args: [{
978
+ imports: [...cmp],
979
+ exports: [...cmp]
980
+ }]
981
+ }] });
982
+
983
+ /**
984
+ * Generated bundle index. Do not edit.
985
+ */
986
+
987
+ export { AddRelationshipComponent, ObjectRelationshipComponent, YuvObjectRelationshipModule };
988
+ //# sourceMappingURL=yuuvis-client-framework-object-relationship.mjs.map