1. Added divId page and form : special classes to be used by explore portal pages which have steps

2. Added divHelpContent pages and form
3. 'before' field of pageHelpContent renamed to 'isPriorTo'
4. Added 'before' checkbox in pageHelpContent form
5. 'uk-button-default' class removed
6. Message (modal) when entity is toggled added - 'none' type in modal form added - Toggle entity if message is approved, cancel otherwise
7. countPageHelpContents() function is called after deleting pageHelpContents
8. Added link to divHelpContents in 'pages' page, only for pages that are related to some divIds


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@50607 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-02-06 11:06:43 +00:00
parent 00b8788918
commit 44daac0654
36 changed files with 1500 additions and 82 deletions

View File

@ -47,7 +47,18 @@
</li>
</ul>
</li>
<li class="uk-nav-header uk-parent">
Manage Predefined Classes for Contents
<ul class="uk-nav-sub">
<li>
<a routerLink="/classes" routerLinkActive="active">
<i class="fa fa-cog"></i>
<span>Classes</span>
</a>
</li>
</ul>
</li>
<li class="uk-nav-header uk-parent">
Manage Pages
@ -89,6 +100,12 @@
<span>Page Contents</span>
</a>
</li>
<li>
<a routerLink="/classContents" routerLinkActive="active">
<i class="fa fa-cog"></i>
<span>Class Contents</span>
</a>
</li>
</ul>
</li>
</ul>

View File

@ -32,7 +32,14 @@ import { CommunityFormComponent } from './pages/community/community-form.compone
import { CommunityEditFormComponent } from './pages/community/community-edit-form.component';
import { EntitiesComponent } from "./pages/helpcontent/entities.component";
import { EntityFormComponent } from "./pages/helpcontent/entity-form.component";
import { DivIdsComponent } from "./pages/divId/divIds.component";
import { DivIdFormComponent } from "./pages/divId/divId-form.component";
import { DivHelpContentsComponent } from "./pages/divhelpcontent/div-help-contents.component";
import { NewDivHelpContentComponent } from "./pages/divhelpcontent/new-div-help-content.component";
import { DivContentFormComponent } from "./pages/divhelpcontent/div-help-content-form.component";
import { EditDivHelpContentComponent } from "./pages/divhelpcontent/edit-div-help-content.component";
import {BottomModule, FeedbackModule, NavigationBarModule, CookieLawModule} from 'ng-openaire-library';
//, , ErrorModule CookieLawModule
@NgModule({
imports: [
@ -69,7 +76,13 @@ import {BottomModule, FeedbackModule, NavigationBarModule, CookieLawModule} from
CommunityFormComponent,
CommunityEditFormComponent,
EntitiesComponent,
EntityFormComponent
EntityFormComponent,
DivIdsComponent,
DivIdFormComponent,
DivHelpContentsComponent,
NewDivHelpContentComponent,
EditDivHelpContentComponent,
DivContentFormComponent
],
providers: [
FAQService,

View File

@ -14,7 +14,10 @@ import { PagesComponent } from "./pages/helpcontent/pages.component";
import { PageHelpContentsComponent } from "./pages/helpcontent/page-help-contents.component";
import { NewPageHelpContentComponent } from "./pages/helpcontent/new-page-help-content.component";
import { EditPageHelpContentComponent } from "./pages/helpcontent/edit-page-help-content.component";
import { DivIdsComponent } from "./pages/divId/divIds.component";
import { DivHelpContentsComponent } from "./pages/divhelpcontent/div-help-contents.component";
import { NewDivHelpContentComponent } from "./pages/divhelpcontent/new-div-help-content.component";
import { EditDivHelpContentComponent } from "./pages/divhelpcontent/edit-div-help-content.component";
const appRoutes: Routes = [
{
@ -46,6 +49,10 @@ const appRoutes: Routes = [
path: 'entities',
component: EntitiesComponent,
},
{
path: 'classes',
component: DivIdsComponent,
},
{
path: 'pages',
component: PagesComponent,
@ -62,6 +69,18 @@ const appRoutes: Routes = [
//path: 'pageContents/edit/:id',
path: 'pageContents/edit',
component: EditPageHelpContentComponent,
},
{
path: 'classContents',
component: DivHelpContentsComponent,
},
{
path: 'classContents/new',
component: NewDivHelpContentComponent,
},
{
path: 'classContents/edit',
component: EditDivHelpContentComponent,
}
];

View File

@ -0,0 +1,19 @@
import { DivId } from "./divId";
export interface DivHelpContent {
_id: string;
divId: DivId | string;
content: string;
isActive: boolean;
}
export interface CheckDivHelpContent {
divHelpContent : DivHelpContent;
checked : boolean;
}
export interface DivHelpContentFilterOptions {
id : string;
active : Boolean;
text : RegExp;
}

14
app/domain/divId.ts Normal file
View File

@ -0,0 +1,14 @@
import {Page} from './page';
import {Community} from './community';
export interface DivId {
_id: string;
name: string;
page: string | Page;
community: string | Community;
}
export interface CheckDivId {
divId : DivId;
checked : boolean;
}

View File

@ -12,6 +12,7 @@ export interface PageHelpContent {
order: number;
content: string;
isActive: boolean;
isPriorTo: boolean;
}
export interface CheckPageHelpContent {

View File

@ -5,7 +5,7 @@
<div class="community-title uk-article-title">Communities</div>
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Community name..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button uk-button-default" type="submit">Search</button>
<button class="uk-button" type="submit">Search</button>
</form>
<a (click)="showModal()" class="uk-button uk-button-primary uk-float-right"><i></i> New Community </a>
</div>
@ -22,7 +22,7 @@
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button uk-button-default" type="button"> Bulk Actions</button>
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="confirmDeleteSelectedCommunities()"><i></i> Delete </a></li>

View File

@ -0,0 +1,13 @@
<form [formGroup]="myForm">
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.page.valid && myForm.controls.page.dirty}">
<label for="pageTag">Select Page</label>
<select formControlName="page" id="pageTag" class="form-control">
<option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option>
</select>
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.name.valid && myForm.controls.name.dirty}">
<label for="divIdNameTag">Class Name</label>
<input type="text" class="form-control" formControlName="name" id="divIdNameTag" placeholder="Class Name">
</div>
<input type="hidden" formControlName="_id">
</form>

View File

@ -0,0 +1,53 @@
import {Component, OnInit, Input} from '@angular/core';
import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms";
import { HelpContentService } from "../../services/help-content.service";
import { Page } from "../../domain/page";
@Component({
selector: 'divId-form',
templateUrl: './divId-form.component.html',
})
export class DivIdFormComponent implements OnInit{
@Input('group')
myForm: FormGroup;
@Input('communityPid')
communityPid: string;
@Input('pageId')
pageId: string;
@Input('availablePages')
availablePages : Page[] = [];
public errorMessage: string;
constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit(): void {
}
public get form() {
return this._fb.group({
_id : '',
name : ['', Validators.required],
page : [this.pageId,Validators.required],
community : this.communityPid,
});
}
public reset() {
this.myForm.patchValue({
_id : '',
name : '',
page: '',
community: this.communityPid
});
}
handleError(message: string, error) {
if(error == null) {
this.reset();
}
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
}

View File

@ -0,0 +1,104 @@
<div id="divIds" class="uk-container">
<div class="menubar ">
<div class="divId-title uk-article-title">Predefined classes for contents</div>
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Class name..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button" type="submit">Search</button>
</form>
<a (click)="showModal()" class="uk-button uk-button-primary uk-float-right"><i></i> New Class </a>
</div>
<div class="content-wrapper" id="contentWrapper">
<div>
<div class="contentPanel">
<div class="uk-alert-danger" uk-alert style="display: none;" aria-hidden="true">
<span></span><span></span><span></span></div>
<div class="uk-alert-success" uk-alert style="display: none;" aria-hidden="true">
<span></span><span></span><span></span></div>
<div class="uk-alert" uk-alert style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="confirmDeleteSelectedCommunities()"><i></i> Delete </a></li>
</ul>
</div>
</div>
</div>
</div>
<div>
<div class="gwt-HTML">
<div class="row users-list">
<div class="col-md-12">
<div class="filters marginBottom20">
<div class="links form-group form-inline">
<span>Filter by community:</span>
<select class="uk-select uk-width-medium" (change)="filterByCommunity($event)">
<!--option value="">-- none selected --</option-->
<option *ngFor="let community of communities" value="{{community.pid}}">{{community.name}}</option>
</select>
</div>
</div>
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th><input id="allDivIdCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th>
<th>Name</th>
<th>Community</th>
<th>Page</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let check of checkboxes; let i=index">
<td><input id="{{check.divId._id}}" class="checkBox" type="checkbox"
name="divIdscb[]" value="{{check.divId._id}}" [(ngModel)]="check.checked">
</td>
<td>
<div class="name" href="#">{{check.divId.name}}</div>
</td>
<td>
<div class="community" href="#">{{check.divId.community.name}}</div>
</td>
<td>
<div class="page" href="#">{{check.divId.page.name}}</div>
</td>
<td>
<div class="actions" href="#">
<input title="Edit" src="imgs/icn_edit.png" class="edit" type="image" (click)="editDivId(i)">
<input title="Delete" src="imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteDivId(check.divId._id)">
</div>
</td>
</tr>
</tbody>
</table>
<div *ngIf="checkboxes.length==0" class="col-md-12">
<div class="uk-alert-warning" uk-alert>No classes found</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Class'" [formGroup]="formGroup" [type]="'divId'"
[isModalShown]="isModalShown" (emmitObject)="divIdSavedSuccessfully($event)" (emmitError)="handleError($event)">
<divId-form [group]="formGroup" [communityPid]="selectedCommunityPid" [availablePages]="pages"></divId-form>
</modal-form>
<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Class'" [formGroup]="formGroup" [type]="'divId'"
[isModalShown]="isModalShown" (emmitObject)="divIdUpdatedSuccessfully($event)" (emmitError)="handleError($event)">
<divId-form [group]="formGroup" [communityPid]="selectedCommunityPid" [availablePages]="pages"></divId-form>
</modal-form>
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteDivIds($event)">
Are you sure you want to delete the selected class(-es)?
</delete-confirmation-dialog>

View File

@ -0,0 +1,198 @@
import { Component, ViewChild, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { HelpContentService } from "../../services/help-content.service";
import { FormGroup } from "@angular/forms";
import { ModalFormComponent } from "../modal-form.component";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { DivIdFormComponent } from "./divId-form.component";
import { CheckDivId, DivId } from "../../domain/divId";
import { Community } from "../../domain/community";
import { Page } from "../../domain/page";
@Component({
selector: 'divIds',
templateUrl: './divIds.component.html',
})
export class DivIdsComponent implements OnInit {
@ViewChild(ModalFormComponent)
@ViewChild('saveModal')
public modal:ModalFormComponent;
@ViewChild('updateModal')
public updateModal:ModalFormComponent;
@ViewChild('deleteConfirmationModal')
public deleteConfirmationModal : DeleteConfirmationDialogComponent;
@ViewChild(DivIdFormComponent)
public formComponent : DivIdFormComponent;
public checkboxes : CheckDivId[] = [];
public divIds : DivId[] = [];
public errorMessage: string;
public formGroup : FormGroup;
private searchText : RegExp = new RegExp('');
public selectedCommunityPid: string;
public communities: Community[] = [];
public pages: Page[] = [];
ngOnInit() {
this.formGroup = this.formComponent.form;
this.route.queryParams.subscribe(params => {
// if(params['community']) {
// this.getCommunity(params['community']);
// } else {
this.getCommunities();
//}
});
}
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
/*
getCommunity(community_pid: string) {
let self = this;
this._helpContentService.getCommunityFull(community_pid).subscribe(
community => {
self.communities = [community];
this.checkboxes.push(<CheckCommunity>{community : community, checked : false});
},
error => this.handleError('System error retrieving communities', error));
}
*/
getCommunities() {
let self = this;
this._helpContentService.getCommunities().subscribe(
communities => {
self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid;
self.getPages(self.selectedCommunityPid);
self.getDivIds(self.selectedCommunityPid);
self.formGroup.patchValue({
community: self.selectedCommunityPid
});
},
error => this.handleError('System error retrieving communities', error));
}
getPages(community_pid: string) {
this._helpContentService.getCommunityPages(community_pid).subscribe(
pages => this.pages = pages,
error => this.handleError('System error retrieving pages', error));
}
getDivIds(community_pid: string) {
let self = this;
this._helpContentService.getDivIdsFull(community_pid, null).subscribe(
divIds => {
self.divIds = divIds;
self.checkboxes = [];
divIds.forEach(_ => {
self.checkboxes.push(<CheckDivId>{divId : _, checked : false});
});
},
error => this.handleError('System error retrieving classes', error));
}
public showModal():void {
this.modal.showModal();
}
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
}
public applyCheck(flag : boolean) {
console.info("applyCheck "+flag);
this.checkboxes.forEach(_ => _.checked = flag);
}
public getSelectedDivIds() : string[] {
return this.checkboxes.filter(divId => divId.checked == true).map(checkedDivId => checkedDivId.divId).map(res => res._id);
}
private deleteDivIdsFromArray(ids : string[]) : void {
for(let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divId._id == id);
this.checkboxes.splice(i, 1);
}
}
public confirmDeleteDivId(id : string) {
this.deleteConfirmationModal.ids = [id];
this.deleteConfirmationModal.showModal();
}
public confirmDeleteSelectedDivIds() {
this.deleteConfirmationModal.ids = this.getSelectedDivIds();
this.deleteConfirmationModal.showModal();
}
public confirmedDeleteDivIds(ids : string[]) {
this._helpContentService.deleteDivIds(ids).subscribe(
_ => this.deleteDivIdsFromArray(ids),
error => this.handleError('System error deleting the selected classes', error)
);
}
public editDivId(i : number) {
let divId : DivId = this.checkboxes[i].divId;
this.formGroup.patchValue(divId);
this.updateModal.showModal();
}
public divIdSavedSuccessfully(divId: DivId) {
this.checkboxes.push(<CheckDivId>{divId : divId, checked : false});
console.info("checkboxes length: "+this.checkboxes.length);
this.applyCheck(false);
}
public divIdUpdatedSuccessfully(divId : DivId) {
this.checkboxes.find(checkItem => checkItem.divId._id==divId._id).divId = divId;
this.applyCheck(false);
}
public filterBySearch(text : string) {
this.searchText = new RegExp(text,'i');
this.applyFilter();
}
public applyFilter() {
this.checkboxes = [];
this.divIds.filter(item => this.filterDivIds(item)).forEach(
_ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false})
);
}
public filterDivIds(divId : DivId) : boolean {
let textFlag = this.searchText.toString() == '' || (/*community.route + ' ' +*/divId.name).match(this.searchText) != null;
return textFlag;
}
public filterByCommunity(event: any) {
this.selectedCommunityPid = event.target.value;
this.formGroup.patchValue({
community: this.selectedCommunityPid
});
this.applyCommunityFilter(this.selectedCommunityPid);
}
public applyCommunityFilter(community_pid: string) {
this.getDivIds(community_pid);
this.getPages(community_pid);
}
handleError(message: string, error) {
if(error == null) {
this.formComponent.reset();
}
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
}

View File

@ -0,0 +1,49 @@
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<form [formGroup]="myForm">
<div class="form-group">
<!--div class="form-group" [ngClass]="{'has-error':!myForm.controls.divId.valid && myForm.controls.divId.dirty}"-->
<label *ngIf="showPageSelect" for="pageTag">Select Page</label>
<select *ngIf="showPageSelect" id="pageTag" (change)="pageSelected($event)">
<option *ngIf="!pageId"></option>
<option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option>
</select>
<label *ngIf="pageId" for="divTag">Select Class</label>
<select *ngIf="pageId" formControlName="divId" id="divTag" class="form-control" (change)="selectedDiv($event)">
<option *ngFor="let div of availableDivs" [value]="div._id">{{div.name}}</option>
</select>
<!--/div-->
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.content.valid && myForm.controls.content.dirty}">
<label>Content</label>
<div>
<ckeditor
[readonly]="false"
debounce="500"
formControlName="content"
[config]="{allowedContent: true,extraAllowedContent : '*(*)'}">
<!--id="contentTag"-->
<!--(ready)="onReady($event)"-->
<!--(focus)="onFocus($event)"-->
<!--[config]="{uiColor: '#99000'}"-->
<!--(blur)="onBlur($event)"-->
<!--(change)="onChange($event)"-->
</ckeditor>
</div>
<!--<textarea class="form-control" formControlName="content" id="contentTag" placeholder="Content" rows="3"></textarea>-->
</div>
<div class="form-group">
<label>Select Status</label>
<label class="checkbox">
<span style="font-weight: normal;">Active</span>
<input tabindex="0" type="checkbox" formControlName="isActive">
</label>
</div>
<input type="hidden" formControlName="_id">
</form>
<!--<pre>-->
<!--{{myForm.value | json}}-->
<!--{{myForm.valid}}-->
<!--</pre>-->

View File

@ -0,0 +1,86 @@
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { Page } from "../../domain/page";
import { DivId } from "../../domain/divId";
import { HelpContentService } from "../../services/help-content.service";
@Component({
selector: 'div-content-form',
templateUrl: './div-help-content-form.component.html',
})
export class DivContentFormComponent implements OnInit{
@Input('group')
myForm: FormGroup;
@Input('communityPid')
communityPid: string;
@Input('pageId')
pageId: string;
showPageSelect: boolean = true;
private availablePages : Page[] = [];
private availableDivs : DivId[] = [];
private errorMessage: string;
private ckeditorContent : string;
constructor(private _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit() {
this.myForm = this.form;
if(this.pageId) {
this.showPageSelect = false;
this.getDivs(this.pageId);
} else {
this._helpContentService.getCommunityPagesWithDivId(this.communityPid).subscribe(
pages => this.availablePages = pages,
error => this.handleError('System error retrieving pages', error));
}
}
public pageSelected(event) {
this.getDivs(event.target.value);
}
public getDivs(pageId: string) {
console.info(pageId);
this._helpContentService.getDivIdsFull(this.communityPid, pageId).subscribe(
divs => {
this.availableDivs = divs;
this.pageId = pageId;
},
error => this.handleError('System error retrieving pages', error));
}
public selectedDiv(event) {
console.info(event.target.value);
}
public get form() {
return this._fb.group({
divId: ['', Validators.required],
content: ['', Validators.required],
isActive: true,
_id : '',
});
}
public reset() {
this.myForm.patchValue({
divId: '',
content: '',
isActive: true,
_id : ''
});
this.myForm.markAsPristine();
}
handleError(message: string, error) {
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
}

View File

@ -0,0 +1,138 @@
<div id="divHelpContents" class="uk-container">
<div class="menubar ">
<div *ngIf="!selectedPageId" class="divHelpContent-title uk-article-title">Class Help Contents</div>
<div *ngIf="selectedPageId && page && community" class="divHelpContent-title uk-article-title">'{{page.name}}' Help Contents of community {{community.name}}</div>
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Class Help Content..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button" type="submit">Search</button>
</form>
<a *ngIf="!selectedPageId" [queryParams]="{community: selectedCommunityPid}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
<a *ngIf="selectedPageId" [queryParams]="{community: selectedCommunityPid, pageId: selectedPageId}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
</div>
<div class="content-wrapper" id="contentWrapper">
<div>
<div class="contentPanel">
<div class="uk-alert-danger" uk-alert style="display: none;" aria-hidden="true">
<span></span><span></span><span></span></div>
<div class="uk-alert-success" uk-alert style="display: none;" aria-hidden="true">
<span></span><span></span><span></span></div>
<div class="uk-alert" uk-alert style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="toggleDivHelpContents(true,getSelectedDivHelpContents())"><i></i> Activate </a></li>
<li><a (click)="toggleDivHelpContents(false,getSelectedDivHelpContents())"><i></i> Deactivate </a></li>
<li><a (click)="confirmDeleteSelectedDivHelpContents()"><i></i> Delete </a></li>
</ul>
</div>
</div>
</div>
</div>
<div>
<div class="gwt-HTML">
<div class="row users-list">
<div class="col-md-12">
<div *ngIf="!selectedPageId" class="filters marginBottom20">
<div class="links form-group form-inline">
<span>Filter by community:</span>
<select class="uk-select uk-width-medium" (change)="filterByCommunity($event)">
<option *ngFor="let community of communities" value="{{community.pid}}">{{community.name}}</option>
</select>
</div>
</div>
<div *ngIf="!selectedPageId" class="filters marginBottom20">
<div class="links form-group form-inline">
<span>Filter by page:</span>
<select class="uk-select uk-width-medium" (change)="filterByPage($event)">
<option value="">-- none selected --</option>
<option *ngFor="let page of pages" value="{{page._id}}">{{page.name}}</option>
</select>
</div>
</div>
<span class="gwt-Label filterLabel">Filter page contents:</span>
<ul uk-tab class="links">
<li [ngClass]="{'uk-active' : filters.active==null}" (click)="displayAllDivHelpContents()">
<a>All Class Contents <span class="uk-badge">{{counter.all}}</span></a>
</li>
<li [ngClass]="{'uk-active' : filters.active==true}" (click)="displayActiveDivHelpContents()">
<a>Active <span class="uk-badge">{{counter.active}}</span></a>
</li>
<li [ngClass]="{'uk-active' : filters.active==false}" (click)="displayInactiveDivHelpContents()">
<a>Inactive <span class="uk-badge">{{counter.inactive}}</span></a>
</li>
</ul>
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th><input id="allDivHelpContentsCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th>
<th *ngIf="!selectedPageId">Page</th>
<th *ngIf="!selectedPageId">Community</th>
<th>Class</th>
<th>Content</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let check of checkboxes; let i=index">
<td><input id="{{check.divHelpContent._id}}" class="checkBox" type="checkbox"
name="entitiescb[]" value="{{check.divHelpContent._id}}" [(ngModel)]="check.checked">
</td>
<td *ngIf="!selectedPageId">
<div class="page" href="#">{{check.divHelpContent.divId.page.name}}</div>
</td>
<td *ngIf="!selectedPageId">
<div class="community" href="#">{{check.divHelpContent.divId.community.name}}</div>
</td>
<td>
<div class="divId" href="#">{{check.divHelpContent.divId.name}}</div>
</td>
<td>
<div class="content" href="#">{{check.divHelpContent.content}}</div>
</td>
<td>
<div *ngIf="check.divHelpContent.isActive" class="activated" >
<input (click)="toggleDivHelpContents(false,[check.divHelpContent._id])" class="deactivate" src="imgs/check-icon.png" title="Deactivate" width="20" type="image" height="20">
</div>
<div *ngIf="!check.divHelpContent.isActive" class="deactivated" >
<input (click)="toggleDivHelpContents(true,[check.divHelpContent._id])" class="activate" src="imgs/x-icon.png" title="Activate" width="20" type="image" height="20">
</div>
</td>
<td>
<div class="actions" href="#">
<input title="Edit" src="imgs/icn_edit.png" class="edit" type="image" (click)="editDivHelpContent(check.divHelpContent._id)">
<input title="Delete" src="imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteDivHelpContent(check.divHelpContent._id)">
</div>
</td>
</tr>
</tbody>
</table>
<div *ngIf="checkboxes.length==0" class="col-md-12">
<div class="uk-alert-warning" uk-alert>No page contents found</div>
</div>
</div>
</div>
</div>
<a *ngIf="selectedPageId && page" [queryParams]="{type: page.type}" routerLink="/pages">Go back to {{page.type}} pages</a>
</div>
</div>
</div>
</div>
</div>
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteDivHelpContents($event)">
Are you sure you want to delete the selected page content(s)?
</delete-confirmation-dialog>

View File

@ -0,0 +1,308 @@
import { Component, ViewChild, OnInit } from '@angular/core';
import { Router } from "@angular/router";
import { FormGroup } from "@angular/forms";
import { ActivatedRoute } from "@angular/router";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { HelpContentService } from "../../services/help-content.service";
import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content";
import { Page } from "../../domain/page";
import { Community } from "../../domain/community";
import { DivId } from "../../domain/divId";
@Component({
selector: 'div-help-contents',
templateUrl: './div-help-contents.component.html',
})
export class DivHelpContentsComponent implements OnInit {
// @ViewChild(ModalFormComponent)
// @ViewChild('saveModal')
// public modal:ModalFormComponent;
//
// @ViewChild('updateModal')
// public updateModal:ModalFormComponent;
//
// @ViewChild(PageHelpContentsFormComponent)
// public formComponent : PageHelpContentsFormComponent;
@ViewChild('deleteConfirmationModal')
public deleteConfirmationModal : DeleteConfirmationDialogComponent;
public checkboxes : CheckDivHelpContent[] = [];
public divHelpContents : DivHelpContent[] = [];
public errorMessage: string;
public formGroup : FormGroup;
public pages: Page[];
public checkboxAll : boolean = false;
public filters : DivHelpContentFilterOptions = {id : '', active : null, text : new RegExp('')};
public counter = {all : 0, active : 0, inactive : 0};
public communities: Community[] = [];
public selectedCommunityPid: string;
public selectedPageId: string;
public community: Community;
public page: Page;
ngOnInit() {
this.route.queryParams.subscribe(params => {
this.selectedCommunityPid = params['community'];
this.selectedPageId = params['page'];
if(this.selectedCommunityPid && this.selectedPageId) {
this.getDivHelpContents(this.selectedCommunityPid);
this.getPage(this.selectedPageId);
this.getCommunity(this.selectedCommunityPid);
} else {
this.selectedPageId = "";
this.getCommunities();
}
});
// this.formGroup = this.formComponent.form;
}
constructor(private route: ActivatedRoute, private _helpService: HelpContentService, private router : Router) {}
getPage(pageId: string) {
let self = this;
this._helpService.getPage(pageId).subscribe(
page => {
self.page = page;
}
);
}
getCommunity(communityPid: string) {
let self = this;
this._helpService.getCommunity(communityPid).subscribe(
community => {
self.community = community;
}
);
}
getCommunities() {
let self = this;
this._helpService.getCommunitiesWithDivId().subscribe(
communities => {
self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid;
this.getPages(self.selectedCommunityPid);
this.getDivHelpContents(self.selectedCommunityPid);
},
error => this.handleError('System error retrieving communities', error));
}
getPages(community_pid: string) {
this._helpService.getCommunityPagesWithDivId(community_pid).subscribe(
pages => this.pages = pages,
error => this.handleError('System error retrieving pages', error));
}
public countDivHelpContents() {
this.counter = {all : 0, active : 0, inactive : 0};
let filter = Object.assign({},this.filters);
filter.active = null;
this.divHelpContents.forEach(_ => {
if(this.filterDivHelpContent(_,filter)){
if (_.isActive==true) this.counter.active++;
else this.counter.inactive++
}
});
this.counter.all = this.counter.active + this.counter.inactive;
}
getDivHelpContents(community_pid: string) {
let self = this;
this._helpService.getCommunityDivHelpContents(community_pid).subscribe(
divHelpContents => {
self.divHelpContents = divHelpContents as Array<DivHelpContent>;
self.counter.all = self.divHelpContents.length;
self.checkboxes = [];
/*self.pageHelpContents.forEach(_ => {
let page: Page = _.page as Page;
if(!self.selectedPageId || (page._id == self.selectedPageId)) {
self.checkboxes.push(<CheckPageHelpContent>{pageHelpContent : _, checked : false});
}
});*/
for (let i = self.divHelpContents.length - 1; i >= 0; i -= 1) {
let divId: DivId = self.divHelpContents[i].divId as DivId;
let page: Page = divId.page as Page;
if(!self.selectedPageId || (page._id == self.selectedPageId)) {
self.checkboxes.push(<CheckDivHelpContent>{divHelpContent : self.divHelpContents[i], checked : false});
} else {
self.divHelpContents.splice(i, 1);
}
}
self.countDivHelpContents();
},
error => this.handleError('System error retrieving page contents', error));
}
// public showModal():void {
// this.modal.showModal();
// }
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
this.checkboxAll = event.target.checked;
}
public applyCheck(flag : boolean) {
this.checkboxes.forEach(_ => _.checked = flag);
this.checkboxAll = false;
}
public getSelectedDivHelpContents() : string[] {
return this.checkboxes.filter(divHelpContent => divHelpContent.checked == true)
.map(checkedDivHelpContent => checkedDivHelpContent.divHelpContent).map(res => res._id);
}
public confirmDeleteDivHelpContent(id : string) {
this.deleteConfirmationModal.ids = [id];
this.deleteConfirmationModal.showModal();
}
public confirmDeleteSelectedDivHelpContents() {
this.deleteConfirmationModal.ids = this.getSelectedDivHelpContents();
this.deleteConfirmationModal.showModal();
}
public confirmedDeleteDivHelpContents(ids : string[]) {
this._helpService.deleteDivHelpContents(ids).subscribe(
_ => this.deleteDivHelpContentsFromArray(ids),
error => this.handleError('System error deleting the selected class content(s)', error)
);
}
private deleteDivHelpContentsFromArray(ids : string[]) : void {
for(let id of ids) {
let iqc = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
let iq = this.divHelpContents.findIndex(_ => _._id == id);
this.checkboxes.splice(iqc, 1);
this.divHelpContents.splice(iqc, 1);
}
this.countDivHelpContents();
}
public editDivHelpContent(id : string) {
//this.router.navigate(['/pageContents/edit/', _id]);
if(this.selectedPageId) {
this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "community": this.selectedCommunityPid, "pageId": this.selectedPageId } } );
} else {
this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "community": this.selectedCommunityPid } } );
}
}
public toggleDivHelpContents(status : boolean, ids : string[]) {
this._helpService.toggleDivHelpContents(ids,status).subscribe(
() => {
for(let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
console.info(i);
this.checkboxes[i].divHelpContent.isActive=status;
}
this.countDivHelpContents();
this.applyCheck(false);
},
error => this.handleError('System error changing the status of the selected page content(s)', error)
);
}
public saveDivHelpContent(data : any):void {
console.log(data);
this._helpService.insertOrUpdateDivHelpContent(data).subscribe(
divHelpContent => this.divHelpContentSavedSuccessfully(divHelpContent),
error => this.handleError('System error saving the specified help content', error)
);
}
public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) {
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent : divHelpContent, checked : false});
this.divHelpContents.push(divHelpContent);
this.applyCheck(false);
this.countDivHelpContents();
}
public divHelpContentUpdatedSuccessfully(divHelpContent : DivHelpContent) {
this.checkboxes.find(checkItem => checkItem.divHelpContent._id==divHelpContent._id).divHelpContent = divHelpContent;
let index = this.divHelpContents.findIndex(checkItem => checkItem._id==divHelpContent._id);
this.divHelpContents[index] = divHelpContent;
this.applyCheck(false);
this.countDivHelpContents();
}
public filterDivHelpContent(divHelpContent : DivHelpContent, filters : DivHelpContentFilterOptions) : boolean {
let divId: DivId = divHelpContent.divId as DivId;
let idFlag = filters.id == '' || (<Page>divId.page)._id == filters.id;
let activeFlag = filters.active == null || divHelpContent.isActive == filters.active;
let textFlag = filters.text.toString() == '' || (divHelpContent.content).match(filters.text) != null;
return idFlag && activeFlag && textFlag;
}
public applyFilter() {
this.checkboxes = [];
this.divHelpContents.filter(item => this.filterDivHelpContent(item,this.filters)).forEach(
_ => this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false})
);
this.countDivHelpContents();
}
public filterByPage(event: any) {
this.filters.id = event.target.value;
this.applyFilter();
}
public displayAllDivHelpContents() {
this.filters.active = null;
this.applyFilter();
}
public displayActiveDivHelpContents() {
this.filters.active = true;
this.applyFilter();
}
public filterBySearch(text : string) {
this.filters.text = new RegExp(text, "i");
this.applyFilter();
}
public displayInactiveDivHelpContents() {
this.filters.active = false;
this.applyFilter();
}
handleError(message: string, error) {
if(error == null) {
// this.formComponent.reset();
}
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
public filterByCommunity(event: any) {
this.selectedCommunityPid = event.target.value;
this.applyCommunityFilter(this.selectedCommunityPid);
}
public applyCommunityFilter(community_pid: string) {
this.getPages(community_pid);
this.getDivHelpContents(community_pid);
}
}

View File

@ -0,0 +1,21 @@
<div id="editDivHelpContent">
<div id="content">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<div class="page-title">Edit Class Content</div>
</div>
<div class="content-wrapper">
<div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<div-content-form [communityPid]="communityPid" [pageId]="pageId" [group]="formGroup"></div-content-form>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Update class content</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,99 @@
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
import { DivContentFormComponent } from "./div-help-content-form.component";
import { Subscription } from "rxjs/Subscription";
import { HelpContentService } from "../../services/help-content.service";
import { DivHelpContent } from "../../domain/div-help-content";
import { ActivatedRoute, Router } from "@angular/router";
@Component({
selector: 'edit-div-help-content',
templateUrl: 'edit-div-help-content.component.html',
})
export class EditDivHelpContentComponent implements OnInit, OnDestroy{
@ViewChild(DivContentFormComponent)
public formComponent : DivContentFormComponent;
private communityPid: string;
private pageId: string;
private sub: Subscription;
private divHelpContent: DivHelpContent;
private errorMessage : string = null;
constructor(
private route: ActivatedRoute,
private router: Router,
private _helpContentService: HelpContentService) {}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => {
//let id = params['id'];
let divContentId = params['classContentId'];
this.communityPid = params['community'];
this.pageId = params['pageId'];
this._helpContentService.getDivHelpContent(divContentId as string).subscribe(
divHelpContent => this.updateForm(divHelpContent),
error => this.handleError('System error retrieving class help content', error));
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
handleError(message: string, error) {
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
getDivId(divId: string) {
this._helpContentService.getDivId(divId).subscribe(
divId => {
this.formComponent.pageId = divId.page;
this.formComponent.getDivs(this.formComponent.pageId);
},
error => this.handleError('System error retrieving class', error)
);
}
private updateForm(divHelpContent : DivHelpContent) {
this.divHelpContent = divHelpContent;
console.info(divHelpContent);
if(!this.pageId) {
this.getDivId(divHelpContent.divId as string);
}
this.formComponent.myForm.patchValue((divHelpContent));
// console.log("patching",pageHelpContent);
}
private saveCustom() {
if(this.formComponent.myForm.valid) {
let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent).subscribe(
_ => {
if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );
} else {
this.router.navigate(['/classContents']);
}
},
err => this.handleError('System error updating class content', err)
);
} else {
this.errorMessage = "Please fill all required fields";
}
}
private cancelCustom() {
if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );
} else {
this.router.navigate(['/classContents']);
}
}
}

