diff --git a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts index 8a99fa7..5cc6476 100644 --- a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts +++ b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts @@ -117,6 +117,7 @@ export class EditStakeholderComponent implements OnDestroy { public stakeholder: Stakeholder; public isDefault: boolean; public isNew: boolean; + public loading: boolean = false; public types: Option[]; public properties: EnvProperties = properties; private subscriptions: any[] = []; @@ -275,6 +276,7 @@ export class EditStakeholderComponent implements OnDestroy { } public save(callback: Function, errorCallback: Function = null) { + this.loading = true; if (this.file) { this.subscriptions.push(this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/" + encodeURIComponent(this.stakeholderFb.getRawValue().type) + "/" + encodeURIComponent(this.stakeholderFb.getRawValue().alias), this.file).subscribe(res => { this.deletePhoto(); @@ -310,11 +312,13 @@ export class EditStakeholderComponent implements OnDestroy { this.notify.sendNotification(this.notification); NotificationHandler.rise(stakeholder.name + ' has been successfully created'); callback(stakeholder); + this.loading = false; }, error => { NotificationHandler.rise('An error has occurred. Please try again later', 'danger'); if (errorCallback) { errorCallback(error) } + this.loading = false; })); } else { this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.getRawValue()).subscribe(stakeholder => { @@ -324,10 +328,14 @@ export class EditStakeholderComponent implements OnDestroy { this.notification.groups = [Role.curator(stakeholder.type), Role.manager(stakeholder.type, stakeholder.alias)]; this.notify.sendNotification(this.notification); NotificationHandler.rise(stakeholder.name + ' has been successfully saved'); - callback(stakeholder); + callback(stakeholder); + this.loading = false; }, error => { NotificationHandler.rise('An error has occurred. Please try again later', 'danger'); - console.error(error); + if (errorCallback) { + errorCallback(error) + } + this.loading = false; })); } } diff --git a/src/app/manageStakeholders/manageStakeholders.component.html b/src/app/manageStakeholders/manageStakeholders.component.html index 08ff4be..9fb9893 100644 --- a/src/app/manageStakeholders/manageStakeholders.component.html +++ b/src/app/manageStakeholders/manageStakeholders.component.html @@ -123,7 +123,10 @@ id="edit_modal" [large]="true" classTitle="uk-background-primary uk-light" (alertOutput)="editStakeholderComponent.save(callback)" [okDisabled]="editStakeholderComponent.disabled"> -