fix delete callback

This commit is contained in:
Efstratios Giannopoulos 2024-04-05 18:03:26 +03:00
parent 7ebe22a45f
commit 45e3426969
14 changed files with 36 additions and 28 deletions

View File

@ -199,7 +199,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
refreshOnNavigateToData(id?: Guid): void { refreshOnNavigateToData(id?: Guid): void {
this.formGroup.markAsPristine(); this.formGroup.markAsPristine();
let route = []; let route = [];
if (id === null) { if (id === null) {
route.push('../..'); route.push('../..');
} else if (this.isNew) { } else if (this.isNew) {
@ -222,7 +222,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
); );
} else if (this.isNewVersion== true && this.isNew == false && this.isClone == false) { } else if (this.isNewVersion== true && this.isNew == false && this.isClone == false) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist; const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist;
this.descriptionTemplateService.newVersion(formData) this.descriptionTemplateService.newVersion(formData)
.pipe(takeUntil(this._destroyed)).subscribe( .pipe(takeUntil(this._destroyed)).subscribe(
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
@ -267,7 +267,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
if (result) { if (result) {
this.descriptionTemplateService.delete(value.id).pipe(takeUntil(this._destroyed)) this.descriptionTemplateService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -163,7 +163,7 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
if (result) { if (result) {
this.descriptionTemplateTypeService.delete(value.id).pipe(takeUntil(this._destroyed)) this.descriptionTemplateTypeService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -261,7 +261,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
if (result) { if (result) {
this.dmpBlueprintService.delete(value.id).pipe(takeUntil(this._destroyed)) this.dmpBlueprintService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.cancel(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -183,7 +183,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
if (result) { if (result) {
this.languageHttpService.delete(value.id).pipe(takeUntil(this._destroyed)) this.languageHttpService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -217,7 +217,7 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
if (result) { if (result) {
this.notificationTemplateService.delete(value.id).pipe(takeUntil(this._destroyed)) this.notificationTemplateService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }
@ -285,24 +285,24 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
if (value) values.push(value) if (value) values.push(value)
event.chipInput!.clear(); event.chipInput!.clear();
return values; return values;
} }
remove(field: string, values: string[]) { remove(field: string, values: string[]) {
const index = values.indexOf(field); const index = values.indexOf(field);
if (index >= 0) values.splice(index, 1); if (index >= 0) values.splice(index, 1);
return values; return values;
} }
edit(field: string, values: string[], event: MatChipEditedEvent) { edit(field: string, values: string[], event: MatChipEditedEvent) {
const value = event.value.trim(); const value = event.value.trim();
if (!value) { if (!value) {
values = this.remove(field, values); values = this.remove(field, values);
return values; return values;
} }
const index = values.indexOf(field); const index = values.indexOf(field);
if (index >= 0) values[index] = value if (index >= 0) values[index] = value

View File

@ -169,7 +169,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
if (result) { if (result) {
this.prefillingSourceService.delete(value.id).pipe(takeUntil(this._destroyed)) this.prefillingSourceService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -182,7 +182,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
if (result) { if (result) {
this.referenceTypeService.delete(value.id).pipe(takeUntil(this._destroyed)) this.referenceTypeService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -176,7 +176,7 @@ export class ReferenceEditorComponent extends BaseEditor<ReferenceEditorModel, R
if (result) { if (result) {
this.referenceService.delete(value.id).pipe(takeUntil(this._destroyed)) this.referenceService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -179,7 +179,7 @@ export class TenantEditorComponent extends BaseEditor<TenantEditorModel, Tenant>
if (result) { if (result) {
this.tenantService.delete(value.id).pipe(takeUntil(this._destroyed)) this.tenantService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -663,7 +663,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
if (result) { if (result) {
this.descriptionService.delete(value.id).pipe(takeUntil(this._destroyed)) this.descriptionService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -181,9 +181,9 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
} }
} }
if(data.dmpDescriptionTemplates){ if(data.dmpDescriptionTemplates){
data.dmpDescriptionTemplates = data.dmpDescriptionTemplates.filter(x => x.isActive === IsActive.Active); data.dmpDescriptionTemplates = data.dmpDescriptionTemplates.filter(x => x.isActive === IsActive.Active);
} }
} }
this.item = data; this.item = data;
@ -290,7 +290,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
if (result) { if (result) {
this.dmpService.delete(value.id).pipe(takeUntil(this._destroyed)) this.dmpService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }
@ -345,7 +345,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
this.selectedBlueprint = data; this.selectedBlueprint = data;
this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id); this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id);
const goToNextStep: boolean = this.formGroup.get('label').valid && this.formGroup.get('description').valid; const goToNextStep: boolean = this.formGroup.get('label').valid && this.formGroup.get('description').valid;
this.buildFormAfterBlueprintSelection(goToNextStep); this.buildFormAfterBlueprintSelection(goToNextStep);
}); });
} }
@ -357,7 +357,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
blueprint: this.selectedBlueprint, blueprint: this.selectedBlueprint,
status: DmpStatus.Draft status: DmpStatus.Draft
} }
this.prepareForm(dmp); this.prepareForm(dmp);
this.goToNextStep = true; //reset this.goToNextStep = true; //reset
} }
@ -476,7 +476,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
multiplicityValidResults.push(true); multiplicityValidResults.push(true);
} }
}) })
if(multiplicityValidResults.includes(true)) return true if(multiplicityValidResults.includes(true)) return true
else return false; else return false;
}else{ }else{

View File

@ -108,7 +108,7 @@ export class InAppNotificationEditorComponent extends BaseComponent implements O
if (result) { if (result) {
this.inappNotificationService.delete(value.id).pipe(takeUntil(this._destroyed)) this.inappNotificationService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.cancel(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }

View File

@ -168,7 +168,7 @@ export class SupportiveMaterialEditorComponent extends BaseEditor<SupportiveMate
if (result) { if (result) {
this.supportiveMaterialService.delete(value.id).pipe(takeUntil(this._destroyed)) this.supportiveMaterialService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackDeleteSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)
); );
} }
@ -185,7 +185,7 @@ export class SupportiveMaterialEditorComponent extends BaseEditor<SupportiveMate
} }
private getSupportiveMaterialData(){ private getSupportiveMaterialData(){
if(this.formGroup.get('type').value >= 0 && this.formGroup.get('languageCode').value){ if(this.formGroup.get('type').value >= 0 && this.formGroup.get('languageCode').value){
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup(); const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
lookup.types = [this.formGroup.get('type').value]; lookup.types = [this.formGroup.get('type').value];
@ -197,7 +197,7 @@ export class SupportiveMaterialEditorComponent extends BaseEditor<SupportiveMate
}else{ }else{
this.formGroup.get('id').patchValue(null); this.formGroup.get('id').patchValue(null);
this.formGroup.get('payload').patchValue(''); this.formGroup.get('payload').patchValue('');
} }
}); });
} }
} }

View File

@ -117,6 +117,14 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
this.refreshOnNavigateToData(data ? data.id : null); this.refreshOnNavigateToData(data ? data.id : null);
} }
onCallbackDeleteSuccess(data?: any): void {
console.log("Success Delete:", data);
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
this.cancel();
}
onCallbackError(errorResponse: HttpErrorResponse) { onCallbackError(errorResponse: HttpErrorResponse) {
console.log("Error:", errorResponse); console.log("Error:", errorResponse);