View File

@ -0,0 +1,21 @@
<div id="newDivHelpContent">
<div id="content">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<div class="page-title">New Class Content</div>
</div>
<div class="content-wrapper">
<div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<div-content-form [communityPid]="communityPid" [pageId]="pageId" [group]="formGroup"></div-content-form>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Save class content</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,69 @@
import { Component, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router";
import { DivContentFormComponent } from "./div-help-content-form.component";
import { DivHelpContent } from "../../domain/div-help-content";
import { HelpContentService } from "../../services/help-content.service";
@Component({
selector: 'new-div-help-content',
templateUrl: 'new-div-help-content.component.html',
})
export class NewDivHelpContentComponent {
@ViewChild(DivContentFormComponent)
public formComponent : DivContentFormComponent;
private errorMessage : string = null;
private communityPid: string;
private pageId: string;
constructor(
private route: ActivatedRoute,
private router: Router,
private _helpContentService: HelpContentService) {}
ngOnInit() {
this.route.queryParams.subscribe(params => {
this.communityPid = params['community'];
this.pageId = params['pageId'];
});
}
private saveCustom() {
this.errorMessage = null;
if(this.formComponent.myForm.valid) {
let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent).subscribe(
_ => {
if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );
} else {
this.router.navigate(['/classContents']);
}
},
err => this.handleError('System error saving page content', err)
);
} else {
this.errorMessage = "Please fill all required fields";
}
}
private cancelCustom() {
if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );
} else {
this.router.navigate(['/classContents']);
}
}
handleError(message: string, error) {
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
}

