UI: Fixed edit and improve create new

This commit is contained in:
Artem Dzhereleiko 2025-07-28 17:24:37 +03:00
parent f31f49b19f
commit db1eb1682f
4 changed files with 19 additions and 1 deletions

View File

@ -40,6 +40,7 @@ export interface TemplateNotificationDialogData {
predefinedType?: NotificationType; predefinedType?: NotificationType;
isAdd?: boolean; isAdd?: boolean;
isCopy?: boolean; isCopy?: boolean;
name?: string;
} }
@Component({ @Component({
@ -85,6 +86,9 @@ export class TemplateNotificationDialogComponent
this.hideSelectType = true; this.hideSelectType = true;
this.templateNotificationForm.get('notificationType').setValue(this.data.predefinedType, {emitEvent: false}); this.templateNotificationForm.get('notificationType').setValue(this.data.predefinedType, {emitEvent: false});
} }
if (isDefinedAndNotNull(this.data?.name)) {
this.templateNotificationForm.get('name').setValue(this.data.name, {emitEvent: false});
}
if (data.isAdd || data.isCopy) { if (data.isAdd || data.isCopy) {
this.dialogTitle = 'notification.add-notification-template'; this.dialogTitle = 'notification.add-notification-template';

View File

@ -29,7 +29,7 @@
(click)="clear()"> (click)="clear()">
<mat-icon class="material-icons">close</mat-icon> <mat-icon class="material-icons">close</mat-icon>
</button> </button>
<button *ngIf="selectTemplateFormGroup.get('templateName').value && !disabled && allowEdit" <button *ngIf="selectTemplateFormGroup.get('templateName').value?.id && !disabled && allowEdit"
type="button" type="button"
matSuffix mat-icon-button aria-label="Edit" matSuffix mat-icon-button aria-label="Edit"
matTooltip="{{ 'notification.edit-notification-template' | translate }}" matTooltip="{{ 'notification.edit-notification-template' | translate }}"
@ -62,6 +62,9 @@
</div> </div>
<ng-template #searchNotEmpty> <ng-template #searchNotEmpty>
<span>{{ 'notification.no-template-matching' | translate : {template: truncate.transform(searchText, true, 6, &apos;...&apos;)} }}</span> <span>{{ 'notification.no-template-matching' | translate : {template: truncate.transform(searchText, true, 6, &apos;...&apos;)} }}</span>
<span *ngIf="allowCreate">
<a translate (click)="createTemplateBySearchText($event, searchText)">notification.create-new-template</a>
</span>
</ng-template> </ng-template>
</div> </div>
</mat-option> </mat-option>

View File

@ -221,6 +221,16 @@ export class TemplateAutocompleteComponent implements ControlValueAccessor, OnIn
predefinedType: this.notificationTypes predefinedType: this.notificationTypes
}); });
} }
createTemplateBySearchText($event: Event, searchText: string) {
if ($event) {
$event.stopPropagation();
}
this.openNotificationTemplateDialog({
isAdd: true,
predefinedType: this.notificationTypes,
name: searchText
});
}
private openNotificationTemplateDialog(dialogData?: TemplateNotificationDialogData) { private openNotificationTemplateDialog(dialogData?: TemplateNotificationDialogData) {
this.dialog.open<TemplateNotificationDialogComponent, TemplateNotificationDialogData, this.dialog.open<TemplateNotificationDialogComponent, TemplateNotificationDialogData,

View File

@ -4071,6 +4071,7 @@
"no-severity-found": "No severity found", "no-severity-found": "No severity found",
"no-severity-matching": "'{{severity}}' not found.", "no-severity-matching": "'{{severity}}' not found.",
"no-template-matching": "No resource matching '{{template}}' were found.", "no-template-matching": "No resource matching '{{template}}' were found.",
"create-new-template": "Create a new one!",
"not-found-slack-recipient": "Slack recipient not found", "not-found-slack-recipient": "Slack recipient not found",
"notification": "Notification", "notification": "Notification",
"notification-center": "Notification center", "notification-center": "Notification center",