[Library | Trunk]: Fix admin tools pages portal type configuration.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60561 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
8acc64fc10
commit
cd519aa1e5
|
@ -4,30 +4,35 @@ import {
|
||||||
Router,
|
Router,
|
||||||
CanActivate,
|
CanActivate,
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot, UrlTree, CanActivateChild,
|
||||||
|
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, Subscription} from 'rxjs';
|
import {Observable, Subscription} from 'rxjs';
|
||||||
import {CommunityService} from '../community/community.service';
|
import {CommunityService} from '../community/community.service';
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConnectCommunityGuard implements CanActivate {
|
export class ConnectCommunityGuard implements CanActivate, CanActivateChild {
|
||||||
sub: Subscription = null;
|
sub: Subscription = null;
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private communityService: CommunityService) {
|
private communityService: CommunityService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
check(community: string): Observable<boolean> | boolean {
|
check(community: string, url: string): Observable<boolean> | boolean {
|
||||||
return this.communityService.isCommunityType(community).pipe(take(1), tap(isCommunity => {
|
return this.communityService.isCommunityType(community).pipe(take(1), tap(isCommunity => {
|
||||||
if (!isCommunity) {
|
if (!isCommunity) {
|
||||||
this.router.navigate(['errorcommunity']);
|
this.router.navigate(['/error'], {queryParams: {'page': url}});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||||
return this.check(route.queryParams['communityId']);
|
return this.check(route.queryParams['communityId'], state.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
|
let community = childRoute.params['community'];
|
||||||
|
return community && this.check(community, state.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,39 @@
|
||||||
import {tap} from 'rxjs/operators';
|
import {tap} from 'rxjs/operators';
|
||||||
import { Injectable } from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
Router,
|
|
||||||
CanActivate,
|
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
|
CanActivate,
|
||||||
|
CanActivateChild,
|
||||||
|
Router,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot,
|
||||||
CanLoad,
|
UrlTree
|
||||||
Route, UrlSegment, CanActivateChild, UrlTree
|
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, Subscription} from 'rxjs';
|
import {Observable, Subscription} from 'rxjs';
|
||||||
import {CommunityService} from '../community/community.service';
|
import {CommunityService} from '../community/community.service';
|
||||||
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
|
|
||||||
import {ConnectHelper} from '../connectHelper';
|
|
||||||
import {properties} from "../../../../environments/environment";
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConnectRIGuard implements CanActivate, CanLoad, CanActivateChild {
|
export class ConnectRIGuard implements CanActivate, CanActivateChild {
|
||||||
sub: Subscription = null;
|
sub: Subscription = null;
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private communityService: CommunityService,
|
private communityService: CommunityService) {
|
||||||
private propertiesService: EnvironmentSpecificService) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check(community: string): Observable<boolean> | boolean {
|
check(community: string, url: string): Observable<boolean> | boolean {
|
||||||
return this.communityService.isRIType(community).pipe(tap(authorized => {
|
return this.communityService.isRIType(community).pipe(tap(authorized => {
|
||||||
if (!authorized) {
|
if (!authorized) {
|
||||||
this.router.navigate(['errorcommunity']);
|
this.router.navigate(['/error'], {queryParams: {'page': url}});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||||
let community = route.params['community'];
|
let community = route.params['community'];
|
||||||
return community && this.check(community);
|
return community && this.check(community, state.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
let community = childRoute.params['community'];
|
let community = childRoute.params['community'];
|
||||||
return community && this.check(community);
|
return community && this.check(community, state.url);
|
||||||
}
|
|
||||||
|
|
||||||
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
|
|
||||||
const path = '/' + route.path + document.location.search;
|
|
||||||
return this.check(ConnectHelper.getCommunityFromPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
canDeactivate() {
|
|
||||||
if(this.sub) {
|
|
||||||
this.sub.unsubscribe();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!--<div *ngIf="checkboxes.length > 0" class=" uk-margin-remove-top uk-margin-small-left"
|
<!--<div *ngIf="checkboxes.length > 0" class=" uk-margin-remove-top uk-margin-small-left"
|
||||||
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
||||||
title="Select at least one help text">
|
title="Select at least one entity">
|
||||||
<input id="checkAll" type="checkbox" (click)="selectAll()"
|
<input id="checkAll" type="checkbox" (click)="selectAll()"
|
||||||
[ngModel]="getSelectedEntities().length ==checkboxes.length"/>
|
[ngModel]="getSelectedEntities().length ==checkboxes.length"/>
|
||||||
<a *ngIf="!isPortalAdministrator" class="uk-margin-left" [class.uk-disabled]="getSelectedEntities().length
|
<a *ngIf="!isPortalAdministrator" class="uk-margin-left" [class.uk-disabled]="getSelectedEntities().length
|
||||||
|
@ -63,10 +63,10 @@
|
||||||
|
|
||||||
</div>-->
|
</div>-->
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="checkboxes.length > 0"
|
<div *ngIf="!showLoading && checkboxes.length > 0"
|
||||||
class="uk-margin-remove-top uk-margin-small-left uk-margin-small-bottom"
|
class="uk-margin-remove-top uk-margin-small-left uk-margin-small-bottom uk-display-inline"
|
||||||
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : null"
|
||||||
title="Select at least one help text"><input id="checkAll" type="checkbox" (click)="selectAll()"
|
title="Select at least one entity"><input id="checkAll" type="checkbox" (click)="selectAll()"
|
||||||
[ngModel]="getSelectedEntities().length ==checkboxes.length"/>
|
[ngModel]="getSelectedEntities().length ==checkboxes.length"/>
|
||||||
<span *ngIf="getSelectedEntities().length > 0" class="uk-margin-left uk-text-muted">
|
<span *ngIf="getSelectedEntities().length > 0" class="uk-margin-left uk-text-muted">
|
||||||
{{getSelectedEntities().length}} entities selected </span>
|
{{getSelectedEntities().length}} entities selected </span>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
<div uk-dropdown="mode: click">
|
<div uk-dropdown="mode: click">
|
||||||
<ul class="uk-nav uk-dropdown-nav"
|
<ul class="uk-nav uk-dropdown-nav"
|
||||||
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
[attr.uk-tooltip]="getSelectedEntities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
||||||
title="Select at least one help text">
|
title="Select at least one entity">
|
||||||
<li *ngIf="!isPortalAdministrator"><a [class]="getSelectedEntities().length == 0 ? 'uk-disabled' : ''"
|
<li *ngIf="!isPortalAdministrator"><a [class]="getSelectedEntities().length == 0 ? 'uk-disabled' : ''"
|
||||||
(click)="toggleEntities(true,getSelectedEntities())"><i></i> Enable
|
(click)="toggleEntities(true,getSelectedEntities())"><i></i> Enable
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|
|
@ -74,9 +74,7 @@ export class EntitiesComponent implements OnInit {
|
||||||
}));
|
}));
|
||||||
this.userManagementService.getUserInfo().subscribe(user => {
|
this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
||||||
if(this.portal === 'connect' || this.portal === 'openaire' || this.portal === 'monitor') {
|
ConnectHelper.setPortalTypeFromPid(this.portal);
|
||||||
ConnectHelper.setPortalTypeFromPid(this.portal);
|
|
||||||
}
|
|
||||||
this.applyPortalFilter(this.portal);
|
this.applyPortalFilter(this.portal);
|
||||||
this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal;
|
this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,88 +1,89 @@
|
||||||
<div page-content>
|
<div page-content>
|
||||||
<div header>
|
<div header>
|
||||||
<!-- <div class="uk-text-bold">
|
|
||||||
<span *ngIf="pageId && page">{{page.name}}</span>
|
|
||||||
</div>-->
|
|
||||||
<div class="uk-margin-top">
|
<div class="uk-margin-top">
|
||||||
<a
|
<a routerLink="../" [queryParams]=" { 'pageId': pageId }"
|
||||||
routerLink="../" [queryParams]=" { 'pageId': pageId }" class="uk-text-secondary">
|
class="uk-text-secondary uk-text-uppercase uk-text-bold uk-text-small">
|
||||||
<span class="uk-icon-button small uk-icon uk-button-secondary">
|
<span class="uk-icon-button uk-icon small uk-button-secondary">
|
||||||
<icon name="arrow_left"></icon></span>
|
<icon name="arrow_left"></icon>
|
||||||
Go back to helptexts list</a>
|
</span>
|
||||||
|
<span class="space">
|
||||||
|
Go back to helptexts list
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div inner>
|
<div inner>
|
||||||
<div class="uk-card-header">
|
<div class="uk-card-header">
|
||||||
<div class="uk-flex uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-grid" uk-grid>
|
<div class="uk-flex uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-grid" uk-grid>
|
||||||
|
<div>
|
||||||
|
<div class="uk-text-small uk-text-muted"> {{pageHelpContent ? 'Update ' : 'Add new '}} help text</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="uk-text-small uk-text-muted"> {{pageHelpContent?'Update ':'Add new '}} help text</div>
|
<span *ngIf="page" class="uk-text-bold">{{page.name}}</span>
|
||||||
<div >
|
<span *ngIf="myForm.dirty"> (unsaved changes)</span>
|
||||||
<span *ngIf="page" class="uk-text-bold">{{page.name}}</span>
|
</div>
|
||||||
<span *ngIf="myForm.dirty"> (unsaved changes)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class=" uk-flex uk-flex-right">
|
|
||||||
<button (click)="resetCustom()" [disabled]="showLoading || !myForm.dirty"
|
|
||||||
class="uk-button uk-button-secondary outlined uk-margin-small-right">Reset
|
|
||||||
</button>
|
|
||||||
<button (click)="saveCustom()" class="uk-button uk-button-secondary uk-margin-small-right"
|
|
||||||
[disabled]="showLoading || !myForm.dirty || !myForm.valid ">Save
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="uk-card uk-card-default uk-position-relative " style="min-height: 60vh">
|
|
||||||
<div style="max-height: 60vh" class="uk-padding-large uk-overflow-auto">
|
|
||||||
|
|
||||||
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
|
||||||
<div class="uk-animation-fade uk-width-1-1" role="alert">
|
|
||||||
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
|
|
||||||
|
|
||||||
<div *ngIf="showLoading" class="uk-position-center">
|
|
||||||
<loading *ngIf="showLoading"></loading>
|
|
||||||
</div>
|
|
||||||
<form [formGroup]="myForm" [class.hidden]="showLoading">
|
|
||||||
<div class="uk-grid uk-child-width-1-2 ">
|
|
||||||
<div *ngIf="placementsOptions.length > 0" dashboard-input
|
|
||||||
[formInput]="myForm.get('placement')"
|
|
||||||
type="select" placeholder="Select placement"
|
|
||||||
label="Select placement" [options]="placementsOptions"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div dashboard-input [formInput]="myForm.get('order')"
|
|
||||||
type="select" placeholder="Select order"
|
|
||||||
label="Select order" [options]="orderOptions">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group uk-margin-top">
|
|
||||||
<span class="uk-text-bold uk-margin-small-right">Select Status (Enable/ disable)</span>
|
|
||||||
|
|
||||||
<mat-slide-toggle [checked]="myForm.get('isActive').value"
|
|
||||||
(change)="changeStatus()"
|
|
||||||
uk-tooltip="title:<div class='uk-padding-small uk-width-large'><div class='uk-text-bold '> Enable or disable help text to show or hide it from the dashboard</div></div>"
|
|
||||||
></mat-slide-toggle>
|
|
||||||
</div>
|
|
||||||
<div class="form-group uk-margin-large-top"
|
|
||||||
[ngClass]="{'has-error':!myForm.controls.content.valid &&
|
|
||||||
myForm.controls.content.dirty}"
|
|
||||||
>
|
|
||||||
<label class="uk-text-bold">Content</label>
|
|
||||||
<div class="uk-margin-top">
|
|
||||||
<ckeditor (change)="contentChanged()"
|
|
||||||
[readonly]="false"
|
|
||||||
debounce="500"
|
|
||||||
[formControl]="myForm.get('content')"
|
|
||||||
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
|
|
||||||
extraPlugins: 'divarea'}">
|
|
||||||
</ckeditor>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<input type="hidden" formControlName="_id">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class=" uk-flex uk-flex-right">
|
||||||
|
<button (click)="resetCustom()" [disabled]="showLoading || !myForm.dirty"
|
||||||
|
class="uk-button uk-button-secondary outlined uk-margin-small-right">Reset
|
||||||
|
</button>
|
||||||
|
<button (click)="saveCustom()" class="uk-button uk-button-secondary uk-margin-small-right"
|
||||||
|
[disabled]="showLoading || !myForm.dirty || !myForm.valid ">Save
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="uk-card uk-card-default uk-position-relative " style="min-height: 60vh">
|
||||||
|
<div style="max-height: 60vh" class="uk-padding-large uk-overflow-auto">
|
||||||
|
|
||||||
|
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
||||||
|
<div class="uk-animation-fade uk-width-1-1" role="alert">
|
||||||
|
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
|
||||||
|
|
||||||
|
<div *ngIf="showLoading" class="uk-position-center">
|
||||||
|
<loading *ngIf="showLoading"></loading>
|
||||||
|
</div>
|
||||||
|
<form [formGroup]="myForm" [class.hidden]="showLoading">
|
||||||
|
<div class="uk-grid uk-child-width-1-2 ">
|
||||||
|
<div *ngIf="placementsOptions.length > 0" dashboard-input
|
||||||
|
[formInput]="myForm.get('placement')"
|
||||||
|
type="select" placeholder="Select placement"
|
||||||
|
label="Select placement" [options]="placementsOptions"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div dashboard-input [formInput]="myForm.get('order')"
|
||||||
|
type="select" placeholder="Select order"
|
||||||
|
label="Select order" [options]="orderOptions">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group uk-margin-top">
|
||||||
|
<span class="uk-text-bold uk-margin-small-right">Select Status (Enable/ disable)</span>
|
||||||
|
|
||||||
|
<mat-slide-toggle [checked]="myForm.get('isActive').value"
|
||||||
|
(change)="changeStatus()"
|
||||||
|
uk-tooltip="title:<div class='uk-padding-small uk-width-large'><div class='uk-text-bold '> Enable or disable help text to show or hide it from the dashboard</div></div>"
|
||||||
|
></mat-slide-toggle>
|
||||||
|
</div>
|
||||||
|
<div class="form-group uk-margin-large-top"
|
||||||
|
[ngClass]="{'has-error':!myForm.controls.content.valid &&
|
||||||
|
myForm.controls.content.dirty}"
|
||||||
|
>
|
||||||
|
<label class="uk-text-bold">Content</label>
|
||||||
|
<div class="uk-margin-top">
|
||||||
|
<ckeditor (change)="contentChanged()"
|
||||||
|
[readonly]="false"
|
||||||
|
debounce="500"
|
||||||
|
[formControl]="myForm.get('content')"
|
||||||
|
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
|
||||||
|
extraPlugins: 'divarea'}">
|
||||||
|
</ckeditor>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<input type="hidden" formControlName="_id">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,293 +11,308 @@ import {properties} from '../../../../environments/environment';
|
||||||
import {from, Observable, Subscriber, Subscription} from 'rxjs';
|
import {from, Observable, Subscriber, Subscription} from 'rxjs';
|
||||||
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
||||||
import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content';
|
import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content';
|
||||||
|
import {ConnectHelper} from "../../connect/connectHelper";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-content-form',
|
selector: 'page-content-form',
|
||||||
templateUrl: './page-help-content-form.component.html',
|
templateUrl: './page-help-content-form.component.html',
|
||||||
})
|
})
|
||||||
|
export class PageContentFormComponent implements OnInit {
|
||||||
export class PageContentFormComponent implements OnInit{
|
|
||||||
|
myForm: FormGroup;
|
||||||
myForm: FormGroup;
|
portal: string;
|
||||||
communityPid: string;
|
pageId: string;
|
||||||
pageId: string;
|
pageContentId: string;
|
||||||
pageContentId: string;
|
page: Page;
|
||||||
page: Page;
|
placementsOptions = [];
|
||||||
placementsOptions = [];
|
orderOptions = [];
|
||||||
orderOptions = [];
|
|
||||||
|
private availablePages: Page[] = [];
|
||||||
private availablePages : Page[] = [];
|
//private errorMessage: string;
|
||||||
//private errorMessage: string;
|
|
||||||
|
private ckeditorContent: string;
|
||||||
private ckeditorContent : string;
|
public properties: EnvProperties = null;
|
||||||
public properties:EnvProperties = null;
|
|
||||||
|
public showLoading: boolean = true;
|
||||||
public showLoading: boolean = true;
|
public errorMessage: string = '';
|
||||||
public errorMessage: string = '';
|
@Input() updateErrorMessage: string = '';
|
||||||
@Input() updateErrorMessage: string = '';
|
private subs: Subscription[] = [];
|
||||||
private subs: Subscription[] = [];
|
private pageHelpContent: PageHelpContent;
|
||||||
private pageHelpContent: PageHelpContent;
|
|
||||||
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService) {
|
||||||
|
}
|
||||||
ngOnInit() {
|
|
||||||
|
ngOnInit() {
|
||||||
this.properties = properties;
|
|
||||||
this.subs.push(this.route.params.subscribe(params => {
|
this.properties = properties;
|
||||||
this.communityPid = params['community'];
|
this.subs.push(this.route.params.subscribe(params => {
|
||||||
this.subs.push(this.route.queryParams.subscribe(params => {
|
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
||||||
HelperFunctions.scroll();
|
ConnectHelper.setPortalTypeFromPid(this.portal);
|
||||||
this.pageId = params['pageId'];
|
this.subs.push(this.route.queryParams.subscribe(params => {
|
||||||
this.myForm = this.form;
|
HelperFunctions.scroll();
|
||||||
this.pageContentId = params['pageContentId'];
|
this.pageId = params['pageId'];
|
||||||
if (!this.pageId) {
|
|
||||||
this._router.navigate(['../'], {relativeTo: this.route});
|
|
||||||
}
|
|
||||||
/* this.getPage(this.pageId);
|
|
||||||
if (this.pageContentId) {
|
|
||||||
this.getPageHelpContent(this.pageContentId);
|
|
||||||
}else{
|
|
||||||
this.myForm = this.form;
|
|
||||||
|
|
||||||
}*/
|
|
||||||
this.getInfo(this.pageId);
|
|
||||||
|
|
||||||
if (!Session.isLoggedIn()) {
|
|
||||||
this._router.navigate(['/user-info'], {
|
|
||||||
queryParams: {
|
|
||||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
|
||||||
"redirectUrl": this._router.url
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.subs.forEach(value => {
|
|
||||||
if (value instanceof Subscriber) {
|
|
||||||
value.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getInfo(pageId: string){
|
|
||||||
this.showLoading = true;
|
|
||||||
let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid), this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL, pageId));
|
|
||||||
this.subs.push(obs.subscribe(
|
|
||||||
results => {
|
|
||||||
this.page = results[0];
|
|
||||||
if(this.properties.adminToolsPortalType != this.page.portalType) {
|
|
||||||
this._router.navigate(['../'], {relativeTo: this.route});
|
|
||||||
}
|
|
||||||
let countPageContents = results[1]?results[1].length:0;
|
|
||||||
console.log(results[1]);
|
|
||||||
for (let content of (results[1] as Array<PageHelpContent>)) {
|
|
||||||
// if(content.page['_id'] == pageId){
|
|
||||||
// countPageContents++;
|
|
||||||
if(this.pageContentId && this.pageContentId == content._id) {
|
|
||||||
this.pageHelpContent = content;
|
|
||||||
// this.pageHelpContent.page = pageId;
|
|
||||||
// this.pageHelpContent.portal = this.communityPid;
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
this.setOptions(this.page, countPageContents + (this.pageHelpContent?0:1));
|
|
||||||
if(!this.pageContentId) {
|
|
||||||
this.myForm = this.form;
|
|
||||||
this.initFormWithSelectOptions();
|
|
||||||
}else{
|
|
||||||
this.updateForm(this.pageHelpContent);
|
|
||||||
}
|
|
||||||
this.showLoading = false;
|
|
||||||
},
|
|
||||||
error => this.handleError('System error retrieving page with id: '+pageId, error)
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
|
||||||
/*private getPage(pageId: string) {
|
|
||||||
this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
|
||||||
page => {
|
|
||||||
if(this.properties.adminToolsPortalType != page.portalType) {
|
|
||||||
this._router.navigate(['../'], {relativeTo: this.route});
|
|
||||||
} else {
|
|
||||||
this.page = page;
|
|
||||||
this.getPageContents(pageId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => this.handleError('System error retrieving page with id: '+pageId, error)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
private getPageContents(pageId: string) {
|
|
||||||
this.subs.push(this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
|
|
||||||
pageHelpContents => {
|
|
||||||
let countPageContents = 1;
|
|
||||||
for (let content of (pageHelpContents as Array<PageHelpContent>)) {
|
|
||||||
if(content.page['_id'] == pageId){
|
|
||||||
countPageContents++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.setOptions(this.page, countPageContents);
|
|
||||||
if(!this.pageContentId) {
|
|
||||||
this.showLoading = false;
|
|
||||||
this.initFormWithSelectOptions();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => this.handleError('System error retrieving page contents with id: ', error)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
private getPageHelpContent(pageContentId: string) {
|
|
||||||
if(!Session.isLoggedIn()){
|
|
||||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
||||||
} else {
|
|
||||||
this.showLoading = true;
|
|
||||||
this.errorMessage = "";
|
|
||||||
this.updateErrorMessage = "";
|
|
||||||
|
|
||||||
this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
|
||||||
pageHelpContent => {
|
|
||||||
this.updateForm(pageHelpContent);
|
|
||||||
this.showLoading = false;
|
|
||||||
},
|
|
||||||
error => this.handleError('System error retrieving page help content', error)));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
private updateForm(pageHelpContent : PageHelpContent) {
|
|
||||||
this.pageHelpContent = pageHelpContent;
|
|
||||||
this.myForm = this.form;
|
this.myForm = this.form;
|
||||||
if(this.pageHelpContent) {
|
this.pageContentId = params['pageContentId'];
|
||||||
this.myForm.patchValue((pageHelpContent));
|
if (!this.pageId) {
|
||||||
}else{
|
this._router.navigate(['../'], {relativeTo: this.route});
|
||||||
this.initFormWithSelectOptions();
|
|
||||||
}
|
}
|
||||||
if(this.orderOptions.length ==1){
|
/* this.getPage(this.pageId);
|
||||||
this.myForm.get('order').disable()
|
if (this.pageContentId) {
|
||||||
}
|
this.getPageHelpContent(this.pageContentId);
|
||||||
if(this.placementsOptions.length ==1){
|
}else{
|
||||||
this.myForm.get('placement').disable()
|
this.myForm = this.form;
|
||||||
}
|
|
||||||
this.myForm.markAsPristine();
|
|
||||||
|
|
||||||
}
|
}*/
|
||||||
initFormWithSelectOptions(){
|
this.getInfo(this.pageId);
|
||||||
if (this.placementsOptions.length == 1) {
|
|
||||||
this.myForm.get("placement").setValue(this.placementsOptions[0].value);
|
if (!Session.isLoggedIn()) {
|
||||||
}
|
this._router.navigate(['/user-info'], {
|
||||||
this.myForm.get("order").setValue(this.orderOptions[this.orderOptions.length - 1].value);
|
queryParams: {
|
||||||
if(this.orderOptions.length ==1){
|
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||||
this.myForm.get('order').disable()
|
"redirectUrl": this._router.url
|
||||||
}
|
|
||||||
if(this.placementsOptions.length ==1){
|
|
||||||
this.myForm.get('placement').disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public setOptions(page: Page, countContents:number) {
|
|
||||||
this.placementsOptions = [];
|
|
||||||
if(page.top){
|
|
||||||
this.placementsOptions.push({label: "top", value: "top"});
|
|
||||||
}
|
|
||||||
if(page.bottom){
|
|
||||||
this.placementsOptions.push({label: "bottom", value: "bottom"});
|
|
||||||
}
|
|
||||||
if(page.left){
|
|
||||||
this.placementsOptions.push({label: "left", value: "left"});
|
|
||||||
}
|
|
||||||
this.orderOptions = [];
|
|
||||||
for(let i=1; i<countContents+1; i++){
|
|
||||||
this.orderOptions.push({label: ""+i, value: i});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public get form() {
|
|
||||||
return this._fb.group({
|
|
||||||
page : [this.pageId, Validators.required],
|
|
||||||
portal : this.communityPid,
|
|
||||||
placement : ['', Validators.required],
|
|
||||||
content : ['', Validators.required],
|
|
||||||
order : [1, Validators.required],
|
|
||||||
isActive : true,
|
|
||||||
//isPriorTo : false,
|
|
||||||
_id : '',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public reset() {
|
|
||||||
this.myForm.patchValue({
|
|
||||||
page : '',
|
|
||||||
portal : this.communityPid,
|
|
||||||
placement : '',
|
|
||||||
content : [''],
|
|
||||||
order : 1,
|
|
||||||
isActive : true,
|
|
||||||
//isPriorTo : false,
|
|
||||||
_id : ''
|
|
||||||
});
|
|
||||||
this.myForm.markAsPristine();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleError(message: string, error) {
|
|
||||||
this.errorMessage = message;
|
|
||||||
console.error('Server responded: ' + error);
|
|
||||||
|
|
||||||
this.showLoading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public saveCustom() {
|
|
||||||
if(!Session.isLoggedIn()){
|
|
||||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
||||||
} else {
|
|
||||||
//this.errorMessage = null;
|
|
||||||
|
|
||||||
if(this.myForm.valid) {
|
|
||||||
this.showLoading = true;
|
|
||||||
this.updateErrorMessage = "";
|
|
||||||
this.myForm.get('order').enable();
|
|
||||||
this.myForm.get('placement').enable();
|
|
||||||
let pageHelpContent : PageHelpContent = this.myForm.value;
|
|
||||||
this.subs.push(this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
|
||||||
_ => {
|
|
||||||
this._router.navigate( ['../'], { queryParams: { "pageId": this.pageId }, relativeTo: this.route } );
|
|
||||||
this.showLoading = false;
|
|
||||||
},
|
|
||||||
err => this.handleUpdateError('System error saving page content', err)
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
this.showLoading = false;
|
|
||||||
this.errorMessage = "Please fill all required fields";
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subs.forEach(value => {
|
||||||
|
if (value instanceof Subscriber) {
|
||||||
|
value.unsubscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getInfo(pageId: string) {
|
||||||
|
this.showLoading = true;
|
||||||
|
let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal), this._helpContentService.getCommunityPageHelpContents(this.portal, this.properties.adminToolsAPIURL, pageId));
|
||||||
|
this.subs.push(obs.subscribe(
|
||||||
|
results => {
|
||||||
|
this.page = results[0];
|
||||||
|
if (this.properties.adminToolsPortalType != this.page.portalType) {
|
||||||
|
this._router.navigate(['../'], {relativeTo: this.route});
|
||||||
|
}
|
||||||
|
let countPageContents = results[1] ? results[1].length : 0;
|
||||||
|
console.log(results[1]);
|
||||||
|
for (let content of (results[1] as Array<PageHelpContent>)) {
|
||||||
|
// if(content.page['_id'] == pageId){
|
||||||
|
// countPageContents++;
|
||||||
|
if (this.pageContentId && this.pageContentId == content._id) {
|
||||||
|
this.pageHelpContent = content;
|
||||||
|
// this.pageHelpContent.page = pageId;
|
||||||
|
// this.pageHelpContent.portal = this.communityPid;
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
this.setOptions(this.page, countPageContents + (this.pageHelpContent ? 0 : 1));
|
||||||
|
if (!this.pageContentId) {
|
||||||
|
this.myForm = this.form;
|
||||||
|
this.initFormWithSelectOptions();
|
||||||
|
} else {
|
||||||
|
this.updateForm(this.pageHelpContent);
|
||||||
|
}
|
||||||
|
this.showLoading = false;
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page with id: ' + pageId, error)
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*private getPage(pageId: string) {
|
||||||
|
this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
||||||
|
page => {
|
||||||
|
if(this.properties.adminToolsPortalType != page.portalType) {
|
||||||
|
this._router.navigate(['../'], {relativeTo: this.route});
|
||||||
|
} else {
|
||||||
|
this.page = page;
|
||||||
|
this.getPageContents(pageId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page with id: '+pageId, error)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
private getPageContents(pageId: string) {
|
||||||
|
this.subs.push(this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
|
||||||
|
pageHelpContents => {
|
||||||
|
let countPageContents = 1;
|
||||||
|
for (let content of (pageHelpContents as Array<PageHelpContent>)) {
|
||||||
|
if(content.page['_id'] == pageId){
|
||||||
|
countPageContents++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setOptions(this.page, countPageContents);
|
||||||
|
if(!this.pageContentId) {
|
||||||
|
this.showLoading = false;
|
||||||
|
this.initFormWithSelectOptions();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page contents with id: ', error)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
private getPageHelpContent(pageContentId: string) {
|
||||||
|
if(!Session.isLoggedIn()){
|
||||||
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||||
|
} else {
|
||||||
|
this.showLoading = true;
|
||||||
|
this.errorMessage = "";
|
||||||
|
this.updateErrorMessage = "";
|
||||||
|
|
||||||
public cancelCustom() {
|
this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
||||||
this._router.navigate( ['../'], { queryParams: { "pageId": this.pageId }, relativeTo: this.route } );
|
pageHelpContent => {
|
||||||
|
this.updateForm(pageHelpContent);
|
||||||
|
this.showLoading = false;
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page help content', error)));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
private updateForm(pageHelpContent: PageHelpContent) {
|
||||||
|
this.pageHelpContent = pageHelpContent;
|
||||||
|
this.myForm = this.form;
|
||||||
|
if (this.pageHelpContent) {
|
||||||
|
this.myForm.patchValue((pageHelpContent));
|
||||||
|
} else {
|
||||||
|
this.initFormWithSelectOptions();
|
||||||
}
|
}
|
||||||
|
if (this.orderOptions.length == 1) {
|
||||||
public resetCustom() {
|
this.myForm.get('order').disable()
|
||||||
|
}
|
||||||
|
if (this.placementsOptions.length == 1) {
|
||||||
|
this.myForm.get('placement').disable()
|
||||||
|
}
|
||||||
|
this.myForm.markAsPristine();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormWithSelectOptions() {
|
||||||
|
if (this.placementsOptions.length == 1) {
|
||||||
|
this.myForm.get("placement").setValue(this.placementsOptions[0].value);
|
||||||
|
}
|
||||||
|
this.myForm.get("order").setValue(this.orderOptions[this.orderOptions.length - 1].value);
|
||||||
|
if (this.orderOptions.length == 1) {
|
||||||
|
this.myForm.get('order').disable()
|
||||||
|
}
|
||||||
|
if (this.placementsOptions.length == 1) {
|
||||||
|
this.myForm.get('placement').disable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setOptions(page: Page, countContents: number) {
|
||||||
|
this.placementsOptions = [];
|
||||||
|
if (page.top) {
|
||||||
|
this.placementsOptions.push({label: "top", value: "top"});
|
||||||
|
}
|
||||||
|
if (page.bottom) {
|
||||||
|
this.placementsOptions.push({label: "bottom", value: "bottom"});
|
||||||
|
}
|
||||||
|
if (page.left) {
|
||||||
|
this.placementsOptions.push({label: "left", value: "left"});
|
||||||
|
}
|
||||||
|
this.orderOptions = [];
|
||||||
|
for (let i = 1; i < countContents + 1; i++) {
|
||||||
|
this.orderOptions.push({label: "" + i, value: i});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public get form() {
|
||||||
|
return this._fb.group({
|
||||||
|
page: [this.pageId, Validators.required],
|
||||||
|
portal: this.portal,
|
||||||
|
placement: ['', Validators.required],
|
||||||
|
content: ['', Validators.required],
|
||||||
|
order: [1, Validators.required],
|
||||||
|
isActive: true,
|
||||||
|
//isPriorTo : false,
|
||||||
|
_id: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public reset() {
|
||||||
|
this.myForm.patchValue({
|
||||||
|
page: '',
|
||||||
|
portal: this.portal,
|
||||||
|
placement: '',
|
||||||
|
content: [''],
|
||||||
|
order: 1,
|
||||||
|
isActive: true,
|
||||||
|
//isPriorTo : false,
|
||||||
|
_id: ''
|
||||||
|
});
|
||||||
|
this.myForm.markAsPristine();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleError(message: string, error) {
|
||||||
|
this.errorMessage = message;
|
||||||
|
console.error('Server responded: ' + error);
|
||||||
|
|
||||||
|
this.showLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveCustom() {
|
||||||
|
if (!Session.isLoggedIn()) {
|
||||||
|
this._router.navigate(['/user-info'], {
|
||||||
|
queryParams: {
|
||||||
|
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||||
|
"redirectUrl": this._router.url
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//this.errorMessage = null;
|
||||||
|
|
||||||
|
if (this.myForm.valid) {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.updateForm(this.pageHelpContent);
|
this.updateErrorMessage = "";
|
||||||
|
this.myForm.get('order').enable();
|
||||||
|
this.myForm.get('placement').enable();
|
||||||
|
let pageHelpContent: PageHelpContent = this.myForm.value;
|
||||||
|
this.subs.push(this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.portal).subscribe(
|
||||||
|
_ => {
|
||||||
|
this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route});
|
||||||
|
this.showLoading = false;
|
||||||
|
},
|
||||||
|
err => this.handleUpdateError('System error saving page content', err)
|
||||||
|
));
|
||||||
|
} else {
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
|
this.errorMessage = "Please fill all required fields";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleUpdateError(message: string, error) {
|
|
||||||
|
public cancelCustom() {
|
||||||
this.updateErrorMessage = message;
|
this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route});
|
||||||
console.error('Server responded: ' + error);
|
}
|
||||||
|
|
||||||
this.showLoading = false;
|
public resetCustom() {
|
||||||
|
this.showLoading = true;
|
||||||
|
this.updateForm(this.pageHelpContent);
|
||||||
|
this.showLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUpdateError(message: string, error) {
|
||||||
|
|
||||||
|
this.updateErrorMessage = message;
|
||||||
|
console.error('Server responded: ' + error);
|
||||||
|
|
||||||
|
this.showLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeStatus() {
|
||||||
|
this.myForm.get('isActive').setValue(!this.myForm.get('isActive').value);
|
||||||
|
if (this.pageHelpContent && this.myForm.get('isActive').value != this.pageHelpContent.isActive || !this.pageHelpContent && !this.myForm.get('isActive').value) {
|
||||||
|
this.myForm.get('isActive').markAsDirty();
|
||||||
|
} else {
|
||||||
|
this.myForm.get('isActive').markAsPristine()
|
||||||
}
|
}
|
||||||
changeStatus(){
|
}
|
||||||
this.myForm.get('isActive').setValue(!this.myForm.get('isActive').value);
|
|
||||||
if(this.pageHelpContent && this.myForm.get('isActive').value != this.pageHelpContent.isActive || !this.pageHelpContent && !this.myForm.get('isActive').value ){
|
contentChanged() {
|
||||||
this.myForm.get('isActive').markAsDirty();
|
if (this.pageHelpContent && this.myForm.get('content').value != this.pageHelpContent.content || !this.pageHelpContent && this.myForm.get('content').value != '') {
|
||||||
}else{
|
this.myForm.get('content').markAsDirty();
|
||||||
this.myForm.get('isActive').markAsPristine()
|
} else {
|
||||||
}
|
this.myForm.get('content').markAsPristine()
|
||||||
}
|
|
||||||
contentChanged(){
|
|
||||||
if(this.pageHelpContent && this.myForm.get('content').value != this.pageHelpContent.content || !this.pageHelpContent && this.myForm.get('content').value != '' ){
|
|
||||||
this.myForm.get('content').markAsDirty();
|
|
||||||
}else{
|
|
||||||
this.myForm.get('content').markAsPristine()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,14 @@
|
||||||
<span *ngIf="selectedPageId && page">{{page.name}}</span>
|
<span *ngIf="selectedPageId && page">{{page.name}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-margin-top">
|
<div class="uk-margin-top">
|
||||||
<a
|
<a routerLink="../pages/" class="uk-text-secondary uk-text-uppercase uk-text-bold uk-text-small">
|
||||||
routerLink="../pages/" class="uk-text-secondary">
|
|
||||||
<span class="uk-icon-button small uk-icon uk-button-secondary">
|
<span class="uk-icon-button small uk-icon uk-button-secondary">
|
||||||
<icon name="arrow_left"></icon></span>
|
<icon name="arrow_left"></icon>
|
||||||
Go back to pages list</a>
|
</span>
|
||||||
|
<span class="space">
|
||||||
|
Go back to pages list
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
|
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
|
||||||
<div #searchInputComponent search-input [control]="filterForm" [showSearch]="false" placeholder="Search helptext"
|
<div #searchInputComponent search-input [control]="filterForm" [showSearch]="false" placeholder="Search helptext"
|
||||||
|
|
|
@ -24,7 +24,6 @@ import {ConnectHelper} from '../../connect/connectHelper';
|
||||||
selector: 'page-help-contents',
|
selector: 'page-help-contents',
|
||||||
templateUrl: './page-help-contents.component.html',
|
templateUrl: './page-help-contents.component.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class PageHelpContentsComponent implements OnInit {
|
export class PageHelpContentsComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents;
|
@ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents;
|
||||||
|
@ -47,7 +46,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
|
|
||||||
public communities: Portal[] = [];
|
public communities: Portal[] = [];
|
||||||
|
|
||||||
public selectedCommunityPid: string;
|
public portal: string;
|
||||||
|
|
||||||
public selectedPageId: string;
|
public selectedPageId: string;
|
||||||
|
|
||||||
|
@ -78,17 +77,12 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
|
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.subscriptions.push(this.route.params.subscribe(params => {
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
||||||
this.selectedCommunityPid = params['community'];
|
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
||||||
if(!this.selectedCommunityPid) {
|
ConnectHelper.setPortalTypeFromPid(this.portal);
|
||||||
this.selectedCommunityPid = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
|
||||||
if (this.selectedCommunityPid === 'connect' || this.selectedCommunityPid === 'openaire' || this.selectedCommunityPid === 'monitor') {
|
|
||||||
ConnectHelper.setPortalTypeFromPid(this.selectedCommunityPid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
this.selectedPageId = params['pageId'];
|
this.selectedPageId = params['pageId'];
|
||||||
if (this.selectedCommunityPid && this.selectedPageId) {
|
if (this.portal && this.selectedPageId) {
|
||||||
this.getPage(this.selectedPageId);
|
this.getPage(this.selectedPageId);
|
||||||
}
|
}
|
||||||
if(!this.selectedPageId) {
|
if(!this.selectedPageId) {
|
||||||
|
@ -124,13 +118,13 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.updateErrorMessage = "";
|
this.updateErrorMessage = "";
|
||||||
this.errorMessage = "";
|
this.errorMessage = "";
|
||||||
this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
|
this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal).subscribe(
|
||||||
page => {
|
page => {
|
||||||
if (this.properties.adminToolsPortalType != page.portalType) {
|
if (this.properties.adminToolsPortalType != page.portalType) {
|
||||||
this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.selectedCommunityPid}});
|
this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.portal}});
|
||||||
} else {
|
} else {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.getPageHelpContents(this.selectedCommunityPid);
|
this.getPageHelpContents(this.portal);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving page', error)));
|
error => this.handleError('System error retrieving page', error)));
|
||||||
|
@ -154,7 +148,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
this.subscriptions.push(this._helpService.getCommunityPagesWithPositions(community_pid,this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._helpService.getCommunityPagesWithPositions(community_pid,this.properties.adminToolsAPIURL).subscribe(
|
||||||
pages => {
|
pages => {
|
||||||
this.pages = pages;
|
this.pages = pages;
|
||||||
this.getPageHelpContents(this.selectedCommunityPid);
|
this.getPageHelpContents(this.portal);
|
||||||
this.selectOptions = [{label:'All pages', value: ''}];
|
this.selectOptions = [{label:'All pages', value: ''}];
|
||||||
for (let page of this.pages) {
|
for (let page of this.pages) {
|
||||||
this.selectOptions.push({label:page.name, value: page._id})
|
this.selectOptions.push({label:page.name, value: page._id})
|
||||||
|
@ -271,7 +265,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.updateErrorMessage = "";
|
this.updateErrorMessage = "";
|
||||||
|
|
||||||
this.subscriptions.push(this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
|
this.subscriptions.push(this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.portal).subscribe(
|
||||||
_ => {
|
_ => {
|
||||||
this.deletePageHelpContentsFromArray(this.selectedPageContents);
|
this.deletePageHelpContentsFromArray(this.selectedPageContents);
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
|
@ -297,7 +291,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
this.router.navigate(['edit/'], {
|
this.router.navigate(['edit/'], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
"pageContentId": id,
|
"pageContentId": id,
|
||||||
"communityId": this.selectedCommunityPid,
|
"communityId": this.portal,
|
||||||
"pageId": this.selectedPageId
|
"pageId": this.selectedPageId
|
||||||
}, relativeTo: this.route
|
}, relativeTo: this.route
|
||||||
});
|
});
|
||||||
|
@ -305,7 +299,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
this.router.navigate(['edit/'], {
|
this.router.navigate(['edit/'], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
"pageContentId": id,
|
"pageContentId": id,
|
||||||
"communityId": this.selectedCommunityPid
|
"communityId": this.portal
|
||||||
}, relativeTo: this.route
|
}, relativeTo: this.route
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -322,7 +316,7 @@ export class PageHelpContentsComponent implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
this.updateErrorMessage = "";
|
this.updateErrorMessage = "";
|
||||||
|
|
||||||
this.subscriptions.push(this._helpService.togglePageHelpContents(ids, status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
|
this.subscriptions.push(this._helpService.togglePageHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe(
|
||||||
() => {
|
() => {
|
||||||
for (let id of ids) {
|
for (let id of ids) {
|
||||||
let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
|
let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
|
||||||
|
|
|
@ -28,19 +28,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="!showLoading && checkboxes.length > 0"
|
||||||
<div *ngIf="checkboxes.length > 0"
|
class="uk-padding uk-padding-remove-bottom uk-padding-remove-top uk-margin-remove-top uk-margin-small-bottom uk-display-inline"
|
||||||
class="uk-padding uk-padding-remove-bottom uk-padding-remove-top uk-margin-remove-top uk-margin-small-bottom"
|
[attr.uk-tooltip]="getSelectedPages().length == 0 ? 'pos:left; cls: uk-active' : null"
|
||||||
[attr.uk-tooltip]="getSelectedPages().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
title="Select at least one page"><input id="checkAll" type="checkbox" (click)="selectAll()"
|
||||||
title="Select at least one help text"><input id="checkAll" type="checkbox" (click)="selectAll()"
|
|
||||||
[ngModel]="getSelectedPages().length ==checkboxes.length"/>
|
[ngModel]="getSelectedPages().length ==checkboxes.length"/>
|
||||||
<span *ngIf="getSelectedPages().length > 0" class="uk-margin-left uk-text-muted">
|
<span *ngIf="getSelectedPages().length > 0" class="uk-margin-left uk-text-muted">
|
||||||
{{getSelectedPages().length}} pages selected </span>
|
{{getSelectedPages().length}} pages selected </span>
|
||||||
<a class="uk-margin-left ">Actions </a>
|
<a class="uk-margin-left">Actions</a>
|
||||||
<div uk-dropdown="mode: click">
|
<div uk-dropdown="mode: click">
|
||||||
<ul class="uk-nav uk-dropdown-nav"
|
<ul class="uk-nav uk-dropdown-nav"
|
||||||
[attr.uk-tooltip]="getSelectedPages().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
[attr.uk-tooltip]="getSelectedPages().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
|
||||||
title="Select at least one help text">
|
title="Select at least one page">
|
||||||
<li *ngIf="!isPortalAdministrator"><a [class]="getSelectedPages().length == 0 ? 'uk-disabled' : ''"
|
<li *ngIf="!isPortalAdministrator"><a [class]="getSelectedPages().length == 0 ? 'uk-disabled' : ''"
|
||||||
(click)="togglePages(true,getSelectedPages())"><i></i> Enable
|
(click)="togglePages(true,getSelectedPages())"><i></i> Enable
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|
|
@ -91,9 +91,7 @@ export class PagesComponent implements OnInit {
|
||||||
this.filterForm.get('type').setValue(params['type']);
|
this.filterForm.get('type').setValue(params['type']);
|
||||||
}
|
}
|
||||||
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
||||||
if (this.portal === 'connect' || this.portal === 'openaire' || this.portal === 'monitor') {
|
ConnectHelper.setPortalTypeFromPid(this.portal);
|
||||||
ConnectHelper.setPortalTypeFromPid(this.portal);
|
|
||||||
}
|
|
||||||
this.keyword = '';
|
this.keyword = '';
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.applyPortalFilter(this.portal);
|
this.applyPortalFilter(this.portal);
|
||||||
|
|
Loading…
Reference in New Issue