View File

@ -77,7 +77,7 @@
<div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
</div>
<template [ngIf]="questionsCheckboxes && questionsCheckboxes.length>0">
<ng-template [ngIf]="questionsCheckboxes && questionsCheckboxes.length>0">
<div *ngFor="let check of questionsCheckboxes; let i=index" class="row user">
<div class="col-sm-1 avatar"><input id="{{check.question._id}}" class="checkBox" type="checkbox"
name="questionscb[]" value="{{check.question._id}}" [(ngModel)]="check.checked">
@ -125,7 +125,7 @@
</div>
</div>
</div>
</template>
</ng-template>
<div *ngIf="questionsCheckboxes.length==0" class="col-md-12">
<div class="alert alert-warning">No questions found</div>
</div>

View File

@ -55,7 +55,7 @@
<div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
</div>
<template [ngIf]="topicsCheckboxes && topicsCheckboxes.length>0">
<ng-template [ngIf]="topicsCheckboxes && topicsCheckboxes.length>0">
<div *ngFor="let check of topicsCheckboxes; let i=index" class="row user">
<div class="col-sm-1 avatar"><input id="{{check.topic._id}}" class="checkBox" type="checkbox"
name="topicscb[]" value="{{check.topic._id}}" [(ngModel)]="check.checked">
@ -83,7 +83,7 @@
</div>
</div>
</div>
</template>
</ng-template>
<div *ngIf="topicsCheckboxes.length==0" class="col-md-12">
<div class="alert alert-warning">No topics found</div>
</div>

