Project

General

Profile

« Previous | Next » 

Revision 60969

[Connect | Trunk]: Add subscriber invite module from library

View differences:

modules/uoa-connect-portal/trunk/src/app/utils/subscribe/subscribe.component.ts
26 26
        <a class="uk-alert-close" uk-close></a>
27 27
        <p>Please login first to subscribe</p>
28 28
      </div>
29
      <button *ngIf="loading" class="uk-button portal-button uk-button-small uk-width-1-1">
29
      <button *ngIf="loading" id="subscribe" class="uk-button portal-button uk-button-small uk-width-1-1">
30 30
        <span class="uk-icon"><loading [top_margin]="false" [size]="'small'" [color]="null"></loading></span>
31 31
      </button>
32
      <button *ngIf="!subscribed && !loading" class="uk-button portal-button uk-button-small uk-width-1-1"
32
      <button *ngIf="!subscribed && !loading" id="subscribe" class="uk-button portal-button uk-button-small uk-width-1-1"
33 33
              (click)="subscribe()">
34 34
        <span class="uk-icon uk-flex uk-flex-middle">
35 35
          <svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
......
40 40
          <span class="space">Subscribe</span>
41 41
        </span>
42 42
      </button>
43
      <button *ngIf="subscribed && !loading" class="subscribed-button uk-button uk-button-small uk-width-1-1"
43
      <button *ngIf="subscribed && !loading" id="subscribe" class="subscribed-button uk-button uk-button-small uk-width-1-1"
44 44
              (click)="confirmOpen()" [disabled]="isManager" [attr.uk-tooltip]="isManager?'You cannot unsubscribe because you are a manager':null">
45 45
        <span class="uk-icon uk-flex uk-flex-middle">
46 46
          <svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
......
71 71
  
72 72
  loading: boolean = false;
73 73
  subscribed: boolean = null;
74
  @Input() properties: EnvProperties = properties;
74
  properties: EnvProperties = properties;
75 75
  members: number = 0;
76 76
  @Output() countSubscribersEvent = new EventEmitter();
77 77
  showLoginAlert: Boolean = false;
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.html
1 1
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other"></schema2jsonld>
2

  
3
<div *ngIf="longView == true" class="">
4
  <div class="uk-section uk-padding-remove-top tm-middle" id="tm-main">
2
<div *ngIf="longView">
3
  <div class="uk-section uk-padding-remove-top">
5 4
    <breadcrumbs addClass="uk-margin-large-left uk-margin-remove-bottom uk-margin-small-top"
6 5
                 [breadcrumbs]="breadcrumbs"></breadcrumbs>
7

  
8
    <div class="uk-container  uk-margin-bottom">
6
    <div class="uk-container uk-margin-bottom">
9 7
      <helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
10 8
              [texts]="pageContents['top']"></helper>
11
      <div id="invite" class=" uk-card uk-card-default uk-padding uk-margin-top">
12
        <div class="uk-text-large uk-text-center uk-width-5-6@l uk-width ">Invite users to subscribe</div>
13
        <div class="uk-margin-top">
14
          <errorMessages [status]="[status]" [type]="'community'"></errorMessages>
9
      <div class=" uk-card uk-card-default uk-padding uk-margin-top">
10
        <h5 class="uk-text-center">Invite users to subscribe</h5>
11
        <div *ngIf="subscriberInvite.loading" class="uk-height-large uk-position-relative">
12
          <loading class="uk-position-center"></loading>
15 13
        </div>
16
        <div *ngIf="missingCommunityId" class="uk-alert uk-alert-warning" role="alert">{{missingCommunityId}}</div>
17
        <div *ngIf="successfulSentMessage" class="uk-alert uk-alert-success"
18
             role="alert">{{successfulSentMessage}} {{successfulSentRecipients}}</div>
19
        <div *ngIf="failureSentMessage" class="uk-alert uk-alert-warning"
20
             role="alert">{{failureSentMessage}} {{failureSentRecipients}}</div>
21
        <div *ngIf="inviteErrorMessage" class="uk-alert uk-alert-warning" role="alert">{{inviteErrorMessage}}</div>
22
        <div *ngIf="communityId != null && status == errorCodes.DONE">
23
          <table class="uk-table uk-align-center">
24
            <tbody>
25
            <!-- <tr>
26
                <td>
27
                </td>
28
                <td>
29
                    <li>Invite by email</li>
30
                </td>
31
            </tr> -->
32
            <tr>
33
              <td for="from" class="uk-text-bold uk-width-1-4 uk-text-right">From <span
34
                  class="uk-text-danger uk-text-bold">*</span> :
35
              </td>
36
              <td class="uk-text-left uk-width-expand">
37
                <input placeholder="Type your name" type="text" (click)="resetMessages()"
38
                       class="form-control uk-input uk-width-large@l uk-width-medium@s" [(ngModel)]="body.fromName"
39
                       id="from" required>
40
                <div *ngIf="!body.fromName" class="uk-width-large uk-text-danger uk-text-small">Please add your name.
41
                </div>
42
              </td>
43
            </tr>
44
            <tr>
45
              <td for="recipients" class="uk-text-bold uk-text-right">To <span
46
                  class="uk-text-danger uk-text-bold">*</span> :
47
              </td>
48
              <td class="uk-text-left">
49
                <input placeholder="email" type="text" (click)="resetMessages(); areValid=true"
50
                       class="form-control uk-input uk-width-large@l uk-width-medium@s" [(ngModel)]="recipients"
51
                       id="recipients"
52
                       required>
53
                <div *ngIf="areValid && !showAddRecipientMessage" class="uk-width-medium uk-text-muted uk-text-small">
54
                  separate multiple emails with a comma
55
                </div>
56
                <div *ngIf="recipients && !areValid" class="uk-width-large uk-text-danger uk-text-small">Please add
57
                  valid email/s.
58
                </div>
59
                <div *ngIf="isEmpty(recipients) && showAddRecipientMessage"
60
                     class="uk-width-large uk-text-danger uk-text-small">Please add a recipient.
61
                </div>
62
              </td>
63
            </tr>
64
            </tbody>
65
          </table>
66
          <div class="boundary-align uk-panel uk-placeholder">
67
            <table class="uk-table uk-align-center uk-padding">
68
              <tbody>
69
              <tr>
70
                <td for="email.body" class="uk-text-bold">Message:</td>
71
                <td *ngIf="allowEdit()" class="uk-width-expand uk-text-left">
72
                  <ckeditor (click)="resetMessages()"
73
                            class="form-control" [(ngModel)]="body.paragraphs" id="message"
74
                            debounce="400"
75
                            [config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
76
                                                                   extraPlugins: 'divarea'}">
77
                    <!-- <id="contentTag"-->
78
                    <!--(ready)="onReady($event)"-->
79
                    <!--(focus)="onFocus($event)"-->
80
                    <!--[config]="{uiColor: '#99000'}"-->
81
                    <!--(blur)="onBlur($event)"-->
82
                    <!--(change)="onChange($event)"-->
83
                  </ckeditor>
84
                </td>
85
                <td *ngIf="!allowEdit()" class="uk-text-left">
86

  
87
                  <div [innerHtml]="body.paragraphs"></div>
88
                </td>
89
              </tr>
90
              <tr>
91
                <td></td>
92
                <td class="uk-text-left">
93
                  <!-- {{body.closing}}<br> -->
94
                  {{body.signature}}
95
                  <span *ngIf="body.fromName == ''" class="uk-text-muted">
96
                                                        <i>{{body.fromMessage}}...</i>
97
                                                </span>
98
                  <span *ngIf="body.fromName !=''">
99
                                                        {{body.fromMessage}}
100
                    <b>{{body.fromName}}</b>
101
                                                </span>
102
                  <br><a href="https://www.openaire.eu">www.openaire.eu</a>
103
                </td>
104
              </tr>
105
              </tbody>
106
            </table>
14
        <div class="uk-padding uk-padding-remove-horizontal" [class.uk-hidden]="subscriberInvite.loading">
15
          <subscriber-invite #subscriberInvite [user]="user"></subscriber-invite>
16
          <div class="uk-flex uk-flex-right uk-margin-medium-top">
17
            <a class="uk-button uk-button-default" routerLink="/">Cancel</a>
18
            <button [class.uk-disabled]="!subscriberInvite.valid" class="uk-button portal-button uk-margin-small-left" (click)="subscriberInvite.invite()">Invite</button>
107 19
          </div>
108
          <table class="uk-table uk-align-center">
109
            <tbody>
110
            <tr>
111
              <td class="uk-text-bold uk-width-3-5@xl uk-width-3-5@m uk-width-3-5@s uk-text-right"></td>
112
              <td>
113
                <div class="uk-padding uk-padding-remove-top uk-padding-remove-bottom uk-text-danger uk-text-bold">*
114
                  Required fields
115
                </div>
116
              </td>
117
            </tr>
118
            <tr>
119
              <td class="uk-text-right"></td>
120
              <td>
121
                <div
122
                    class="uk-grid-margin uk-first-column uk-align-center uk-text-left uk-padding uk-padding-remove-top uk-padding-remove-bottom">
123
                  <button class="uk-button portal-button" (click)="invite()">Invite</button>
124
                </div>
125
              </td>
126
            </tr>
127
            </tbody>
128
          </table>
129

  
130
          <div class="uk-text-left">
131
            <span uk-icon="chevron-left"></span><span class="uk-margin-small-left">
132
                    <a [queryParams]="communityIdParam" routerLinkActive="router-link-active"
133
                       routerLink="/" class="portal-link">Back</a>
134
            </span>
135
          </div>
136

  
137 20
        </div>
138 21
      </div>
139 22
      <helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0"
......
142 25
  </div>
143 26
</div>
144 27
<div *ngIf="!longView" class="uk-margin-small-top">
145
  <button
146
      [class]=" ((buttonSizeSmall)?'uk-button-small':'') + ' uk-button  portal-button uk-button-small uk-width-1-1'">
28
  <button id="invite" class="uk-button portal-button uk-button-small uk-width-1-1">
147 29
    <span class="uk-icon uk-flex uk-flex-middle">
148 30
      <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
149 31
        <path d="M0 0h24v24H0z" fill="none"></path>
......
153 35
      <span class="space">Invite users</span>
154 36
    </span>
155 37
  </button>
156
  <div uk-dropdown="mode: click" class="uk-form uk-margin-small uk-alert uk-background-default" id="toggle-usage">
157
    <div class="uk-margin-top">
158
      <errorMessages [status]="[status]" [type]="'community'"></errorMessages>
38
  <div #dropdown uk-dropdown="mode: click" [class.uk-hidden]="subscriberInvite.loading" class="uk-form uk-margin-small uk-alert uk-background-default" id="toggle-usage" style="width: 300px;">
39
    <div>
40
      <subscriber-invite #subscriberInvite [user]="user" [longView]="false"></subscriber-invite>
41
      <div class="uk-flex uk-flex-middle uk-child-width-1-2 uk-margin-small-top">
42
        <span><a class="uk-button uk-button-default uk-button-small" (click)="close(dropdown)" routerLink="/invite">Customize</a></span>
43
        <span class="uk-flex uk-flex-right">
44
        <button [class.uk-disabled]="!subscriberInvite.valid" class="portal-button uk-button uk-button-small" (click)="subscriberInvite.invite();close(dropdown)">Send</button>
45
      </span>
46
      </div>
159 47
    </div>
160
    <div *ngIf="missingCommunityId" class="uk-width-large uk-text-warning uk-text-small uk-margin-top"
161
         role="alert">{{missingCommunityId}}</div>
162
    <div *ngIf="successfulSentMessage" class="uk-width-large uk-text-success uk-text-small uk-margin-top"
163
         role="alert">{{successfulSentMessage}} {{successfulSentRecipients}}</div>
164
    <div *ngIf="failureSentMessage" class="uk-width-large uk-text-warning uk-text-small uk-margin-top"
165
         role="alert">{{failureSentMessage}} {{failureSentRecipients}}</div>
166
    <div *ngIf="inviteErrorMessage" class="uk-width-large uk-text-warning uk-text-small uk-margin-top"
167
         role="alert">{{inviteErrorMessage}}</div>
168

  
169
    <div *ngIf="recipients && !areValid" class="uk-width-large uk-text-danger uk-text-small uk-margin-top">Please add
170
      valid email/s.
171
    </div>
172
    <div *ngIf="isEmpty(recipients) && showAddRecipientMessage"
173
         class="uk-width-large uk-text-danger uk-text-small uk-margin-top">Please add a recipient.
174
    </div>
175
    <input (click)="resetMessages(); areValid=true" placeholder="Type e-mails" type="text"
176
           class="form-control uk-input uk-form-small uk-form" [(ngModel)]="recipients" id="recipients"
177
           required>
178
    <div class="uk-width-medium uk-text-muted uk-text-small">separate with commas</div>
179
    <div class="uk-margin-small-top uk-text-center ">
180
      <button class=" uk-button portal-button ignoreCommunityPanelBackground uk-button-small " (click)="invite()">
181
        Invite
182
      </button>
183
      {{" "}}
184
      <a class=" uk-button uk-button-default uk-button-small ignoreCommunityPanelBackground "
185
         [queryParams]="communityIdParam"
186
         routerLinkActive="router-link-active" routerLink="/invite">
187
                        <span class="uk-margin-xsmall-left uk-icon">
188
                            <svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
189
                                 icon="cog"
190
                                 ratio="0.8"><circle fill="none" stroke="#000" cx="9.997" cy="10" r="3.31"></circle><path
191
                                fill="none" stroke="#000"
192
                                d="M18.488,12.285 L16.205,16.237 C15.322,15.496 14.185,15.281 13.303,15.791 C12.428,16.289 12.047,17.373 12.246,18.5 L7.735,18.5 C7.938,17.374 7.553,16.299 6.684,15.791 C5.801,15.27 4.655,15.492 3.773,16.237 L1.5,12.285 C2.573,11.871 3.317,10.999 3.317,9.991 C3.305,8.98 2.573,8.121 1.5,7.716 L3.765,3.784 C4.645,4.516 5.794,4.738 6.687,4.232 C7.555,3.722 7.939,2.637 7.735,1.5 L12.263,1.5 C12.072,2.637 12.441,3.71 13.314,4.22 C14.206,4.73 15.343,4.516 16.225,3.794 L18.487,7.714 C17.404,8.117 16.661,8.988 16.67,10.009 C16.672,11.018 17.415,11.88 18.488,12.285 L18.488,12.285 Z"></path></svg>
193

  
194
                          </span>
195
        Customize
196
      </a>
197
    </div>
198 48
  </div>
199 49
</div>
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts
1 1
import {Component, Input, OnInit} from '@angular/core';
2
import {FormBuilder} from "@angular/forms";
3 2
import {ActivatedRoute, Router} from '@angular/router';
4 3

  
5
import {ConnectHelper} from '../../../openaireLibrary/connect/connectHelper';
6

  
7
import {Email} from '../../../openaireLibrary/utils/email/email';
8
import {Body} from '../../../openaireLibrary/utils/email/body';
9
import {Validator} from '../../../openaireLibrary/utils/email/validator';
10
import {Composer} from '../../../openaireLibrary/utils/email/composer';
11

  
12 4
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
13
import {EmailService} from '../../../openaireLibrary/utils/email/email.service';
14
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
15
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
16
import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component';
17
import {Session, User} from '../../../openaireLibrary/login/utils/helper.class';
18
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
5
import {User} from '../../../openaireLibrary/login/utils/helper.class';
19 6
import {HelperService} from "../../../openaireLibrary/utils/helper/helper.service";
20 7
import {Meta, Title} from "@angular/platform-browser";
21 8
import {SEOService} from "../../../openaireLibrary/sharedComponents/SEO/SEO.service";
22 9
import {PiwikService} from "../../../openaireLibrary/utils/piwik/piwik.service";
23
import {PiwikHelper} from "../../piwikHelper";
24 10
import {UserManagementService} from "../../../openaireLibrary/services/user-management.service";
25 11
import {Breadcrumb} from "../../../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
26 12
import {Subscriber, Subscription} from "rxjs";
27 13
import {properties} from "../../../../environments/environment";
28 14

  
15
declare var UIkit;
16

  
29 17
@Component({
30 18
  selector: 'invite',
31 19
  templateUrl: './invite.component.html',
32 20
})
33

  
34 21
export class InviteComponent implements OnInit {
35

  
36 22
  @Input() longView: boolean = true;
37 23
  @Input() communityId = null;
38
  @Input() buttonSizeSmall = true;
39

  
40
  @Input() properties: EnvProperties;
41

  
42
  public community = null;
43
  //public showLoading: boolean = true;
44
  public errorMessage: string = '';
45
  public successfulSentMessage: string = '';
46
  public successfulSentRecipients: string[] = [];
47
  public failureSentMessage: string = '';
48
  public failureSentRecipients: string[] = [];
49
  public inviteErrorMessage: string = '';
50
  public missingCommunityId: string = '';
51
  public showAddRecipientMessage: boolean = false;
52
  public showAddNameMessage: boolean = false;
53

  
54
  public email: Email;
55
  public body: Body;
56
  public recipients: string;
57
  public fullname: string;
58

  
59
  public areValid: boolean = true;
60

  
61
  private ckeditorContent: string;
62

  
63
  // public defaultBody ='';
64

  
65
  public communityIdParam = {};
66
  public status: number = 1;
67
  public errorCodes: ErrorCodes;
68
  private errorMessages: ErrorMessagesComponent;
69
  public pageContents = null;
70
  public divContents = null;
71

  
72
  public url: string = null;
24
  public properties: EnvProperties = properties;
73 25
  public pageTitle: string = "Invite";
74
  private user: User;
75

  
26
  public user: User;
27
  public url: string;
28
  public pageContents;
29
  public divContents
76 30
  public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'invite'}];
77

  
78
  subs: Subscription[] = [];
79

  
31
  private subs: Subscription[] = [];
32
  
80 33
  constructor(
81 34
    private route: ActivatedRoute,
82 35
    private _router: Router,
83
    public _fb: FormBuilder,
84
    private _emailService: EmailService,
85
    private _communityService: CommunityService,
36
    private _meta: Meta,
86 37
    private helper: HelperService,
87
    private _meta: Meta,
88 38
    private _title: Title,
89 39
    private seoService: SEOService,
90 40
    private _piwikService: PiwikService,
91 41
    private userManageService: UserManagementService) {
92

  
93
    this.errorCodes = new ErrorCodes();
94
    this.errorMessages = new ErrorMessagesComponent();
95
    this.status = this.errorCodes.LOADING;
96 42
  }
97

  
43
  
98 44
  public ngOnInit() {
99
    if(!this.properties) {
100
      this.properties = properties;
101
    }
102
    if(this.properties) {
103
      this.errorMessage = "";
104
      this.missingCommunityId = "";
105
      this.status = this.errorCodes.LOADING;
106
      this.subs.push(this.userManageService.getUserInfo().subscribe(
107
        user => {
108
          this.user = user;
109
          this.init();
110
        },
111
        error => {
112
          this.init();
113
        }
114
      ));
115
      //this.init();
116
    }
45
    this.subs.push(this.userManageService.getUserInfo().subscribe(
46
      user => {
47
        this.user = user;
48
    }));
49
    this.getPageContents();
50
    this.url = this.properties.domain + this._router.url;
51
    this.seoService.createLinkForCanonicalURL(this.url);
52
    this.updateUrl(this.url );
53
    this.updateTitle(this.pageTitle);
54
    this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
117 55
  }
118

  
56
  
119 57
  ngOnDestroy() {
120 58
    for (let sub of this.subs) {
121 59
      if (sub instanceof Subscriber) {
......
123 61
      }
124 62
    }
125 63
  }
126

  
127
  private init() {
128
    this.subs.push(this.route.queryParams.subscribe(
129
      communityId => {
130
        //if(!this.communityId && typeof document !== 'undefined'){
131
        this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
132
        if (!this.communityId) {
133
          this.communityId = communityId['communityId'];
134
        }
135

  
136
        if (this.longView) {
137
          if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
138
            this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
139
          }
140
          this.url = this.properties.domain + this._router.url;
141
          this.seoService.createLinkForCanonicalURL(this.url);
142
          this.updateUrl(this.url);
143
          this.updateTitle(this.pageTitle);
144
          this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
145
        }
146
        this.communityIdParam = (this.properties.environment != "development") ? {} : {communityId: this.communityId};
147
        if (this.communityId != null && this.communityId != '') {
148
          //this.getDivContents();
149
          this.getPageContents();
150
          this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
151
            community => {
152
              this.community = community;
153
              this.fullname = (this.user) ? this.user.fullname : null;
154
              //console.log("Fullname from session " + Session.getUserFullName());
155

  
156
              this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
157
              this.email = Composer.initializeInvitationsEmail(community.title);
158
              this.recipients = "";
159

  
160
              this.status = this.errorCodes.DONE;
161
            },
162
            error => {
163
              //this.handleError(error)
164
              this.handleError("Error getting community with id: " + this.communityId, error);
165
              this.status = this.errorMessages.getErrorCode(error.status);
166
            }
167
          ));
168
        } else {
169
          this.status = this.errorCodes.DONE;
170
          this.missingCommunityId = "There is no community selected!";
171
        }
172

  
173
      }));
174
  }
175

  
64
  
176 65
  private getPageContents() {
177 66
    this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
178 67
      this.pageContents = contents;
179 68
    }));
180 69
  }
181

  
70
  
182 71
  private getDivContents() {
183 72
    this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
184 73
      this.divContents = contents;
185 74
    }));
186 75
  }
187

  
188

  
189
  public invite() {
190
    this.successfulSentMessage = "";
191
    this.failureSentMessage = "";
192
    this.inviteErrorMessage = "";
193
    this.status = this.errorCodes.LOADING;
194
    HelperFunctions.scroll();
195
    if (!this.isEmpty(this.recipients) && this.body.fromName != "") {
196
      if (this.validateEmails()) {
197
        this.composeEmail();
198

  
199
        this.subs.push(this._emailService.sendEmail(this.properties, this.email).subscribe(
200
          res => {
201
            this.status = this.errorCodes.DONE;
202
            if (res['success']) {
203
              this.successfulSentMessage = "Email sent successfully to: ";
204
              this.successfulSentRecipients = res['success'];
205
            }
206
            if (res['failure']) {
207
              this.failureSentMessage = "There was an error sending email to: ";
208
              this.failureSentRecipients = res['failure'];
209
            }
210

  
211
            this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
212
            this.email = Composer.initializeInvitationsEmail(this.community.title);
213
            this.recipients = "";
214
          },
215
          error => {
216
            //console.log(error);
217
            this.handleError("Error inviting emails: " + JSON.stringify(this.recipients) + " to community with id: " + this.communityId + " by: " + this.fullname, error);
218
            this.status = this.errorCodes.DONE;
219
            this.inviteErrorMessage = "There was an error sending emails. Please try again.";
220
          }
221
        ));
222
      } else {
223
        this.email.recipients = [];
224
        this.status = this.errorCodes.DONE;
225
      }
226
    } else {
227
      this.showAddRecipientMessage = true;
228
      this.status = this.errorCodes.DONE;
229
    }
230
  }
231

  
232
  public isEmpty(data: string): boolean {
233
    return data != undefined && !data.replace(/\s/g, '').length;
234
  }
235

  
236
  public resetMessages() {
237
    this.errorMessage = "";
238
    this.successfulSentMessage = "";
239
    this.failureSentMessage = "";
240
    this.inviteErrorMessage = "";
241
  }
242

  
243
  public validateEmails(): boolean {
244
    if (this.parseEmails()) {
245
      if (Validator.hasValidEmails(this.email.recipients)) {
246
        return this.areValid;
247
      }
248
    }
249
    this.areValid = false;
250
    return this.areValid;
251
  }
252

  
253
  public parseEmails(): boolean {
254
    let email = new Array<string>();
255

  
256
    // remove spaces
257
    this.recipients = this.recipients.replace(/\s/g, '');
258

  
259
    // remove commas
260
    email = this.recipients.split(",");
261

  
262
    // remove empty fields
263
    for (let i = 0; i < email.length; i++) {
264
      if (!(email[i] == "")) {
265
        this.email.recipients.push(email[i]);
266
      }
267
    }
268
    return true;
269
  }
270

  
271
  public composeEmail() {
272
    this.email.body = Composer.formatEmailBodyForInvitation(this.body);
273
  }
274 76
  
275
  allowEdit() {
276
    if (!this.user) {
277
      return false;
278
    }
279
    var email = this.user.email;
280
    var index = -1;
281
    if (email && this.community != null && this.community.managers != null) {
282
      index = this.community.managers.indexOf(email);
283
    }
284
    return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || index != -1;
285
  }
286

  
287
  private handleError(message: string, error) {
288
    console.error("Invite Page (or component): " + message, error);
289
  }
290

  
291 77
  private updateDescription(description: string) {
292 78
    this._meta.updateTag({content: description}, "name='description'");
293 79
    this._meta.updateTag({content: description}, "property='og:description'");
294 80
  }
295

  
81
  
