-
{{errorMessage}}
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
{{check.pageHelpContent.page.name}}
-
-
-
{{check.pageHelpContent.content|htmlToString}}
-
-
-
- Placement: {{check.pageHelpContent.placement}}
-
-
- Order: {{check.pageHelpContent.order}}
-
-
- Enable/disable:
-
-
-
-
-
+
+
0" class="uk-list pages">
+ -
+
+
+
+
+
+
+
+
{{check.pageHelpContent.page.name}}
-
-
-
-
-
-
-
- Edit
-
-
-
-
-
- Delete
-
-
-
-
+
+
{{check.pageHelpContent.content|htmlToString}}
+
+
+
+ Placement: {{check.pageHelpContent.placement}}
+
+
+ Order: {{check.pageHelpContent.order}}
+
+
+ Enable/disable:
+
-
-
-
-
-
No page contents found
-
+
+
+
+
+
+
+
+
+
+ Edit
+
+
+
+
+
+ Delete
+
+
+
+
+
-
+
+
+
-
-
+
+
diff --git a/dashboard/helpTexts/page-help-contents.component.ts b/dashboard/helpTexts/page-help-contents.component.ts
index 855288f7..3758a1be 100644
--- a/dashboard/helpTexts/page-help-contents.component.ts
+++ b/dashboard/helpTexts/page-help-contents.component.ts
@@ -19,52 +19,37 @@ import {DomSanitizer} from '@angular/platform-browser';
import {SearchInputComponent} from '../../sharedComponents/search-input/search-input.component';
import {ConnectHelper} from '../../connect/connectHelper';
+declare var UIkit;
@Component({
selector: 'page-help-contents',
templateUrl: './page-help-contents.component.html',
})
export class PageHelpContentsComponent implements OnInit {
-
@ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents;
private selectedPageContents: string[] = [];
-
public checkboxes: CheckPageHelpContent[] = [];
-
public pageHelpContents: PageHelpContent[] = [];
-
public formGroup: FormGroup;
-
public pages: Page[];
-
public checkboxAll: boolean = false;
-
public filters: PageHelpContentFilterOptions = {id: '', active: null, text: new RegExp('')};
public keyword: string = "";
-
public counter = {all: 0, active: 0, inactive: 0};
-
public communities: Portal[] = [];
-
public portal: string;
-
public selectedPageId: string;
-
public community: Portal;
-
public page: Page;
- public properties: EnvProperties = null;
-
+ public properties: EnvProperties = properties;
public showLoading: boolean = true;
- public errorMessage: string = '';
- public updateErrorMessage: string = '';
public filterForm: FormControl;
public selectForm: FormControl;
public selectOptions = [];
private subscriptions: any[] = [];
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
-
+
ngOnInit() {
this.filterForm = this._fb.control('');
this.selectForm = this._fb.control('');
@@ -74,8 +59,6 @@ export class PageHelpContentsComponent implements OnInit {
this.subscriptions.push(this.selectForm.valueChanges.subscribe(value => {
this.filterByPage(value);
}));
-
- this.properties = properties;
this.subscriptions.push(this.route.params.subscribe(params => {
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
ConnectHelper.setPortalTypeFromPid(this.portal);
@@ -85,15 +68,16 @@ export class PageHelpContentsComponent implements OnInit {
if (this.portal && this.selectedPageId) {
this.getPage(this.selectedPageId);
}
- if(!this.selectedPageId) {
- this.router.navigate(['../pages'], {relativeTo: this.route });
+ if (!this.selectedPageId) {
+ this.router.navigate(['../pages'], {relativeTo: this.route});
}
}));
}));
}
-
+
constructor(private element: ElementRef, private route: ActivatedRoute, private router: Router, private _helpService: HelpContentService, private _fb: FormBuilder, private sanitizer: DomSanitizer) {
}
+
ngOnDestroy(): void {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
@@ -103,9 +87,7 @@ export class PageHelpContentsComponent implements OnInit {
}
});
}
- init(){
-
- }
+
getPage(pageId: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -116,12 +98,10 @@ export class PageHelpContentsComponent implements OnInit {
});
} else {
this.showLoading = true;
- this.updateErrorMessage = "";
- this.errorMessage = "";
this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal).subscribe(
page => {
if (this.properties.adminToolsPortalType != page.portalType) {
- this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.portal}});
+ this.router.navigate(['./pageContents']);
} else {
this.page = page;
this.getPageHelpContents(this.portal);
@@ -130,7 +110,7 @@ export class PageHelpContentsComponent implements OnInit {
error => this.handleError('System error retrieving page', error)));
}
}
-
+
getPages(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -141,23 +121,20 @@ export class PageHelpContentsComponent implements OnInit {
});
} else {
this.showLoading = true;
- this.updateErrorMessage = "";
- this.errorMessage = "";
-
//this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
- 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 => {
this.pages = pages;
this.getPageHelpContents(this.portal);
- this.selectOptions = [{label:'All pages', value: ''}];
+ this.selectOptions = [{label: 'All pages', value: ''}];
for (let page of this.pages) {
- this.selectOptions.push({label:page.name, value: page._id})
+ this.selectOptions.push({label: page.name, value: page._id})
}
},
error => this.handleError('System error retrieving pages', error)));
}
}
-
+
public countPageHelpContents() {
this.counter = {all: 0, active: 0, inactive: 0};
let filter = Object.assign({}, this.filters);
@@ -170,7 +147,7 @@ export class PageHelpContentsComponent implements OnInit {
});
this.counter.all = this.counter.active + this.counter.inactive;
}
-
+
getPageHelpContents(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -185,55 +162,51 @@ export class PageHelpContentsComponent implements OnInit {
this.pageHelpContents = pageHelpContents as Array
;
this.counter.all = this.pageHelpContents.length;
this.checkboxes = [];
-
+
for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
- this.checkboxes.unshift({
- pageHelpContent: this.pageHelpContents[i],
- checked: false
- });
+ this.checkboxes.unshift({
+ pageHelpContent: this.pageHelpContents[i],
+ checked: false
+ });
}
-
+
this.countPageHelpContents();
-
+
this.showLoading = false;
},
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 getSelectedPageHelpContents(): string[] {
return this.checkboxes.filter(pageHelpContent => pageHelpContent.checked == true)
.map(checkedPageHelpContent => checkedPageHelpContent.pageHelpContent).map(res => res._id);
}
-
+
public confirmDeletePageHelpContent(id: string) {
//this.deleteConfirmationModal.ids = [id];
//this.deleteConfirmationModal.showModal();
this.selectedPageContents = [id];
this.confirmModalOpen();
}
-
+
public confirmDeleteSelectedPageHelpContents() {
//this.deleteConfirmationModal.ids = this.getSelectedPageHelpContents();
//this.deleteConfirmationModal.showModal();
this.selectedPageContents = this.getSelectedPageHelpContents();
this.confirmModalOpen();
}
-
+
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -251,7 +224,7 @@ export class PageHelpContentsComponent implements OnInit {
this.alertModalDeletePageHelpContents.open();
}
}
-
+
public confirmedDeletePageHelpContents(data: any) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -262,18 +235,21 @@ export class PageHelpContentsComponent implements OnInit {
});
} else {
this.showLoading = true;
- this.updateErrorMessage = "";
-
this.subscriptions.push(this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.portal).subscribe(
_ => {
this.deletePageHelpContentsFromArray(this.selectedPageContents);
+ UIkit.notification('Page content(s) has been successfully deleted', {
+ status: 'success',
+ timeout: 6000,
+ pos: 'bottom-right'
+ });
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected page content(s)', error)
));
}
}
-
+
private deletePageHelpContentsFromArray(ids: string[]): void {
for (let id of ids) {
let iqc = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
@@ -283,27 +259,25 @@ export class PageHelpContentsComponent implements OnInit {
}
this.countPageHelpContents();
}
-
+
public editPageHelpContent(id: string) {
//this.router.navigate(['/pageContents/edit/', _id]);
if (this.selectedPageId) {
this.router.navigate(['edit/'], {
queryParams: {
"pageContentId": id,
- "communityId": this.portal,
"pageId": this.selectedPageId
}, relativeTo: this.route
});
} else {
this.router.navigate(['edit/'], {
queryParams: {
- "pageContentId": id,
- "communityId": this.portal
+ "pageContentId": id``
}, relativeTo: this.route
});
}
}
-
+
public togglePageHelpContents(status: boolean, ids: string[]) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
@@ -313,14 +287,17 @@ export class PageHelpContentsComponent implements OnInit {
}
});
} else {
- this.updateErrorMessage = "";
-
this.subscriptions.push(this._helpService.togglePageHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe(
() => {
for (let id of ids) {
let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
this.checkboxes[i].pageHelpContent.isActive = status;
}
+ UIkit.notification('Page content(s) has been successfully updated', {
+ status: 'success',
+ timeout: 6000,
+ pos: 'bottom-right'
+ });
this.countPageHelpContents();
this.applyCheck(false);
},
@@ -328,14 +305,14 @@ export class PageHelpContentsComponent implements OnInit {
));
}
}
-
+
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
this.checkboxes.push({pageHelpContent: pageHelpContent, checked: false});
this.pageHelpContents.push(pageHelpContent);
this.applyCheck(false);
this.countPageHelpContents();
}
-
+
public pageHelpContentUpdatedSuccessfully(pageHelpContent: PageHelpContent) {
this.checkboxes.find(checkItem => checkItem.pageHelpContent._id == pageHelpContent._id).pageHelpContent = pageHelpContent;
let index = this.pageHelpContents.findIndex(checkItem => checkItem._id == pageHelpContent._id);
@@ -343,8 +320,8 @@ export class PageHelpContentsComponent implements OnInit {
this.applyCheck(false);
this.countPageHelpContents();
}
-
-
+
+
public filterPageHelpContent(pageHelpContent: PageHelpContent, filters: PageHelpContentFilterOptions): boolean {
let idFlag = filters.id == '' || (pageHelpContent.page)._id == filters.id;
let activeFlag = filters.active == null || pageHelpContent.isActive == filters.active;
@@ -352,8 +329,8 @@ export class PageHelpContentsComponent implements OnInit {
|| ((pageHelpContent.page).name).match(filters.text) != null;
return idFlag && activeFlag && textFlag;
}
-
-
+
+
public applyFilter() {
this.checkboxes = [];
this.pageHelpContents.filter(item => this.filterPageHelpContent(item, this.filters)).forEach(
@@ -363,68 +340,75 @@ export class PageHelpContentsComponent implements OnInit {
);
// this.countPageHelpContents();
}
-
+
public filterByPage(event: any) {
- if(event.target && event.target.value) {
+ if (event.target && event.target.value) {
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) {
- this.errorMessage = message;
+ UIkit.notification(message, {
+ status: 'danger',
+ timeout: 6000,
+ pos: 'bottom-right'
+ });
console.log('Server responded: ' + error);
-
this.showLoading = false;
}
-
+
handleUpdateError(message: string, error) {
- this.updateErrorMessage = message;
+ UIkit.notification(message, {
+ status: 'danger',
+ timeout: 6000,
+ pos: 'bottom-right'
+ });
console.log('Server responded: ' + error);
-
this.showLoading = false;
}
-
+
public newPageContent() {
- this.router.navigate(['edit'], {
- queryParams: {
- pageId: this.selectedPageId
- }, relativeTo: this.route
- });
+ this.router.navigate(['edit'], {
+ queryParams: {
+ pageId: this.selectedPageId
+ }, relativeTo: this.route
+ });
}
-
+
public onSearchClose() {
this.selectedKeyword = this.filterForm.value;
}
-
+
public reset() {
this.selectedKeyword = null;
this.searchInputComponent.reset()
}
- selectAll(){
- let checked = !!(this.getSelectedPageHelpContents().length != this.checkboxes.length);
- for (let check of this.checkboxes) {
- check.checked = checked;
- }
+
+ selectAll() {
+ let checked = (this.getSelectedPageHelpContents().length != this.checkboxes.length);
+ for (let check of this.checkboxes) {
+ check.checked = checked;
+ }
}
}
diff --git a/dashboard/page/pages.component.html b/dashboard/page/pages.component.html
index 8adcc58b..63b204f5 100644
--- a/dashboard/page/pages.component.html
+++ b/dashboard/page/pages.component.html
@@ -1,7 +1,7 @@
-
+
-
-
+
+ [bordered]="true" colorClass="uk-text-secondary"
+ class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1">
-
+
-
-
-
- {{updateErrorMessage}}
-
-
{{errorMessage}}
-
-
-
-
- -
-
-
-
-
-
Name
-
{{check.page.name}}
-
0">Entities:
- {{getEntitiesAsString(check.page)}}
-
Route: {{check.page.route}}
-
Type: {{check.page.type}}
-
- Portal type: {{check.page.portalType}}
-
-
-
-
0" class="uk-list pages">
+
-
+
+
+
+
+
Name
+
{{check.page.name}}
+
0">Entities:
+ {{getEntitiesAsString(check.page)}}
+
Route: {{check.page.route}}
+
Type: {{check.page.type}}
+
+ Portal type: {{check.page.portalType}}
+
+
+
+
-
-
-
-
-
-
-
No pages found
+
Helptexts
+
+
+
+
-
+
+
+
+
-
- {{ modalErrorMessage }}