[develop]: Fix an error while inviting a person that it is already a member or manager. Remove message while accepting the member role.
This commit is contained in:
parent
e6d03d324f
commit
901f9f769d
|
@ -268,9 +268,9 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
return this.userRegistryService.invite(this.type, this.id, {
|
return this.userRegistryService.invite(this.type, this.id, {
|
||||||
link: this.link,
|
link: this.link,
|
||||||
email: this.emailComposer(this.name, email, this.role)
|
email: this.emailComposer(this.name, email, this.role)
|
||||||
}, this.role).pipe(map(invitation => new InvitationResponse(email, invitation), catchError(error => {
|
}, this.role).pipe(catchError(error => {
|
||||||
return of(new InvitationResponse(current, null));
|
return of(null);
|
||||||
})));
|
}), map(invitation => new InvitationResponse(email, invitation)));
|
||||||
});
|
});
|
||||||
this.subs.push(forkJoin(invitations).subscribe(responses => {
|
this.subs.push(forkJoin(invitations).subscribe(responses => {
|
||||||
let notifications = responses.map(response => {
|
let notifications = responses.map(response => {
|
||||||
|
@ -292,7 +292,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
return of(null);
|
return of(null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NotificationHandler.rise('An error has occurred while sending the invitation mail to ' + response.email + '.Please try again later', 'danger');
|
NotificationHandler.rise('An error has occurred while sending the invitation mail to ' +
|
||||||
|
response.email + '.Check if the user is already a ' + this.stakeholderUtils.roles[this.role] + ' or try again later', 'danger');
|
||||||
return of(null);
|
return of(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {Composer} from "../utils/email/composer";
|
||||||
import {ClearCacheService} from "../services/clear-cache.service";
|
import {ClearCacheService} from "../services/clear-cache.service";
|
||||||
import {BaseComponent} from "../sharedComponents/base/base.component";
|
import {BaseComponent} from "../sharedComponents/base/base.component";
|
||||||
import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
||||||
|
import {StringUtils} from "../utils/string-utils.class";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'role-verification',
|
selector: 'role-verification',
|
||||||
|
@ -20,12 +21,9 @@ import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
||||||
<modal-alert #managerModal [overflowBody]="false" (alertOutput)="verifyManager()" (cancelOutput)="cancel()"
|
<modal-alert #managerModal [overflowBody]="false" (alertOutput)="verifyManager()" (cancelOutput)="cancel()"
|
||||||
[okDisabled]="code.invalid || loading">
|
[okDisabled]="code.invalid || loading">
|
||||||
<div>
|
<div>
|
||||||
You have been invited to join <span
|
You have been invited to join <span class="uk-text-bold">{{name}}</span> {{(dashboard)}} Dashboard as a {{stakeholderUtils.roles.manager}}.
|
||||||
class="uk-text-bold">{{name}}</span> {{(service === 'monitor' ? 'Monitor' : 'Research Community')}} Dashboard
|
|
||||||
as a manager.
|
|
||||||
<span class="uk-text-primary">Fill</span> in the <span class="uk-text-primary">verification code</span>, sent to
|
<span class="uk-text-primary">Fill</span> in the <span class="uk-text-primary">verification code</span>, sent to
|
||||||
your
|
your email, to accept the invitation request.
|
||||||
email, to accept the invitation request.
|
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-center">
|
<div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-center">
|
||||||
<div input [formInput]="code" class="uk-width-medium" placeholder="Verification code">
|
<div input [formInput]="code" class="uk-width-medium" placeholder="Verification code">
|
||||||
|
@ -37,14 +35,12 @@ import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
||||||
</div>
|
</div>
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<modal-alert #memberModal [overflowBody]="false" (cancelOutput)="cancel()"
|
<modal-alert #memberModal [overflowBody]="false" (cancelOutput)="cancel()"
|
||||||
(alertOutput)="verifyMember()" [okDisabled]="(code.invalid || loading) && !isMember">
|
(alertOutput)="verifyMember()" [okDisabled]="(code.invalid || loading)">
|
||||||
<div *ngIf="!isMember">
|
<div>
|
||||||
<div>
|
<div>
|
||||||
You have been invited to join <span class="uk-text-bold">{{name}}</span> Monitor Dashboard as a member.
|
You have been invited to join <span class="uk-text-bold">{{name}}</span> {{(dashboard)}} as a {{stakeholderUtils.roles.member}}.
|
||||||
<span class="uk-text-primary">Fill</span> in the <span class="uk-text-primary">verification code</span>, sent
|
<span class="uk-text-primary">Fill</span> in the <span class="uk-text-primary">verification code</span>, sent
|
||||||
to
|
to your email, to accept the invitation request.
|
||||||
your
|
|
||||||
email, to accept the invitation request.
|
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-wrap uk-flex-center">
|
<div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-wrap uk-flex-center">
|
||||||
<div input [formInput]="code" class="uk-width-medium" placeholder="Verification code">
|
<div input [formInput]="code" class="uk-width-medium" placeholder="Verification code">
|
||||||
|
@ -55,13 +51,6 @@ import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
||||||
<loading></loading>
|
<loading></loading>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="isMember">
|
|
||||||
<div>
|
|
||||||
Welcome! You are now a member of the OpenAIRE Monitor Dashboard for the <span
|
|
||||||
class="uk-text-bold">{{name}}</span>!
|
|
||||||
From now on, you will have access to our restricted content.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<modal-alert #errorModal (alertOutput)="cancel()" [overflowBody]="false">
|
<modal-alert #errorModal (alertOutput)="cancel()" [overflowBody]="false">
|
||||||
<div>
|
<div>
|
||||||
|
@ -96,6 +85,8 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
public userInfoLink = null;
|
public userInfoLink = null;
|
||||||
@Input()
|
@Input()
|
||||||
public relativeTo: ActivatedRoute = this._route;
|
public relativeTo: ActivatedRoute = this._route;
|
||||||
|
@Input()
|
||||||
|
public dashboard: string = 'Research Community';
|
||||||
public user: User;
|
public user: User;
|
||||||
public verification: any;
|
public verification: any;
|
||||||
public code: UntypedFormControl;
|
public code: UntypedFormControl;
|
||||||
|
@ -106,9 +97,8 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
@ViewChild('errorModal') errorModal: AlertModal;
|
@ViewChild('errorModal') errorModal: AlertModal;
|
||||||
public error: string = null;
|
public error: string = null;
|
||||||
public loading: boolean = false;
|
public loading: boolean = false;
|
||||||
public isMember: boolean = false;
|
|
||||||
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
||||||
|
|
||||||
constructor(protected _route: ActivatedRoute,
|
constructor(protected _route: ActivatedRoute,
|
||||||
protected _router: Router,
|
protected _router: Router,
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
|
@ -119,18 +109,18 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
private cdr: ChangeDetectorRef) {
|
private cdr: ChangeDetectorRef) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.paramsSubscription = this._route.queryParams.subscribe(params => {
|
this.paramsSubscription = this._route.queryParams.subscribe(params => {
|
||||||
if (params) {
|
if (params) {
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
if(params['verify'] && !this.isMember) {
|
if(params['verify']) {
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
|
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
|
||||||
this.verification = verification;
|
this.verification = verification;
|
||||||
|
@ -157,51 +147,43 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
relativeTo: this.relativeTo
|
relativeTo: this.relativeTo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if(this.isMember) {
|
|
||||||
this.openMemberModal();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.isMember = false;
|
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
super.ngOnDestroy();
|
super.ngOnDestroy();
|
||||||
if (this.paramsSubscription instanceof Subscription) {
|
if (this.paramsSubscription instanceof Subscription) {
|
||||||
this.paramsSubscription.unsubscribe();
|
this.paramsSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public openManagerModal() {
|
public openManagerModal() {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.managerModal.okButtonLeft = false;
|
this.managerModal.okButtonLeft = false;
|
||||||
this.managerModal.okButtonText = 'Accept';
|
this.managerModal.okButtonText = 'Accept';
|
||||||
this.managerModal.stayOpen = true;
|
this.managerModal.stayOpen = true;
|
||||||
this.managerModal.cancelButtonText = 'Cancel';
|
this.managerModal.cancelButtonText = 'Cancel';
|
||||||
this.managerModal.alertTitle = this.stakeholderUtils.roles.manager + ' Invitation';
|
this.managerModal.alertTitle = StringUtils.capitalize(this.stakeholderUtils.roles.manager) + ' Invitation';
|
||||||
this.managerModal.open();
|
this.managerModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public openMemberModal() {
|
public openMemberModal() {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
if(this.isMember) {
|
this.memberModal.cancelButton = true;
|
||||||
this.memberModal.cancelButton = false;
|
this.memberModal.okButtonText = 'Accept';
|
||||||
this.memberModal.okButtonText = 'Close';
|
|
||||||
} else {
|
|
||||||
this.memberModal.cancelButton = true;
|
|
||||||
this.memberModal.okButtonText = 'Accept';
|
|
||||||
}
|
|
||||||
this.memberModal.okButtonLeft = false;
|
this.memberModal.okButtonLeft = false;
|
||||||
this.memberModal.stayOpen = true;
|
this.memberModal.stayOpen = true;
|
||||||
this.memberModal.cancelButtonText = 'Cancel';
|
this.memberModal.cancelButtonText = 'Cancel';
|
||||||
this.memberModal.alertTitle = this.stakeholderUtils.roles.member + ' Invitation';
|
this.memberModal.alertTitle = StringUtils.capitalize(this.stakeholderUtils.roles.member) + ' Invitation';
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
this.memberModal.open();
|
this.memberModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public openErrorModal() {
|
public openErrorModal() {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.errorModal.cancelButton = false;
|
this.errorModal.cancelButton = false;
|
||||||
|
@ -209,7 +191,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
this.errorModal.alertTitle = 'Invalid URL';
|
this.errorModal.alertTitle = 'Invalid URL';
|
||||||
this.errorModal.open();
|
this.errorModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifyManager() {
|
public verifyManager() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.subscriptions.push(this.userRegistryService.verify(this.verification.id, this.code.value).subscribe(() => {
|
this.subscriptions.push(this.userRegistryService.verify(this.verification.id, this.code.value).subscribe(() => {
|
||||||
|
@ -252,15 +234,13 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
this.error = 'The verification code is invalid';
|
this.error = 'The verification code is invalid';
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifyMember() {
|
public verifyMember() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
if (!this.isMember) {
|
|
||||||
this.subscriptions.push(this.userRegistryService.verify(this.verification.id, this.code.value, "member").subscribe(() => {
|
this.subscriptions.push(this.userRegistryService.verify(this.verification.id, this.code.value, "member").subscribe(() => {
|
||||||
this.clearCacheService.clearCache('Members updated');
|
this.clearCacheService.clearCache('Members updated');
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.isMember = true;
|
|
||||||
this.userManagementService.updateUserInfo(() => {
|
this.userManagementService.updateUserInfo(() => {
|
||||||
if (this.paramsSubscription instanceof Subscription) {
|
if (this.paramsSubscription instanceof Subscription) {
|
||||||
this.paramsSubscription.unsubscribe();
|
this.paramsSubscription.unsubscribe();
|
||||||
|
@ -271,17 +251,13 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.error = 'The verification code is invalid';
|
this.error = 'The verification code is invalid';
|
||||||
}));
|
}));
|
||||||
} else {
|
|
||||||
this.memberModal.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public reset() {
|
public reset() {
|
||||||
this.code = this.fb.control('', [Validators.required, Validators.pattern('^[+0-9]{6}$')]);
|
this.code = this.fb.control('', [Validators.required, Validators.pattern('^[+0-9]{6}$')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.isMember = false;
|
|
||||||
this._router.navigate([]);
|
this._router.navigate([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue