[Trunk|Library]: 1. Remove error and warning pages. 2. Block user when he tries to add an empty affiliation.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@55986 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-06-04 14:20:16 +00:00
parent 5a0ffefd54
commit d65a3e54a0
2 changed files with 72 additions and 81 deletions

View File

@ -65,9 +65,7 @@
<td class="uk-text-right"></td>
<td>
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
<div *ngIf="warning" class="uk-alert uk-alert-warning" role="alert">{{warning}}</div>
<div *ngIf="successfulSaveMessage" class="uk-alert uk-alert-success" role="alert">{{successfulSaveMessage}}</div>
<div *ngIf="successfulResetMessage" class="uk-alert uk-alert-warning" role="alert">{{successfulResetMessage}}</div>
</tr>
</tbody>
</table>
@ -85,14 +83,14 @@
<ul class="uk-list uk-list-divider uk-margin uk-height-max-large uk-overflow-auto">
<li *ngFor="let result of curator.affiliations; let i=index" class="uk-animation-fade uk-margin-auto uk-height-small uk-flex uk-flex-middle" uk-grid>
<div class="uk-width-1-5 uk-card uk-card-default affiliation-card uk-card-body uk-inline">
<img class="uk-padding uk-position-center" src="{{result.logoUrl}}" width="80" height="80" alt="{{result.name}}">
<img class="uk-padding uk-position-center" src="{{result.logo_url}}" width="80" height="80" alt="{{result.name}}">
</div>
<div class="uk-width-3-5">
<h3 class="uk-h3" title="{{result.name}}">{{_format(result.name)}}</h3>
<a href="{{result.websiteUrl}}" title="{{result.websiteUrl}}" class="uk-margin-auto-top" target="_blank">{{_format(result.websiteUrl)}}</a>
<a href="{{result.logo_url}}" title="{{result.website_url}}" class="uk-margin-auto-top" target="_blank">{{_format(result.website_url)}}</a>
</div>
<div class="uk-width-1-5 uk-card">
<button class="uk-icon-button uk-icon uk-button-secondary" title="Edit" uk-icon="pencil" (click)="chooseAffiliation(i, 'edit')"></button>
<button class="uk-icon-button uk-icon uk-button-secondary uk-margin-small-right" title="Edit" uk-icon="pencil" (click)="chooseAffiliation(i, 'edit')"></button>
<button class="uk-icon-button uk-icon uk-button-danger" title="Remove" uk-icon="minus" (click)="chooseAffiliation(i)"></button>
</div>
</li>
@ -116,7 +114,7 @@
<td class="uk-text-left">
<input type="text"
class="form-control uk-input uk-width-large@l uk-width-medium@s" id="logourl"
[(ngModel)]="affiliation.logoUrl">
[(ngModel)]="affiliation.logo_url">
</td>
</tr>
<tr>
@ -124,7 +122,7 @@
<td class="uk-text-left">
<input type="text"
class="form-control uk-input uk-width-large@l uk-width-medium@s" id="websiteurl"
[(ngModel)]="affiliation.websiteUrl">
[(ngModel)]="affiliation.website_url">
</td>
</tr>
</tbody>

View File

