From bc30921492985d0fb9c9a974b5a53b815b6b0ead Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Jul 2024 12:00:00 +0200 Subject: [PATCH] Query Builder: Set alias automatically based on name --- .../aql-builder-select-item.component.ts | 18 +++++++++++++++++- .../models/aqb/aqb-select-item-ui.model.ts | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/modules/aqls/components/aql-builder-select-item/aql-builder-select-item.component.ts b/src/app/modules/aqls/components/aql-builder-select-item/aql-builder-select-item.component.ts index 4c9bbd76b..26753b794 100644 --- a/src/app/modules/aqls/components/aql-builder-select-item/aql-builder-select-item.component.ts +++ b/src/app/modules/aqls/components/aql-builder-select-item/aql-builder-select-item.component.ts @@ -22,9 +22,25 @@ export class AqlBuilderSelectItemComponent implements OnInit, OnDestroy { ngOnInit(): void { this.aliasForm = new UntypedFormGroup({ - value: new UntypedFormControl(this.item.givenName), + value: new UntypedFormControl( + this.item.givenName == undefined + ? this.item.name + .replace('ä', 'ae') + .replace('ö', 'oe') + .replace('ü', 'ue') + .replace('ß', 'ss') + .replace('Ä', 'Ae') + .replace('Ö', 'Oe') + .replace('Ü', 'Ue') + .replace('ẞ', 'SS') + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + .replace(/(^[^a-zA-Z]+)|[^0-9a-zA-Z_]+/g, '_') + : this.item.givenName + ), }) + this.handleAliasChange(this.aliasForm.get('value').value) this.subscriptions.add( this.aliasForm.get('value').valueChanges.subscribe((value) => this.handleAliasChange(value)) ) diff --git a/src/app/shared/models/aqb/aqb-select-item-ui.model.ts b/src/app/shared/models/aqb/aqb-select-item-ui.model.ts index 340339888..f0ee31124 100644 --- a/src/app/shared/models/aqb/aqb-select-item-ui.model.ts +++ b/src/app/shared/models/aqb/aqb-select-item-ui.model.ts @@ -7,7 +7,7 @@ import { IContainmentTreeNode } from '../../../modules/aqls/models/containment-t export class AqbSelectItemUiModel { readonly type = ConnectorNodeType.Aqb_Item name: string - givenName: string + givenName?: string rmType: ReferenceModelType aqlPath: string humanReadablePath: string @@ -24,7 +24,7 @@ export class AqbSelectItemUiModel { templateId: string ) { this.name = item.name || item.archetypeId - this.givenName = item.givenName || '' + this.givenName = item.givenName this.rmType = item.rmType this.aqlPath = (item.aqlPath || '').replace(/^\//, '') this.humanReadablePath = item.humanReadablePath