@yuuvis/client-framework 2.3.31 → 2.4.1

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