View File

@ -13,7 +13,7 @@
<div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<page-content-form [communityPid]="communityPid" [pageId]="pageId" [group]="formGroup"></page-content-form>
<button (click)="cancelCustom()" class="uk-button uk-button-link">Cancel</button>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Update page content</button>
</div>
</div>

View File

@ -55,6 +55,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
private updateForm(pageHelpContent : PageHelpContent) {
this.pageHelpContent = pageHelpContent;
console.info(pageHelpContent);
this.formComponent.myForm.patchValue((pageHelpContent));
// console.log("patching",pageHelpContent);
}

View File

@ -5,7 +5,7 @@
<div class="entity-title uk-article-title ">Entities</div>
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Entity name..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button uk-button-default" type="submit">Search</button>
<button class="uk-button" type="submit">Search</button>
</form>
<a (click)="showModal()" class="uk-button uk-button-primary uk-float-right"><i></i> New Entity </a>
</div>
@ -22,7 +22,7 @@
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button uk-button-default" type="button"> Bulk Actions</button>
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="toggleEntities(true, getSelectedEntities())"><i></i> Activate </a></li>
@ -110,7 +110,12 @@
[isModalShown]="isModalShown" (emmitObject)="entityUpdatedSuccessfully($event)" (emmitError)="handleError($event)">
<entity-form [group]="formGroup"></entity-form>
</modal-form>
<modal-form #okModal [saveText]="'OK'" [titleText]="'Warning'" [type]="'none'"
[isModalShown]="isModalShown" (emmitObject)="continueToggling($event)" (emmitError)="handleError($event)">
This action will affect all search pages related to this entity!
Pages' status will change to entity's status!
Do you want to continue?
<modal-form>
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteEntities($event)">
Are you sure you want to delete the selected entity(-ies)?
</delete-confirmation-dialog>

View File

