2017-09-22 12:26:08 +02:00
|
|
|
/**
|
|
|
|
* Created by stefania on 7/13/17.
|
|
|
|
*/
|
2018-12-03 12:33:03 +01:00
|
|
|
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
|
2017-09-22 12:26:08 +02:00
|
|
|
import { FormGroup } from "@angular/forms";
|
2018-11-13 16:26:49 +01:00
|
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
2017-09-22 12:26:08 +02:00
|
|
|
import { HelpContentService } from "../../services/help-content.service";
|
|
|
|
import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content";
|
|
|
|
import { Page } from "../../domain/page";
|
2017-12-13 12:15:19 +01:00
|
|
|
import { Community } from "../../domain/community";
|
2018-03-06 16:36:33 +01:00
|
|
|
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
2018-10-30 16:31:16 +01:00
|
|
|
import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe';
|
2017-09-22 12:26:08 +02:00
|
|
|
|
2018-11-13 16:26:49 +01:00
|
|
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
|
|
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
2019-04-24 13:44:46 +02:00
|
|
|
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
2018-11-13 16:26:49 +01:00
|
|
|
|
2017-09-22 12:26:08 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'page-help-contents',
|
|
|
|
templateUrl: './page-help-contents.component.html',
|
|
|
|
})
|
|
|
|
|
|
|
|
export class PageHelpContentsComponent implements OnInit {
|
|
|
|
|
|
|
|
// @ViewChild(ModalFormComponent)
|
|
|
|
// @ViewChild('saveModal')
|
|
|
|
// public modal:ModalFormComponent;
|
|
|
|
//
|
|
|
|
// @ViewChild('updateModal')
|
|
|
|
// public updateModal:ModalFormComponent;
|
|
|
|
//
|
|
|
|
// @ViewChild(PageHelpContentsFormComponent)
|
|
|
|
// public formComponent : PageHelpContentsFormComponent;
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
// @ViewChild('deleteConfirmationModal')
|
|
|
|
// public deleteConfirmationModal : DeleteConfirmationDialogComponent;
|
|
|
|
@ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents;
|
|
|
|
private selectedPageContents: string[] = [];
|
2017-09-22 12:26:08 +02:00
|
|
|
|
2018-01-04 16:56:22 +01:00
|
|
|
public checkboxes : CheckPageHelpContent[] = [];
|
2017-09-22 12:26:08 +02:00
|
|
|
|
|
|
|
public pageHelpContents : PageHelpContent[] = [];
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
//public errorMessage: string;
|
2017-09-22 12:26:08 +02:00
|
|
|
|
|
|
|
public formGroup : FormGroup;
|
|
|
|
|
|
|
|
public pages: Page[];
|
|
|
|
|
|
|
|
public checkboxAll : boolean = false;
|
|
|
|
|
|
|
|
public filters : PageHelpContentFilterOptions = {id : '', active : null, text : new RegExp('')};
|
2018-11-27 13:28:20 +01:00
|
|
|
public keyword: string = "";
|
2017-09-22 12:26:08 +02:00
|
|
|
|
|
|
|
public counter = {all : 0, active : 0, inactive : 0};
|
|
|
|
|
2017-12-13 12:15:19 +01:00
|
|
|
public communities: Community[] = [];
|
|
|
|
|
2018-01-29 23:45:42 +01:00
|
|
|
public selectedCommunityPid: string;
|
2017-12-13 12:15:19 +01:00
|
|
|
|
2017-12-20 15:26:30 +01:00
|
|
|
public selectedPageId: string;
|
|
|
|
|
2018-01-08 10:29:40 +01:00
|
|
|
public community: Community;
|
|
|
|
|
|
|
|
public page: Page;
|
2018-03-06 16:36:33 +01:00
|
|
|
public properties:EnvProperties = null;
|
2017-12-20 15:26:30 +01:00
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
public showLoading: boolean = true;
|
|
|
|
public errorMessage: string = '';
|
|
|
|
public updateErrorMessage: string = '';
|
|
|
|
|
2017-09-22 12:26:08 +02:00
|
|
|
ngOnInit() {
|
2018-03-06 16:36:33 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
this.route.queryParams.subscribe(params => {
|
2019-04-24 13:44:46 +02:00
|
|
|
HelperFunctions.scroll();
|
2018-03-06 16:36:33 +01:00
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
this.selectedCommunityPid = params['communityId'];
|
|
|
|
this.selectedPageId = params['pageId'];
|
2018-03-06 16:36:33 +01:00
|
|
|
|
|
|
|
if(this.selectedCommunityPid && this.selectedPageId) {
|
|
|
|
this.getPage(this.selectedPageId);
|
2018-10-30 16:31:16 +01:00
|
|
|
} else if(this.selectedCommunityPid) {
|
2018-03-06 16:36:33 +01:00
|
|
|
this.selectedPageId = "";
|
2018-10-30 16:31:16 +01:00
|
|
|
this.getPages(this.selectedCommunityPid);
|
2018-03-06 16:36:33 +01:00
|
|
|
}
|
|
|
|
});
|
2017-12-20 15:26:30 +01:00
|
|
|
});
|
2017-09-22 12:26:08 +02:00
|
|
|
// this.formGroup = this.formComponent.form;
|
|
|
|
}
|
|
|
|
|
2018-12-03 12:33:03 +01:00
|
|
|
constructor(private element: ElementRef, private route: ActivatedRoute, private router : Router, private _helpService: HelpContentService) {}
|
2017-12-20 15:26:30 +01:00
|
|
|
|
|
|
|
getPage(pageId: string) {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.updateErrorMessage = "";
|
|
|
|
this.errorMessage = "";
|
|
|
|
|
|
|
|
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
page => {
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
if( (this.selectedCommunityPid == 'openaire' && !page.openaire)
|
|
|
|
|| (this.selectedCommunityPid == 'connect' && !page.connect)
|
|
|
|
|| (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) {
|
|
|
|
this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.selectedCommunityPid} });
|
|
|
|
} else {
|
|
|
|
this.page = page;
|
|
|
|
this.getPageHelpContents(this.selectedCommunityPid);
|
|
|
|
}
|
2018-11-13 16:26:49 +01:00
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving page', error));
|
|
|
|
}
|
2017-12-13 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
2018-01-29 23:45:42 +01:00
|
|
|
getPages(community_pid: string) {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.updateErrorMessage = "";
|
|
|
|
this.errorMessage = "";
|
|
|
|
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
//this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
this._helpService.getPages(this.properties.adminToolsAPIURL, community_pid, true).subscribe(
|
|
|
|
pages => {
|
2018-11-13 16:26:49 +01:00
|
|
|
this.pages = pages;
|
|
|
|
this.getPageHelpContents(this.selectedCommunityPid);
|
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving pages', error));
|
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public countPageHelpContents() {
|
|
|
|
this.counter = {all : 0, active : 0, inactive : 0};
|
|
|
|
let filter = Object.assign({},this.filters);
|
|
|
|
filter.active = null;
|
|
|
|
this.pageHelpContents.forEach(_ => {
|
|
|
|
if(this.filterPageHelpContent(_,filter)){
|
|
|
|
if (_.isActive==true) this.counter.active++;
|
|
|
|
else this.counter.inactive++
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.counter.all = this.counter.active + this.counter.inactive;
|
|
|
|
}
|
|
|
|
|
2018-01-29 23:45:42 +01:00
|
|
|
getPageHelpContents(community_pid: string) {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
2018-03-06 16:36:33 +01:00
|
|
|
this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
|
2017-09-22 12:26:08 +02:00
|
|
|
pageHelpContents => {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.pageHelpContents = pageHelpContents as Array<PageHelpContent>;
|
|
|
|
this.counter.all = this.pageHelpContents.length;
|
|
|
|
this.checkboxes = [];
|
|
|
|
|
2019-07-25 16:09:29 +02:00
|
|
|
//for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
|
|
|
|
for (let i = 0; i < this.pageHelpContents.length; i++) {
|
2018-10-30 16:31:16 +01:00
|
|
|
let page: Page = this.pageHelpContents[i].page as Page;
|
|
|
|
if(!this.selectedPageId || (page._id == this.selectedPageId)) {
|
2019-07-26 12:08:18 +02:00
|
|
|
this.cutContent(this.pageHelpContents[i]);
|
2018-10-30 16:31:16 +01:00
|
|
|
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent : this.pageHelpContents[i], checked : false});
|
2017-12-20 15:26:30 +01:00
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.pageHelpContents.splice(i, 1);
|
2017-12-20 15:26:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
this.countPageHelpContents();
|
|
|
|
|
|
|
|
this.showLoading = false;
|
2017-09-22 12:26:08 +02:00
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving page contents', error));
|
2018-11-13 16:26:49 +01:00
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// public showModal():void {
|
|
|
|
// this.modal.showModal();
|
|
|
|
// }
|
|
|
|
|
|
|
|
public toggleCheckBoxes(event) {
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes.forEach(_ => _.checked = event.target.checked);
|
2017-09-22 12:26:08 +02:00
|
|
|
this.checkboxAll = event.target.checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
public applyCheck(flag : boolean) {
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes.forEach(_ => _.checked = flag);
|
2017-09-22 12:26:08 +02:00
|
|
|
this.checkboxAll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getSelectedPageHelpContents() : string[] {
|
2018-01-04 16:56:22 +01:00
|
|
|
return this.checkboxes.filter(pageHelpContent => pageHelpContent.checked == true)
|
2017-09-22 12:26:08 +02:00
|
|
|
.map(checkedPageHelpContent => checkedPageHelpContent.pageHelpContent).map(res => res._id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public confirmDeletePageHelpContent(id : string) {
|
2018-10-30 16:31:16 +01:00
|
|
|
//this.deleteConfirmationModal.ids = [id];
|
|
|
|
//this.deleteConfirmationModal.showModal();
|
|
|
|
this.selectedPageContents = [id];
|
|
|
|
this.confirmModalOpen();
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public confirmDeleteSelectedPageHelpContents() {
|
2018-10-30 16:31:16 +01:00
|
|
|
//this.deleteConfirmationModal.ids = this.getSelectedPageHelpContents();
|
|
|
|
//this.deleteConfirmationModal.showModal();
|
|
|
|
this.selectedPageContents = this.getSelectedPageHelpContents();
|
|
|
|
this.confirmModalOpen();
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
private confirmModalOpen() {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
|
|
|
this.alertModalDeletePageHelpContents.cancelButton = true;
|
|
|
|
this.alertModalDeletePageHelpContents.okButton = true;
|
|
|
|
this.alertModalDeletePageHelpContents.alertTitle = "Delete Confirmation";
|
|
|
|
this.alertModalDeletePageHelpContents.message = "Are you sure you want to delete the selected page content(s)?";
|
|
|
|
this.alertModalDeletePageHelpContents.okButtonText = "Yes";
|
|
|
|
this.alertModalDeletePageHelpContents.open();
|
|
|
|
}
|
2018-10-30 16:31:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public confirmedDeletePageHelpContents(data: any) {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.showLoading = true;
|
|
|
|
this.updateErrorMessage = "";
|
|
|
|
|
|
|
|
this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
_ => {
|
|
|
|
this.deletePageHelpContentsFromArray(this.selectedPageContents);
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
error => this.handleUpdateError('System error deleting the selected page content(s)', error)
|
2017-09-22 12:26:08 +02:00
|
|
|
);
|
2018-11-13 16:26:49 +01:00
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private deletePageHelpContentsFromArray(ids : string[]) : void {
|
|
|
|
for(let id of ids) {
|
2018-01-04 16:56:22 +01:00
|
|
|
let iqc = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
|
2017-09-22 12:26:08 +02:00
|
|
|
let iq = this.pageHelpContents.findIndex(_ => _._id == id);
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes.splice(iqc, 1);
|
2017-09-22 12:26:08 +02:00
|
|
|
this.pageHelpContents.splice(iqc, 1);
|
|
|
|
}
|
2018-02-06 12:06:43 +01:00
|
|
|
this.countPageHelpContents();
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
2018-01-29 23:45:42 +01:00
|
|
|
public editPageHelpContent(id : string) {
|
2017-12-13 12:15:19 +01:00
|
|
|
//this.router.navigate(['/pageContents/edit/', _id]);
|
2017-12-20 15:26:30 +01:00
|
|
|
if(this.selectedPageId) {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "communityId": this.selectedCommunityPid, "pageId": this.selectedPageId } } );
|
2017-12-20 15:26:30 +01:00
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "communityId": this.selectedCommunityPid } } );
|
2017-12-20 15:26:30 +01:00
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public togglePageHelpContents(status : boolean, ids : string[]) {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.updateErrorMessage = "";
|
|
|
|
|
2018-03-06 16:36:33 +01:00
|
|
|
this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe(
|
2017-12-13 12:15:19 +01:00
|
|
|
() => {
|
|
|
|
for(let id of ids) {
|
2018-01-04 16:56:22 +01:00
|
|
|
let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
|
|
|
|
this.checkboxes[i].pageHelpContent.isActive=status;
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
this.countPageHelpContents();
|
|
|
|
this.applyCheck(false);
|
2018-10-30 16:31:16 +01:00
|
|
|
},
|
|
|
|
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
|
2017-09-22 12:26:08 +02:00
|
|
|
);
|
2018-11-13 16:26:49 +01:00
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
|
2019-07-26 12:08:18 +02:00
|
|
|
this.cutContent(pageHelpContent);
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent : pageHelpContent, checked : false});
|
2017-09-22 12:26:08 +02:00
|
|
|
this.pageHelpContents.push(pageHelpContent);
|
|
|
|
this.applyCheck(false);
|
|
|
|
this.countPageHelpContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
public pageHelpContentUpdatedSuccessfully(pageHelpContent : PageHelpContent) {
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes.find(checkItem => checkItem.pageHelpContent._id==pageHelpContent._id).pageHelpContent = pageHelpContent;
|
2017-09-22 12:26:08 +02:00
|
|
|
let index = this.pageHelpContents.findIndex(checkItem => checkItem._id==pageHelpContent._id);
|
|
|
|
this.pageHelpContents[index] = pageHelpContent;
|
|
|
|
this.applyCheck(false);
|
|
|
|
this.countPageHelpContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public filterPageHelpContent(pageHelpContent : PageHelpContent, filters : PageHelpContentFilterOptions) : boolean {
|
|
|
|
let idFlag = filters.id == '' || (<Page>pageHelpContent.page)._id == filters.id;
|
|
|
|
let activeFlag = filters.active == null || pageHelpContent.isActive == filters.active;
|
|
|
|
let textFlag = filters.text.toString() == '' || (pageHelpContent.content).match(filters.text) != null;
|
|
|
|
return idFlag && activeFlag && textFlag;
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:08:18 +02:00
|
|
|
public cutContent(pageHelpContent: PageHelpContent) {
|
|
|
|
pageHelpContent.content = pageHelpContent.content.replace(/<[^>]*>/g, '');
|
|
|
|
if(pageHelpContent.content.length > 200) {
|
|
|
|
pageHelpContent.content = pageHelpContent.content.substr(0, 200) + "...";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-22 12:26:08 +02:00
|
|
|
public applyFilter() {
|
2018-01-04 16:56:22 +01:00
|
|
|
this.checkboxes = [];
|
2017-09-22 12:26:08 +02:00
|
|
|
this.pageHelpContents.filter(item => this.filterPageHelpContent(item,this.filters)).forEach(
|
2019-07-26 12:08:18 +02:00
|
|
|
_ => {
|
|
|
|
this.cutContent(_);
|
|
|
|
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
|
|
|
|
}
|
2017-09-22 12:26:08 +02:00
|
|
|
);
|
|
|
|
this.countPageHelpContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
public filterByPage(event: any) {
|
|
|
|
this.filters.id = event.target.value;
|
|
|
|
this.applyFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
public displayAllPageHelpContents() {
|
|
|
|
this.filters.active = null;
|
|
|
|
this.applyFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
public displayActivePageHelpContents() {
|
|
|
|
this.filters.active = true;
|
|
|
|
this.applyFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
public filterBySearch(text : string) {
|
|
|
|
this.filters.text = new RegExp(text, "i");
|
|
|
|
this.applyFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
public displayInactivePageHelpContents() {
|
|
|
|
this.filters.active = false;
|
|
|
|
this.applyFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleError(message: string, error) {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.errorMessage = message;
|
|
|
|
console.log('Server responded: ' + error);
|
|
|
|
|
|
|
|
this.showLoading = false;
|
2017-09-22 12:26:08 +02:00
|
|
|
}
|
2017-12-13 12:15:19 +01:00
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
handleUpdateError(message: string, error) {
|
|
|
|
this.updateErrorMessage = message;
|
|
|
|
console.log('Server responded: ' +error);
|
|
|
|
|
|
|
|
this.showLoading = false;
|
2017-12-13 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
public newPageContent() {
|
|
|
|
if(this.selectedPageId) {
|
|
|
|
this.router.navigate( ['/pageContents/new'], { queryParams: {communityId: this.selectedCommunityPid, pageId: this.selectedPageId} } );
|
|
|
|
} else {
|
|
|
|
this.router.navigate( ['/pageContents/new'], { queryParams: {communityId: this.selectedCommunityPid} } );
|
|
|
|
}
|
2017-12-13 12:15:19 +01:00
|
|
|
}
|
|
|
|
}
|