[Library | Trunk]: Add isManager method for editing subscriber invitation message

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60275 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-01-21 16:22:16 +00:00
parent 7d147b89e7
commit b2152f1f19
1 changed files with 10 additions and 2 deletions

View File

@ -6,9 +6,10 @@ import {Email} from "../../utils/email/email";
import {Body} from "../../utils/email/body"; import {Body} from "../../utils/email/body";
import {CommunityService} from "../../connect/community/community.service"; import {CommunityService} from "../../connect/community/community.service";
import {Composer} from "../../utils/email/composer"; import {Composer} from "../../utils/email/composer";
import {User} from "../../login/utils/helper.class"; import {Session, User} from "../../login/utils/helper.class";
import {EmailService} from "../../utils/email/email.service"; import {EmailService} from "../../utils/email/email.service";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {CommunityInfo} from "../../connect/community/communityInfo";
declare var UIkit; declare var UIkit;
@ -31,10 +32,11 @@ declare var UIkit;
Message *: Message *:
</div> </div>
<div class="uk-width-expand"> <div class="uk-width-expand">
<ckeditor class="form-control" formControlName="message" id="message" <ckeditor *ngIf="isManager" class="form-control" formControlName="message" id="message"
debounce="400" debounce="400"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print', [config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
extraPlugins: 'divarea'}"></ckeditor> extraPlugins: 'divarea'}"></ckeditor>
<div *ngIf="!isManager" [innerHTML]="body.paragraphs"></div>
<div class="uk-margin-top"> <div class="uk-margin-top">
{{body.signature}} {{body.signature}}
<span *ngIf="body.fromName == ''" class="uk-text-muted"> <span *ngIf="body.fromName == ''" class="uk-text-muted">
@ -55,6 +57,7 @@ declare var UIkit;
export class SubscriberInviteComponent implements OnInit, OnDestroy { export class SubscriberInviteComponent implements OnInit, OnDestroy {
@Input() @Input()
public user: User; public user: User;
public community: CommunityInfo
public inviteForm: FormGroup; public inviteForm: FormGroup;
public email: Email; public email: Email;
public body: Body; public body: Body;
@ -90,6 +93,7 @@ export class SubscriberInviteComponent implements OnInit, OnDestroy {
message: this.fb.control('', Validators.required) message: this.fb.control('', Validators.required)
}); });
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.community = community;
this.inviteForm.get('name').enable(); this.inviteForm.get('name').enable();
this.inviteForm.get('name').setValue(this.user.fullname); this.inviteForm.get('name').setValue(this.user.fullname);
this.inviteForm.get('name').disable(); this.inviteForm.get('name').disable();
@ -150,6 +154,10 @@ export class SubscriberInviteComponent implements OnInit, OnDestroy {
} }
} }
get isManager() {
return Session.isPortalAdministrator(this.user) && Session.isCurator('community', this.user) && Session.isManager('community', this.community.communityId, this.user);
}
get valid() { get valid() {
return this.inviteForm && this.inviteForm.valid; return this.inviteForm && this.inviteForm.valid;
} }