@ -40,6 +40,10 @@ export class EntitiesComponent implements OnInit {
public communities: Community[] = [];
public selectedCommunityPid: string;
@ViewChild('okModal')
public okModal:ModalFormComponent;
public toggleIds: string[];
public toggleStatus: boolean;
ngOnInit() {
this.getCommunities();
@ -167,16 +171,22 @@ export class EntitiesComponent implements OnInit {
}
public toggleEntities(status : boolean, ids : string[]) {
this._helpContentService.toggleEntities(this.selectedCommunityPid,ids,status).subscribe(
() => {
for(let id of ids) {
let i = this.checkboxes.findIndex(_ => _.entity._id == id);
this.checkboxes[i].entity.isEnabled=status;
}
this.applyCheck(false);
},
error => this.handleError('System error changing the status of the selected entity(-ies)', error)
);
this.okModal.showModal();
this.toggleIds = ids;
this.toggleStatus = status;
}
public continueToggling(event: any) {
this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus).subscribe(
() => {
for(let id of this.toggleIds) {
let i = this.checkboxes.findIndex(_ => _.entity._id == id);
this.checkboxes[i].entity.isEnabled=this.toggleStatus;
}
this.applyCheck(false);
},
error => this.handleError('System error changing the status of the selected entity(-ies)', error)
);
}
}

View File

@ -13,7 +13,7 @@
<div>
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert>{{errorMessage}}</div>
<page-content-form [communityPid]="communityPid" [pageId]="pageId" [group]="formGroup"></page-content-form>
<button (click)="cancelCustom()" class="uk-button uk-button-link">Cancel</button>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Save page content</button>
</div>
</div>

View File

@ -38,6 +38,14 @@
<label for="orderTag">Order</label>
<input type="text" step="1" class="form-control" formControlName="order" id="orderTag" placeholder="Order (e.g. 2)">
</div>
<div class="form-group">
<label>Help Content before existing content</label>
<label class="checkbox">
<span style="font-weight: normal;">Before</span>
<input tabindex="0" type="checkbox" formControlName="isPriorTo">
</label>
</div>
<div class="form-group">
<label>Select Status</label>
<label class="checkbox">

View File

@ -43,6 +43,7 @@ export class PageContentFormComponent implements OnInit{
content : ['', Validators.required],
order : ['1', Validators.required],
isActive : true,
isPriorTo : false,
_id : '',
});
}
@ -55,6 +56,7 @@ export class PageContentFormComponent implements OnInit{
content : [''],
order : '1',
isActive : true,
isPriorTo : false,
_id : ''
});
this.myForm.markAsPristine();

View File

@ -148,7 +148,7 @@
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Page Help Content..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button uk-button-default" type="submit">Search</button>
<button class="uk-button" type="submit">Search</button>
</form>
<a *ngIf="!selectedPageId" [queryParams]="{community: selectedCommunityPid}" routerLink="/pageContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
<a *ngIf="selectedPageId" [queryParams]="{community: selectedCommunityPid, pageId: selectedPageId}" routerLink="/pageContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
@ -166,7 +166,7 @@
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button uk-button-default" type="button"> Bulk Actions</button>
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="togglePageHelpContents(true,getSelectedPageHelpContents())"><i></i> Activate </a></li>
@ -223,6 +223,7 @@
<th>Content</th>
<th>Placement</th>
<th>Order</th>
<th>Before</th>
<th>Active</th>
<th>Actions</th>
</tr>
@ -239,7 +240,7 @@
<div class="community" href="#">{{check.pageHelpContent.community.name}}</div>
</td>
<td>
<div class="content" href="#">{{check.pageHelpContent.content}}</div>
<div class="content" href="#" [innerHtml]="check.pageHelpContent.content"></div>
</td>
<td>
<div class="placement" href="#">{{check.pageHelpContent.placement}}</div>
@ -248,6 +249,10 @@
<div class="order" href="#">{{check.pageHelpContent.order}}
</div>
</td>
<td>
<div class="isPriorTo" href="#">{{check.pageHelpContent.isPriorTo}}
</div>
</td>
<td>
<div *ngIf="check.pageHelpContent.isActive" class="activated" >
<input (click)="togglePageHelpContents(false,[check.pageHelpContent._id])" class="deactivate" src="imgs/check-icon.png" title="Deactivate" width="20" type="image" height="20">

View File

