Skip to content

Commit

Permalink
Query Builder: Set alias automatically based on name
Browse files Browse the repository at this point in the history
  • Loading branch information
askask committed Aug 15, 2024
1 parent d384175 commit bc30921
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/models/aqb/aqb-select-item-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bc30921

Please sign in to comment.