[Admin | Trunk]: Fix upload/delete photo of curator bug
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@59484 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
d1fba2997f
commit
316bdbbaf6
|
@ -220,6 +220,22 @@ export class CuratorComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
saveCurator() {
|
||||
this.curatorService.updateCurator(this.properties, this.curator).subscribe((curator) => {
|
||||
if (curator) {
|
||||
this.handleSuccessfulSave('Your data has been saved successfully!');
|
||||
this.newCurator = false;
|
||||
this.file = null;
|
||||
this.deletePhoto = false;
|
||||
this.resetChange();
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleUpdateError('An error has occurred. Try again later!', error);
|
||||
this.resetChange();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
updateCurator() {
|
||||
if (!Session.isLoggedIn()) {
|
||||
|
@ -236,36 +252,19 @@ export class CuratorComponent implements OnInit {
|
|||
this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe();
|
||||
}
|
||||
this.curator.photo = res.filename;
|
||||
this.curatorService.updateCurator(this.properties, this.curator).subscribe((curator) => {
|
||||
if (curator) {
|
||||
this.handleSuccessfulSave('Your data has been saved successfully!');
|
||||
this.newCurator = false;
|
||||
this.resetChange();
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleUpdateError('An error has occurred. Try again later!', error);
|
||||
this.resetChange();
|
||||
});
|
||||
this.saveCurator();
|
||||
}, error => {
|
||||
this.handleUpdateError('An error has occurred during photo uploading.', error);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if (this.deletePhoto) {
|
||||
this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe();
|
||||
this.curator.photo = '';
|
||||
if(this.curator.photo && this.curator.photo != '') {
|
||||
this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe();
|
||||
this.curator.photo = '';
|
||||
}
|
||||
}
|
||||
this.curatorService.updateCurator(this.properties, this.curator).subscribe((curator) => {
|
||||
if (curator) {
|
||||
this.handleSuccessfulSave('Your data has been saved successfully!');
|
||||
this.resetChange();
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleUpdateError('An error has occurred. Try again later!', error);
|
||||
this.resetChange();
|
||||
});
|
||||
this.saveCurator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,16 +272,13 @@ export class CuratorComponent implements OnInit {
|
|||
|
||||
onNameChange() {
|
||||
this.hasChanged = true;
|
||||
if (!this.curator.name || this.curator.name === '') {
|
||||
this.enabled = false;
|
||||
} else {
|
||||
this.enabled = true;
|
||||
}
|
||||
this.enabled = !(!this.curator.name || this.curator.name === '');
|
||||
}
|
||||
|
||||
removePhoto() {
|
||||
this.deletePhoto = true;
|
||||
this.hasChanged = true;
|
||||
this.file = null;
|
||||
this.photo = 'assets/common-assets/curator-default.png';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue