Project

General

Profile

« Previous | Next » 

Revision 56437

[Trunk|Admin]: Add Message on Curators and Organizations if page is disabled.

View differences:

modules/uoa-admin-portal/trunk/src/app/pages/curator/curator.component.html
39 39
                Upload a photo
40 40
              </button>
41 41
            </div>
42
            <div class="uk-margin-small-left">
42
            <div *ngIf="photo !== 'assets/common-assets/curator-default.png'" class="uk-margin-small-left">
43 43
              <button class="uk-button uk-button-danger" type="button" (click)="resetMessages(); removePhotoModal.open()">
44 44
                Remove
45 45
              </button>
......
72 72
      <tr>
73 73
        <td class="uk-text-right"></td>
74 74
        <td>
75
          <div *ngIf="!newCurator && !curatorsEnabled" class="uk-alert uk-alert-warning" role="alert">
76
            <span class="uk-margin-small-right uk-icon" uk-icon="warning">
77
            </span>
78
            Community's Curators page is disabled. Please enable it <a routerLink="/pages" routerLinkActive="router-link-active" [queryParams]="{communityId: communityId, type: 'other'}">here</a>.
79
          </div>
75 80
          <div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
76 81
          <div *ngIf="successfulSaveMessage" class="uk-alert uk-alert-success" role="alert">{{successfulSaveMessage}}</div>
77 82
      </tr>
modules/uoa-admin-portal/trunk/src/app/pages/curator/curator.component.ts
9 9
import {Curator} from '../../openaireLibrary/utils/entities/CuratorInfo';
10 10
import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
11 11
import {UtilitiesService} from '../../openaireLibrary/services/utilities.service';
12
import {HelpContentService} from '../../services/help-content.service';
12 13

  
13 14
@Component({
14 15
  selector: 'curator',
......
21 22
  public updateErrorMessage = '';
22 23
  public successfulSaveMessage = '';
23 24

  
25
  public curatorsEnabled;
26
  public newCurator;
27

  
28
  public communityId = null;
29

  
24 30
  public affiliationsChanged = false;
25 31
  public hasChanged = false;
26 32
  public curatorId = null;
......
31 37
  private file: File = null;
32 38
  private maxsize: number = 200*1024;
33 39
  private enabled = true;
34
  private deletePhoto =false;
40
  private deletePhoto = false;
35 41

  
36 42
  constructor(private element: ElementRef,
37 43
              private route: ActivatedRoute,
38 44
              private _router: Router,
39 45
              private curatorService: CuratorService,
40
              private utilitiesService: UtilitiesService) {
46
              private utilitiesService: UtilitiesService,
47
              private helpContentService: HelpContentService) {
41 48
  }
42 49

  
43 50

  
......
49 56
          queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
50 57
        });
51 58
      } else {
52
        this.showLoading = true;
53
        this.updateErrorMessage = '';
54
        this.curatorId = Session.getUser().id;
55
        this.curatorService.getCurator(this.properties,
56
          this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
57
          curator => {
58
            if (curator && Object.keys(curator).length > 0) {
59
              this.curator = curator;
60
              this.curator.email = Session.getUserEmail();
61
              if (this.curator.photo && this.curator.photo !== '') {
62
                this.photo = this.properties.utilsService + '/download/' + this.curator.photo;
59
        this.route.queryParams.subscribe((params) => {
60
          this.communityId = params['communityId'];
61
          this.showLoading = true;
62
          this.updateErrorMessage = '';
63
          this.curatorId = Session.getUser().id;
64
          this.curatorService.getCurator(this.properties,
65
            this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
66
            curator => {
67
              if (curator && Object.keys(curator).length > 0) {
68
                this.curator = curator;
69
                this.curator.email = Session.getUserEmail();
70
                if (this.curator.photo && this.curator.photo !== '') {
71
                  this.photo = this.properties.utilsService + '/download/' + this.curator.photo;
72
                } else {
73
                  this.photo = 'assets/common-assets/curator-default.png';
74
                }
75
                this.curatorsPageStatus();
76
                this.showLoading = false;
77
                HelperFunctions.scroll();
63 78
              } else {
79
                this.newCurator = true;
80
                this.curator = new Curator();
81
                this.curator._id = this.curatorId;
82
                this.curator.email = Session.getUserEmail();
83
                this.curator.name = Session.getUserFullName();
84
                this.curator.affiliations = [];
85
                this.curator.bio = '';
86
                this.curator.photo = null;
64 87
                this.photo = 'assets/common-assets/curator-default.png';
88
                this.showLoading = false;
89
                HelperFunctions.scroll();
65 90
              }
66
              this.showLoading = false;
67
              HelperFunctions.scroll();
68
            } else {
69
              this.curator = new Curator();
70
              this.curator._id = this.curatorId;
71
              this.curator.email = Session.getUserEmail();
72
              this.curator.name = Session.getUserFullName();
73
              this.curator.affiliations = [];
74
              this.curator.bio = '';
75
              this.curator.photo = null;
76
              this.photo = 'assets/common-assets/curator-default.png';
77
              this.showLoading = false;
78
              HelperFunctions.scroll();
91
            },
92
            error => {
79 93
            }
80
          },
81
          error => {
82
          }
83
        );
94
          );
95
        })
84 96
      }
85 97
    });
98

  
86 99
  }
87 100

  
88 101
  public resetForm() {
......
107 120
                this.photo = 'assets/common-assets/curator-default.png';
108 121
              }
109 122
              this.showLoading = false;
123
              this.curatorsPageStatus();
110 124
              HelperFunctions.scroll();
111 125
            } else {
126
              this.newCurator = true;
112 127
              this.curator = new Curator();
113 128
              this.curator._id = this.curatorId;
114 129
              this.curator.email = Session.getUserEmail();
......
129 144
    }
130 145
  }
131 146

  
147
  private curatorsPageStatus() {
148
    this.helpContentService.getCommunityFull(this.communityId, this.properties.adminToolsAPIURL).subscribe((community) => {
149
      for(let page of community.pages) {
150
        if(page['route'] === '/curators') {
151
          this.curatorsEnabled = page['isEnabled'];
152
          console.log(this.curatorsEnabled)
153
          return;
154
        }
155
      }
156
      this.curatorsEnabled = false;
157
      console.log(this.curatorsEnabled)
158
    })
159
  }
160

  
132 161
  private change() {
133 162
    this.hasChanged = true;
134 163
    this.affiliationsChanged = true;
......
202 231
                this.curator).subscribe((curator) => {
203 232
                  if (curator) {
204 233
                    this.handleSuccessfulSave('Your data has been saved successfully!');
234
                    this.newCurator = false;
205 235
                    this.resetChange();
206 236
                  }
207 237
                },
modules/uoa-admin-portal/trunk/src/app/pages/affiliations/affiliations.component.html
30 30
         routerLinkActive="router-link-active">
31 31
        here
32 32
      </a>
33
      .
34
      <div *ngIf="!organizationsEnabled" class="uk-alert uk-alert-warning" role="alert">
35
            <span class="uk-margin-small-right uk-icon" uk-icon="warning">
36
            </span>
37
        Community's Organizations page is disabled. Please enable it <a routerLink="/pages" routerLinkActive="router-link-active" [queryParams]="{communityId: communityId, type: 'other'}">here</a>.
38
      </div>
33 39
    </div>
34 40
  </div>
35 41

  
modules/uoa-admin-portal/trunk/src/app/pages/affiliations/affiliations.component.ts
38 38
  @Output() resetCuratorMessages: EventEmitter<boolean> = new EventEmitter();
39 39
  public communityId: string;
40 40
  public organizationsPageId: string;
41
  public organizationsEnabled = false;
41 42

  
42 43
  constructor(private element: ElementRef,
43 44
              private route: ActivatedRoute,
......
66 67
            if(!this.curatorAffiliations) {
67 68
              this.getAffiliations();
68 69
            }
70
            this.organizationsPageStatus();
69 71
          }
70 72
        );
71 73
      }
......
226 228
    }
227 229
  }
228 230

  
231
  private organizationsPageStatus() {
232
    this._helpContentService.getCommunityFull(this.communityId, this.properties.adminToolsAPIURL).subscribe((community) => {
233
      for(let page of community.pages) {
234
        if(page['route'] === '/organizations') {
235
          this.organizationsEnabled = page['isEnabled'];
236
          return;
237
        }
238
      }
239
      this.organizationsEnabled = false;
240
    })
241
  }
229 242

  
230 243
  private change() {
231 244
    this.hasChanged = true;

Also available in: Unified diff