[Trunk|Admin]: Add functionality to remove curator photo.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56025 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-06-07 10:27:16 +00:00
parent 77b0742079
commit f8782beba9
2 changed files with 27 additions and 9 deletions

View File

@ -36,7 +36,12 @@
<div uk-form-custom>
<input id="photo" type="file" (change)="fileChangeEvent($event)" (input)="change()"/>
<button class="uk-button portal-button" type="button" tabindex="-1">
Update your photo
Upload a photo
</button>
</div>
<div class="uk-margin-small-left">
<button class="uk-button uk-button-danger" type="button" (click)="removePhotoModal.open()">
Remove
</button>
</div>
</div>
@ -98,9 +103,9 @@
</div>
</div>
<div class="uk-float-right">
<button class="uk-button" (click)="resetForm()">Cancel</button>
<button *ngIf="enabled" class="uk-button uk-button-primary" (click)="updateCurator()">Save</button>
<button *ngIf="!enabled" class="uk-button uk-button-default" disabled>Save</button>
<button class="uk-button uk-margin-small-right" (click)="resetForm()">Cancel</button>
<button *ngIf="enabled && hasChanged" class="uk-button uk-button-primary" (click)="updateCurator()">Save</button>
<button *ngIf="!enabled || !hasChanged" class="uk-button uk-button-default" disabled>Save</button>
</div>
<modal-alert #affiliationModal [okDisabled]="isEmptyAffiliation()" (alertOutput)="addAffiliation()">
<table class="uk-align-center">
@ -150,5 +155,8 @@
</tbody>
</table>
</modal-alert>
<modal-alert #removeAffiliationModal [okDisabled]="isEmptyAffiliation()" (alertOutput)="removeAffiliation()">
<modal-alert #removeAffiliationModal (alertOutput)="removeAffiliation()">
</modal-alert>
<modal-alert #removePhotoModal (alertOutput)="removePhoto()">
Your photo will be removed after save your data. Are you sure you want to proceed?
</modal-alert>

View File

@ -35,6 +35,7 @@ export class CuratorComponent implements OnInit {
private enabled = true;
private index = 0;
private maxCharacters = 70;
private deletePhoto =false;
constructor(private element: ElementRef,
private route: ActivatedRoute,
@ -61,7 +62,7 @@ export class CuratorComponent implements OnInit {
if (curator) {
this.curator = curator;
this.curator.email = Session.getUserEmail();
if (this.curator.photo) {
if (this.curator.photo && this.curator.photo !== '') {
this.photo = this.properties.downloadUrl + '/' + this.curator.photo;
} else {
this.photo = '../../../assets/common-assets/curator-default.png';
@ -100,7 +101,6 @@ export class CuratorComponent implements OnInit {
this.affiliation.name = '';
this.affiliation.logo_url = '';
this.affiliation.website_url = '';
this.affiliationModal.okButtonText = 'Add new Affiliation';
}
this.affiliationModal.okButtonLeft = false;
this.affiliationModal.open();
@ -122,7 +122,7 @@ export class CuratorComponent implements OnInit {
if (curator) {
this.curator = curator;
this.curator.email = Session.getUserEmail();
if (this.curator.photo) {
if (this.curator.photo && this.curator.photo !== '') {
this.photo = this.properties.downloadUrl + '/' + this.curator.photo;
} else {
this.photo = '../../../assets/common-assets/curator-default.png';
@ -244,6 +244,10 @@ export class CuratorComponent implements OnInit {
}
);
} else {
if(this.deletePhoto) {
this.utilitiesService.deletePhoto(this.properties.deleteUrl + '/' + this.curator.photo).subscribe();
this.curator.photo = '';
}
this.curatorService.updateCurator(this.properties.adminToolsAPIURL + 'curator',
this.curator).subscribe((curator) => {
if (curator) {
@ -255,9 +259,9 @@ export class CuratorComponent implements OnInit {
this.handleUpdateError('An error has occurred. Try again later!', error);
this.resetChange();
});
}
}
}
}
}
isEmptyAffiliation(): boolean {
@ -310,4 +314,10 @@ export class CuratorComponent implements OnInit {
return null;
}
}
removePhoto() {
this.deletePhoto = true;
this.hasChanged = true;
this.photo = '../../../assets/common-assets/curator-default.png';
}
}