@ -22,10 +22,7 @@ export class CuratorComponent implements OnInit {
@ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal;
public showLoading = true;
public updateErrorMessage = '';
public warning = '';
public successfulSaveMessage = '';
public successfulResetMessage = '';
public hasChanged = false;
public curatorId = null;
@ -57,7 +54,6 @@ export class CuratorComponent implements OnInit {
} else {
this.showLoading = true;
this.updateErrorMessage = '';
this.warning = '';
this.curatorId = Session.getUser().id;
this.curatorService.getCurator(this.properties,
this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
@ -72,9 +68,7 @@ export class CuratorComponent implements OnInit {
}
this.showLoading = false;
HelperFunctions.scroll();
}
},
error => {
} else {
this.curator = new Curator();
this.curator._id = this.curatorId;
this.curator.email = Session.getUserEmail();
@ -82,11 +76,13 @@ export class CuratorComponent implements OnInit {
this.curator.affiliations = [];
this.curator.bio = '';
this.curator.photo = null;
this.handleWarning('No personal info has been found!');
this.photo = '../../../assets/common-assets/curator-default.png';
this.showLoading = false;
HelperFunctions.scroll();
}
},
error => {
}
);
}
});
@ -96,11 +92,14 @@ export class CuratorComponent implements OnInit {
this.affiliation = new Affiliation();
if (affiliation) {
this.affiliation.name = affiliation.name;
this.affiliation.logoUrl = affiliation.logoUrl;
this.affiliation.websiteUrl = affiliation.websiteUrl;
this.affiliation.logo_url = affiliation.logo_url;
this.affiliation.website_url = affiliation.website_url;
this.affiliationModal.okButtonText = 'Edit Affiliation';
} else {
this.index = -1;
this.affiliation.name = '';
this.affiliation.logo_url = '';
this.affiliation.website_url = '';
this.affiliationModal.okButtonText = 'Add new Affiliation';
}
this.affiliationModal.okButtonLeft = false;
@ -117,14 +116,12 @@ export class CuratorComponent implements OnInit {
if (this.curatorId != null && this.curatorId !== '') {
this.showLoading = true;
this.updateErrorMessage = '';
this.warning = '';
this.curatorService.getCurator(this.properties,
this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
curator => {
if (curator) {
this.curator = curator;
this.curator.email = Session.getUserEmail();
this.handleSuccessfulReset('Your Personal Info has been reset!');
if (this.curator.photo) {
this.photo = this.properties.downloadUrl + '/' + this.curator.photo;
} else {
@ -132,9 +129,7 @@ export class CuratorComponent implements OnInit {
}
this.showLoading = false;
HelperFunctions.scroll();
}
},
error => {
} else {
this.curator = new Curator();
this.curator._id = this.curatorId;
this.curator.email = Session.getUserEmail();
@ -142,11 +137,13 @@ export class CuratorComponent implements OnInit {
this.curator.affiliations = [];
this.curator.bio = '';
this.curator.photo = null;
this.handleWarning('No personal info has been found!');
this.photo = '../../../assets/common-assets/curator-default.png';
this.showLoading = false;
HelperFunctions.scroll();
}
},
error => {
}
);
}
this.resetChange();
@ -163,7 +160,6 @@ export class CuratorComponent implements OnInit {
private resetMessages() {
this.successfulSaveMessage = '';
this.successfulResetMessage = '';
this.updateErrorMessage = '';
}
@ -189,12 +185,6 @@ export class CuratorComponent implements OnInit {
this.showLoading = false;
}
handleWarning(message: string) {
this.warning = message;
this.showLoading = false;
HelperFunctions.scroll();
}
handleSuccessfulSave(message) {
this.resetMessages();
this.showLoading = false;
@ -202,14 +192,6 @@ export class CuratorComponent implements OnInit {
this.successfulSaveMessage = message;
}
handleSuccessfulReset(message) {
this.resetMessages();
this.showLoading = false;
HelperFunctions.scroll();
this.successfulResetMessage = message;
}
fileChangeEvent(event) {
this.showLoading = true;
if (event.target.files && event.target.files[0]) {
@ -232,6 +214,12 @@ export class CuratorComponent implements OnInit {
updateCurator() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams:
{'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else {
if (this.hasChanged && this.curator && this.curator.name && this.curator.name !== '') {
this.showLoading = true;
if (this.file) {
@ -252,7 +240,7 @@ export class CuratorComponent implements OnInit {
this.resetChange();
});
}, error => {
this.handleWarning('An error has occurred during photo uploading.');
this.handleUpdateError('An error has occurred during photo uploading.', error);
}
);
} else {
@ -270,11 +258,12 @@ export class CuratorComponent implements OnInit {
}
}
}
}
isEmptyAffiliation(): boolean {
return ((!this.affiliation.name || this.affiliation.name === '') &&
(!this.affiliation.logoUrl || this.affiliation.logoUrl === '') &&
(!this.affiliation.websiteUrl || this.affiliation.websiteUrl === ''));
return ((!this.affiliation.name || this.affiliation.name === '') ||
(!this.affiliation.logo_url || this.affiliation.logo_url === '') ||
(!this.affiliation.website_url || this.affiliation.website_url === ''));
}
addAffiliation() {
@ -303,6 +292,10 @@ export class CuratorComponent implements OnInit {
}
_format(name: string){
if(name) {
return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
} else {
return null;
}
}
}