@ -196,6 +196,7 @@ export class PageHelpContentsComponent implements OnInit {
this.checkboxes.splice(iqc, 1);
this.pageHelpContents.splice(iqc, 1);
}
this.countPageHelpContents();
}
public editPageHelpContent(id : string) {

View File

@ -142,7 +142,7 @@
<div class="page-title uk-article-title ">Pages</div>
<form target="BSFormPanel_Admin_1" class="search">
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Page name..." type="text" class="uk-input uk-width-medium"/>
<button class="uk-button uk-button-default" type="submit">Search</button>
<button class="uk-button" type="submit">Search</button>
</form>
<a (click)="showModal()" class="uk-button uk-button-primary uk-float-right"><i></i> New Page </a>
</div>
@ -159,7 +159,7 @@
<div class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button uk-button-default" type="button"> Bulk Actions</button>
<button class="uk-button" type="button"> Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav">
<li><a (click)="togglePages(true, getSelectedPages())"><i></i> Activate </a></li>
@ -195,7 +195,8 @@
<th>Related Entities</th>
<th>Route</th>
<th>Actions</th>
<th>Help Contents</th>
<th>Page Help Contents</th>
<th *ngIf="pageWithDivIds && pageWithDivIds.length > 0">Class Help Contents</th>
</tr>
</thead>
<tbody >
@ -233,7 +234,11 @@
</div>
</td>
<td>
<a class="helpContents" [queryParams]="{community: selectedCommunityPid, page: check.page._id}" routerLink="/pageContents">add contents</a>
<a class="helpContents" [queryParams]="{community: selectedCommunityPid, page: check.page._id}" routerLink="/pageContents">add page contents</a>
</td>
<td *ngIf="pageWithDivIds && pageWithDivIds.length > 0" class="uk-text-center">
<a *ngIf="pageWithDivIds.includes(check.page._id)" class="classHelpContents" [queryParams]="{community: selectedCommunityPid, page: check.page._id}" routerLink="/classContents">add class contents</a>
<span *ngIf="!pageWithDivIds.includes(check.page._id)">-</span>
</td>
</tr>
</tbody>

View File

@ -35,6 +35,7 @@ export class PagesComponent implements OnInit {
public checkboxes : CheckPage[] = [];
public pages : Page[] = [];
public pageWithDivIds: string[] = [];
public errorMessage: string;
@ -81,6 +82,15 @@ export class PagesComponent implements OnInit {
}
}
getPagesWithDivIds(community_pid: string) {
let self = this;
this._helpContentService.getPagesWithDivIds(community_pid).subscribe(
pages => {
self.pageWithDivIds = pages[community_pid];
},
error => this.handleError('System error retrieving pages', error));
}
pagesReturned(pages: Page[]) {
this.pages = pages;
this.checkboxes = [];
@ -97,6 +107,7 @@ export class PagesComponent implements OnInit {
self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid;
self.getPages(self.selectedCommunityPid);
self.getPagesWithDivIds(self.selectedCommunityPid);
},
error => this.handleError('System error retrieving communities', error));
}
@ -199,6 +210,7 @@ export class PagesComponent implements OnInit {
public applyCommunityFilter(community_pid: string) {
this.getPages(community_pid);
this.getPagesWithDivIds(community_pid);
}
public togglePages(status : boolean, ids : string[]) {

View File

@ -14,7 +14,8 @@
<div class="modal-footer">
<div class="confirmationModalButtons">
<a (click)="hideModal()" class="btn"><i></i> Cancel </a>
<a (click)="saveCustom(formGroup.value)" class="btn btn-success"><i></i> {{saveText}} </a>
<a *ngIf="formGroup" (click)="saveCustom(formGroup.value)" class="btn btn-success"><i></i> {{saveText}} </a>
<a *ngIf="!formGroup" (click)="saveCustom(null)" class="btn btn-success"><i></i> {{saveText}} </a>
</div>
</div>
</div>

View File

@ -11,6 +11,7 @@ import { HelpContentService } from "../services/help-content.service";
import { Page } from "../domain/page";
import { Entity } from "../domain/entity";
import { Community } from "../domain/community";
import { DivId } from "../domain/divId";
@Component({
selector: 'modal-form',
@ -60,59 +61,76 @@ export class ModalFormComponent {
}
public saveCustom(obj : any) {
if(!this.formGroup.valid) {
this.errorMessage = "Please fill in all required fields marked with *"
if (this.type == 'none') {
this.emmitObject.emit(true);
this.hideModal();
} else {
if(!this.formGroup.valid) {
this.errorMessage = "Please fill in all required fields marked with *"
} else {
if (this.type == 'topic') {
this._faqService.saveTopic(<Topic> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if (this.type == 'question') {
this._faqService.saveQuestion(<Question> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if (this.type == 'community') {
if(this.saveText == 'Update') {
this._helpService.updateCommunity(<Community> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
if (this.type == 'topic') {
this._faqService.saveTopic(<Topic> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
console.info(<Community> obj);
} else if (this.type == 'question') {
this._faqService.saveQuestion(<Question> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if (this.type == 'community') {
if(this.saveText == 'Update') {
this._helpService.updateCommunity(<Community> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
console.info(<Community> obj);
} else if(this.saveText == 'Save') {
this._helpService.saveCommunity(<Community> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
console.info(<Community> obj);
}
} else if (this.type == 'page') {
if(this.saveText == 'Update') {
this._helpService.updatePage(<Page> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.savePage(<Page> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'entity') {
if(this.saveText == 'Update') {
this._helpService.updateEntity(<Entity> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveEntity(<Entity> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if(this.saveText == 'Save') {
this._helpService.saveCommunity(<Community> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
console.info(<Community> obj);
}
} else if (this.type == 'page') {
if(this.saveText == 'Update') {
this._helpService.updatePage(<Page> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.savePage(<Page> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'entity') {
if(this.saveText == 'Update') {
this._helpService.updateEntity(<Entity> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveEntity(<Entity> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'divId') {
if(this.saveText == 'Update') {
this._helpService.updateDivId(<DivId> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveDivId(<DivId> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
}
}
this.hideModal();
}

View File

@ -8,7 +8,8 @@ import { Page } from "../domain/page";
import { PageHelpContent } from "../domain/page-help-content";
import { Community } from "../domain/community";
import { Entity } from "../domain/entity";
import { DivId } from "../domain/divId";
import { DivHelpContent } from "../domain/div-help-content";
@Injectable()
export class HelpContentService {
@ -26,6 +27,113 @@ export class HelpContentService {
}
}
getDivIdsFull(community_pid: string, page_id: string) {
if(page_id) {
return this.http.get(this._helpContentUrl + 'divFull?community='+community_pid+'&page='+page_id)
.map(res => <Array<DivId>> res.json())
.catch(this.handleError);
} else {
return this.http.get(this._helpContentUrl + 'divFull?community='+community_pid)
.map(res => <Array<DivId>> res.json())
.catch(this.handleError);
}
}
updateDivId(divId: DivId) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divId);
return this.http.post(this._helpContentUrl + 'div/update', JSON.stringify(divId), options)
.map(res => <DivId> res.json())
.catch(this.handleError);
}
getDivId(divId: string) {
return this.http.get(this._helpContentUrl + 'div/'+divId)
.map(res => <DivId> res.json())
.catch(this.handleError);
}
saveDivId(divId: DivId) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divId);
return this.http.post(this._helpContentUrl + 'div/save', JSON.stringify(divId), options)
.map(res => <DivId> res.json())
.catch(this.handleError);
}
getCommunitiesWithDivId() {
return this.http.get(this._helpContentUrl + 'community?div=true')
.map(res => <Array<Community>> res.json())
.catch(this.handleError);
}
getCommunityPagesWithDivId(community_pid: string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages?div=true')
.map(res => <Array<Page>> res.json())
.catch(this.handleError);
}
getCommunityDivHelpContents(community_pid: string) {
return this.http.get(this._helpContentUrl + 'divhelpcontent?community='+community_pid)
.map(res => <Array<DivHelpContent>> res.json())
.catch(this.handleError);
}
getDivHelpContent(id : string) {
return this.http.get(this._helpContentUrl + 'divhelpcontent/' + id)
.map(res => <DivHelpContent> res.json())
.catch(this.handleError);
}
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divHelpContent);
return this.http.post(this._helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), options)
.map(res => <DivHelpContent> res.json())
.catch(this.handleError);
}
deleteDivIds(ids : string[]) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'div/delete',JSON.stringify(ids), options)
.catch(this.handleError);
}
deleteDivHelpContents(ids : string[]) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), options)
.catch(this.handleError);
}
toggleDivHelpContents(ids : string[],status : boolean) {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options)
//.map( res => <string[]> res.json())
.catch(this.handleError);
}
getPagesWithDivIds(community_pid: string) {
return this.http.get(this._helpContentUrl + 'div/pages?communtity='+community_pid)
.map(res => <Map<string, Set<string>>> res.json())
.catch(this.handleError);
}
getPages() {
return this.http.get(this._helpContentUrl + 'page')
.map(res => <Array<Page>> res.json())

View File

@ -9,7 +9,7 @@
"deploy:server": "docker rm -f omtd-platform && docker run --name omtd-platform -d -p 80:80 omtd-platform",
"deploy:complete": "npm run build:docker && npm run deploy:server",
"watch": "npm run build --watch",
"server": "webpack-dev-server --inline --progress --port 5000 --content-base . --disable-host-check --host 0.0.0.0",
"server": "webpack-dev-server --inline --progress --port 3000 --content-base . --disable-host-check --host 0.0.0.0",
"start": "npm run server "
},
"license": "ISC",