From f6f86634ce3f19ba61ccd16ca602ccd465161c3e Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 24 Jul 2019 09:16:42 +0000 Subject: [PATCH] [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 --- src/app/app.component.ts | 12 +++-- .../div-help-content-form.component.html | 18 ++++--- .../div-help-content-form.component.ts | 4 +- .../div-help-contents.component.html | 4 +- .../div-help-contents.component.ts | 7 +++ .../edit-div-help-content.component.html | 2 +- .../edit-div-help-content.component.ts | 25 ++++++++++ .../new-div-help-content.component.html | 2 +- .../new-div-help-content.component.ts | 41 ++++++++++++++-- .../edit-page-help-content.component.html | 4 +- .../edit-page-help-content.component.ts | 36 ++++++++++++-- .../new-page-help-content.component.html | 4 +- .../new-page-help-content.component.ts | 49 ++++++++++++++++--- .../page-help-content-form.component.html | 2 +- .../page-help-content-form.component.ts | 33 ++++++------- .../page-help-contents.component.html | 4 +- .../page-help-contents.component.ts | 15 ++++-- src/app/pages/page/pages.component.html | 6 ++- src/app/services/help-content.service.ts | 37 +++++++++----- src/assets/env-properties.json | 2 +- 20 files changed, 232 insertions(+), 75 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2dce8f3..1f0d947 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -314,11 +314,13 @@ export class AppComponent implements OnInit{ '/pageContents', false, [], [], {communityId: this.communityId}), items: [] }); - help.items.push({ - rootItem: new MenuItem('classes', 'Class Help Texts', '/classContents', - '/classContents', false, [], [], {communityId: this.communityId}), - items: [] - }); + if (this.communityId === 'openaire' || this.communityId === 'connect') { + help.items.push({ + rootItem: new MenuItem('classes', 'Class Help Texts', '/classContents', + '/classContents', false, [], [], {communityId: this.communityId}), + items: [] + }); + } this.sideMenuItems.push(help); if (this.communityId !== 'openaire' && this.communityId !== 'connect') { const stats: SideMenuItem = { diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.html b/src/app/pages/divhelpcontent/div-help-content-form.component.html index 0bcda21..618a90e 100644 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.html +++ b/src/app/pages/divhelpcontent/div-help-content-form.component.html @@ -13,17 +13,21 @@
Class content displayed in page(s): {{page.name}},
- - +
+ + +
- - +
diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.ts b/src/app/pages/divhelpcontent/div-help-content-form.component.ts index cb8e54e..2fdca83 100644 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.ts +++ b/src/app/pages/divhelpcontent/div-help-content-form.component.ts @@ -113,10 +113,10 @@ export class DivContentFormComponent implements OnInit{ if(!Session.isLoggedIn()){ this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); } else { - this.showLoading = true; + //this.showLoading = true; this.errorMessage = ''; - this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( divs => { this.availableDivs = divs; this.pageId = pageId; diff --git a/src/app/pages/divhelpcontent/div-help-contents.component.html b/src/app/pages/divhelpcontent/div-help-contents.component.html index 88b9603..ee85b5f 100644 --- a/src/app/pages/divhelpcontent/div-help-contents.component.html +++ b/src/app/pages/divhelpcontent/div-help-contents.component.html @@ -2,8 +2,8 @@
diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts index e9cbfc2..a1af624 100644 --- a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts +++ b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts @@ -9,6 +9,7 @@ import { EnvProperties } from '../../openaireLibrary/utils/properties/env-proper import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Page} from "../../domain/page"; @Component({ selector: 'edit-div-help-content', @@ -22,6 +23,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ public communityPid: string; public pageId: string; + public page: Page; private sub: Subscription; @@ -51,6 +53,10 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ this.communityPid = params['communityId']; this.pageId = params['pageId']; + if(!divContentId) { + this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); + } + this.getDivHelpContent(divContentId); }); }); @@ -71,6 +77,22 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ this.showLoading = false; } + private getPage(pageId: string) { + this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + page => { + if( (this.communityPid == 'openaire' && !page.openaire) + || (this.communityPid == 'connect' && !page.connect) + || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); + } else { + this.page = page; + this.showLoading = false; + } + }, + error => this.handleError('System error retrieving page with id: '+pageId, error) + ); + } + private getDivHelpContent(divContentId: string) { if(!Session.isLoggedIn()){ this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); @@ -81,6 +103,9 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL).subscribe( divHelpContent => { + if(this.pageId) { + this.getPage(this.pageId); + } this.updateForm(divHelpContent); this.showLoading = false; }, diff --git a/src/app/pages/divhelpcontent/new-div-help-content.component.html b/src/app/pages/divhelpcontent/new-div-help-content.component.html index c786e04..954b59b 100644 --- a/src/app/pages/divhelpcontent/new-div-help-content.component.html +++ b/src/app/pages/divhelpcontent/new-div-help-content.component.html @@ -5,7 +5,7 @@
-
New class help text
+
New Class help text of page "{{page.name}}"
diff --git a/src/app/pages/divhelpcontent/new-div-help-content.component.ts b/src/app/pages/divhelpcontent/new-div-help-content.component.ts index fb191b4..4d81097 100644 --- a/src/app/pages/divhelpcontent/new-div-help-content.component.ts +++ b/src/app/pages/divhelpcontent/new-div-help-content.component.ts @@ -8,6 +8,7 @@ import { EnvProperties } from '../../openaireLibrary/utils/properties/env-proper import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Page} from "../../domain/page"; @Component({ selector: 'new-div-help-content', @@ -23,10 +24,12 @@ export class NewDivHelpContentComponent { public communityPid: string; - public pageId: string; + public pageId: string; + public page: Page; + public properties:EnvProperties = null; - public showLoading: boolean = false; + public showLoading: boolean = true; public errorMessage: string = ''; public updateErrorMessage: string = ''; @@ -45,11 +48,35 @@ export class NewDivHelpContentComponent { this.communityPid = params['communityId']; this.pageId = params['pageId']; + + + if(this.pageId) { + this.getPage(this.pageId); + } else { + this.showLoading = false; + } }); }); } - public saveCustom() { + private getPage(pageId: string) { + this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + page => { + if( (this.communityPid == 'openaire' && !page.openaire) + || (this.communityPid == 'connect' && !page.connect) + || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); + } else { + this.page = page; + this.showLoading = false; + console.info(this.page); + } + }, + error => this.handleError('System error retrieving page with id: '+pageId, error) + ); + } + + public saveCustom() { if(!Session.isLoggedIn()){ this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); } else { @@ -76,7 +103,7 @@ export class NewDivHelpContentComponent { } } - public cancelCustom() { + public cancelCustom() { if(this.pageId) { this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); } else { @@ -89,4 +116,10 @@ export class NewDivHelpContentComponent { console.log('Server responded: ' + error); this.showLoading = false; } + + handleError(message: string, error) { + this.errorMessage = message; + console.log('Server responded: ' + error); + this.showLoading = false; + } } diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.html b/src/app/pages/helpcontent/edit-page-help-content.component.html index 0f20923..8b8ca71 100644 --- a/src/app/pages/helpcontent/edit-page-help-content.component.html +++ b/src/app/pages/helpcontent/edit-page-help-content.component.html @@ -5,7 +5,7 @@
-
Edit Help Text
+
Edit help text of page "{{page.name}}"
@@ -14,7 +14,7 @@ - +
diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.ts b/src/app/pages/helpcontent/edit-page-help-content.component.ts index d9f5c12..df1120d 100644 --- a/src/app/pages/helpcontent/edit-page-help-content.component.ts +++ b/src/app/pages/helpcontent/edit-page-help-content.component.ts @@ -12,6 +12,7 @@ import { EnvProperties } from '../../openaireLibrary/utils/properties/env-proper import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Page} from "../../domain/page"; @Component({ selector: 'edit-page-help-content', @@ -23,9 +24,10 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ @ViewChild(PageContentFormComponent) public formComponent : PageContentFormComponent; - public communityPid: string; + public communityPid: string; - public pageId: string; + public pageId: string; + public page: Page; private sub: Subscription; @@ -55,6 +57,10 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.communityPid = params['communityId']; this.pageId = params['pageId']; + if(!pageContentId) { + this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); + } + this.getPageHelpContent(pageContentId); }); }); @@ -75,6 +81,23 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.showLoading = false; } + private getPage(pageId: string) { + this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + page => { + if( (this.communityPid == 'openaire' && !page.openaire) + || (this.communityPid == 'connect' && !page.connect) + || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); + } else { + this.page = page; + this.formComponent.setPlacements(this.page); + this.showLoading = false; + } + }, + error => this.handleError('System error retrieving page with id: '+pageId, error) + ); + } + private getPageHelpContent(pageContentId: string) { if(!Session.isLoggedIn()){ this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); @@ -85,8 +108,15 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe( pageHelpContent => { + if(this.pageId && this.pageId != pageHelpContent.page) { + this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); + } else if(this.pageId) { + this.getPage(this.pageId); + } else { + this.getPage(pageHelpContent.page); + } this.updateForm(pageHelpContent); - this.showLoading = false; + //this.showLoading = false; }, error => this.handleError('System error retrieving page help content', error)); } diff --git a/src/app/pages/helpcontent/new-page-help-content.component.html b/src/app/pages/helpcontent/new-page-help-content.component.html index 237b391..93cadd3 100644 --- a/src/app/pages/helpcontent/new-page-help-content.component.html +++ b/src/app/pages/helpcontent/new-page-help-content.component.html @@ -5,7 +5,7 @@ -
New help text
+
New help text of page "{{page.name}}"
@@ -15,7 +15,7 @@ - +
diff --git a/src/app/pages/helpcontent/new-page-help-content.component.ts b/src/app/pages/helpcontent/new-page-help-content.component.ts index 4ff976d..b554fca 100644 --- a/src/app/pages/helpcontent/new-page-help-content.component.ts +++ b/src/app/pages/helpcontent/new-page-help-content.component.ts @@ -11,6 +11,7 @@ import { EnvProperties } from '../../openaireLibrary/utils/properties/env-proper import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Page} from "../../domain/page"; @Component({ selector: 'new-page-help-content', @@ -26,10 +27,12 @@ export class NewPageHelpContentComponent { public communityPid: string; - public pageId: string; + public pageId: string; + public page: Page; + public properties:EnvProperties = null; - public showLoading: boolean = false; + public showLoading: boolean = true; public errorMessage: string = ''; public updateErrorMessage: string = ''; @@ -48,10 +51,34 @@ export class NewPageHelpContentComponent { this.communityPid = params['communityId']; this.pageId = params['pageId']; + + if(this.pageId) { + this.getPage(this.pageId); + } else { + this.showLoading = false; + } }); }); } + private getPage(pageId: string) { + this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + page => { + if( (this.communityPid == 'openaire' && !page.openaire) + || (this.communityPid == 'connect' && !page.connect) + || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); + } else { + this.page = page; + this.formComponent.setPlacements(this.page); + this.showLoading = false; + console.info(this.page); + } + }, + error => this.handleError('System error retrieving page with id: '+pageId, error) + ); + } + public saveCustom() { if(!Session.isLoggedIn()){ this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); @@ -87,12 +114,18 @@ export class NewPageHelpContentComponent { } else { this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} } ); } - } + } - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); + handleUpdateError(message: string, error) { + this.updateErrorMessage = message; + console.log('Server responded: ' + error); - this.showLoading = false; - } + this.showLoading = false; + } + + handleError(message: string, error) { + this.errorMessage = message; + console.log('Server responded: ' + error); + this.showLoading = false; + } } diff --git a/src/app/pages/helpcontent/page-help-content-form.component.html b/src/app/pages/helpcontent/page-help-content-form.component.html index d3ab62d..1106e65 100644 --- a/src/app/pages/helpcontent/page-help-content-form.component.html +++ b/src/app/pages/helpcontent/page-help-content-form.component.html @@ -16,7 +16,7 @@ -
+