296 82
  private updateTitle(title: string) {
297 83
    var _title = ((title.length > 50) ? title.substring(0, 50) : title);
298 84
    this._title.setTitle(_title);
299 85
    this._meta.updateTag({content: _title}, "property='og:title'");
300 86
  }
301

  
87
  
302 88
  private updateUrl(url: string) {
303 89
    this._meta.updateTag({content: url}, "property='og:url'");
304 90
  }
91
  
92
  close(element) {
93
    UIkit.dropdown(element).hide();
94
    this
95
  }
305 96
}
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/inviteBasic.module.ts
16 16
import {SEOServiceModule} from "../../../openaireLibrary/sharedComponents/SEO/SEOService.module";
17 17
import {PiwikService} from "../../../openaireLibrary/utils/piwik/piwik.service";
18 18
import {BreadcrumbsModule} from "../../../openaireLibrary/utils/breadcrumbs/breadcrumbs.module";
19
import {SubscriberInviteModule} from "../../../openaireLibrary/sharedComponents/subscriber-invite/subscriber-invite.module";
20
import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module";
21
import {IconsService} from "../../../openaireLibrary/utils/icons/icons.service";
22
import {cog, send} from "../../../openaireLibrary/utils/icons/icons";
23
import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module";
19 24

  
20 25
@NgModule({
21 26
  imports: [
22 27
    RouterModule, CommonModule, FormsModule, CKEditorModule, ErrorMessagesModule,
23
    HelperModule, Schema2jsonldModule, SEOServiceModule, BreadcrumbsModule
28
    HelperModule, Schema2jsonldModule, SEOServiceModule, BreadcrumbsModule, SubscriberInviteModule, LoadingModule, IconsModule
24 29
  ],
25 30
  declarations: [
26 31
    InviteComponent
......
35 40
  ]
36 41
})
37 42

  
38
export class InviteBasicModule { }
43
export class InviteBasicModule {
44
  constructor(private iconsService: IconsService) {
45
    this.iconsService.registerIcons([send, cog])
46
  }
47
}
modules/uoa-connect-portal/trunk/src/app/app.component.ts
56 56
          <router-outlet></router-outlet>
57 57
        </main>
58 58
      </div>
59
      <div id="subscribeAndInviteBtn" *ngIf="isClient && properties && community">
60
        <subscribe [communityId]="community.id" [properties]="properties"></subscribe>
61
        <invite *ngIf="isManager" [longView]=false [buttonSizeSmall]=false [properties]="properties"></invite>
59
      <div id="subscribeAndInviteBtn" *ngIf="isClient && community">
60
        <subscribe [communityId]="community.id"></subscribe>
61
        <invite *ngIf="isManager" [longView]="false"></invite>
62 62
      </div>
63 63
      <!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
64 64
      <cookie-law *ngIf="isClient" position="bottom">
......
86 86
})
87 87
export class AppComponent {
88 88
  isClient: boolean = false;
89
  
90 89
  userMenuItems: MenuItem[] = [];
91
  
92
  
93 90
  menuItems: RootMenuItem [] = [];
94 91
  bottomMenuItems: MenuItem[] = [];
95 92
  public community = null;
96
  properties: EnvProperties;
93
  properties: EnvProperties = properties;
97 94
  showMenu: boolean = false;
98 95
  communities = null;
99 96
  user: User;
......
122 119
  }
123 120
  
124 121
  ngOnInit() {
125
    this.properties = properties;
126 122
    this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
127 123
    if (typeof document !== 'undefined') {
128 124
      try {
modules/uoa-connect-portal/trunk/src/assets/connect-custom.css
109 109
    top: calc(30% - 47px);
110 110
}
111 111

  
112
#subscribeAndInviteBtn button {
112
#subscribeAndInviteBtn #subscribe,
113
#subscribeAndInviteBtn #invite {
113 114
    width: 125px;
114 115
    height: 35px;
115 116
    border-right: none;
116
    /*border-top-right-radius: 0;*/
117
    /*border-bottom-right-radius: 0;*/
118
    border-radius: 4px 0px 0px 4px;
119
    box-shadow: 0px 2px 6px #00000038;
120
    border-width: 0px;
117
    border-radius: 4px 0 0 4px;
118
    box-shadow: 0 2px 6px #00000038;
119
    border-width: 0;
121 120
}
122 121

  
123 122
.subscribed-button {

Also available in: Unified diff