2018-12-03 12:33:03 +01:00
|
|
|
import { Component, ViewChild, ElementRef } from '@angular/core';
|
2018-02-06 12:06:43 +01:00
|
|
|
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";
|
2018-03-06 16:36:33 +01:00
|
|
|
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
2018-02-06 12:06:43 +01:00
|
|
|
|
2018-11-13 16:26:49 +01:00
|
|
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
|
|
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
2019-04-24 13:44:46 +02:00
|
|
|
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
import {Page} from "../../domain/page";
|
2020-04-01 15:40:48 +02:00
|
|
|
import {Title} from '@angular/platform-browser';
|
2018-11-13 16:26:49 +01:00
|
|
|
|
2018-02-06 12:06:43 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'new-div-help-content',
|
|
|
|
templateUrl: 'new-div-help-content.component.html',
|
|
|
|
})
|
|
|
|
|
|
|
|
export class NewDivHelpContentComponent {
|
|
|
|
|
|
|
|
@ViewChild(DivContentFormComponent)
|
|
|
|
public formComponent : DivContentFormComponent;
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
//private errorMessage : string = null;
|
2018-02-06 12:06:43 +01:00
|
|
|
|
2019-07-10 14:55:16 +02:00
|
|
|
public communityPid: string;
|
2018-02-06 12:06:43 +01:00
|
|
|
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
public pageId: string;
|
|
|
|
public page: Page;
|
|
|
|
|
2018-03-06 16:36:33 +01:00
|
|
|
public properties:EnvProperties = null;
|
2018-02-06 12:06:43 +01:00
|
|
|
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
public showLoading: boolean = true;
|
2018-10-30 16:31:16 +01:00
|
|
|
public errorMessage: string = '';
|
|
|
|
public updateErrorMessage: string = '';
|
|
|
|
|
2018-02-06 12:06:43 +01:00
|
|
|
constructor(
|
2018-12-03 12:33:03 +01:00
|
|
|
private element: ElementRef,
|
2018-02-06 12:06:43 +01:00
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
2020-04-01 15:40:48 +02:00
|
|
|
private title: Title,
|
2018-02-06 12:06:43 +01:00
|
|
|
private _helpContentService: HelpContentService) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-03-06 16:36:33 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2018-10-30 16:31:16 +01:00
|
|
|
this.route.queryParams.subscribe(params => {
|
2019-04-24 13:44:46 +02:00
|
|
|
HelperFunctions.scroll();
|
2020-04-01 15:40:48 +02:00
|
|
|
this.title.setTitle('Administration Dashboard | New Class Help Text');
|
2018-10-30 16:31:16 +01:00
|
|
|
this.communityPid = params['communityId'];
|
|
|
|
this.pageId = params['pageId'];
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
if(this.pageId) {
|
|
|
|
this.getPage(this.pageId);
|
|
|
|
} else {
|
|
|
|
this.showLoading = false;
|
|
|
|
}
|
2018-10-30 16:31:16 +01:00
|
|
|
});
|
2018-02-06 12:06:43 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
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() {
|
2018-11-13 16:26:49 +01:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
|
|
|
} else {
|
2018-02-06 12:06:43 +01:00
|
|
|
if(this.formComponent.myForm.valid) {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.showLoading = true;
|
|
|
|
this.updateErrorMessage = "";
|
|
|
|
|
2018-02-06 12:06:43 +01:00
|
|
|
let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
|
|
|
|
|
2018-03-06 16:36:33 +01:00
|
|
|
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe(
|
2018-02-06 12:06:43 +01:00
|
|
|
_ => {
|
|
|
|
if(this.pageId) {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } );
|
2018-02-06 12:06:43 +01:00
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } );
|
2018-02-06 12:06:43 +01:00
|
|
|
}
|
2018-10-30 16:31:16 +01:00
|
|
|
this.showLoading = false;
|
2018-02-06 12:06:43 +01:00
|
|
|
},
|
2018-10-30 16:31:16 +01:00
|
|
|
err => this.handleUpdateError('System error saving page content', err)
|
2018-02-06 12:06:43 +01:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.errorMessage = "Please fill all required fields";
|
|
|
|
}
|
2018-11-13 16:26:49 +01:00
|
|
|
}
|
2018-02-06 12:06:43 +01:00
|
|
|
}
|
|
|
|
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
public cancelCustom() {
|
2018-02-06 12:06:43 +01:00
|
|
|
if(this.pageId) {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } );
|
2018-02-06 12:06:43 +01:00
|
|
|
} else {
|
2018-10-30 16:31:16 +01:00
|
|
|
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } );
|
2018-02-06 12:06:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 16:31:16 +01:00
|
|
|
handleUpdateError(message: string, error) {
|
|
|
|
this.errorMessage = message;
|
|
|
|
console.log('Server responded: ' + error);
|
|
|
|
this.showLoading = false;
|
2018-02-06 12:06:43 +01:00
|
|
|
}
|
[Trunk | Admin]:
1. pages.component: Show link to add pageHelpContents only when at least one posiiton is enabled.
2. help-content.service:
Add 'pid' parameter in 'getDivIdsFull()' method to be able to get divIds that are enabled in a community.
Add 'with_positions' parameter in 'getPages()' method to be able to get pages that have at least one position or no positions enabled.
3. app.component: Hide '/classContents' route for communities (currently no divIds for communities).
4. div-help-content-form.component: Get divIds that are enabled for the community.
5. div-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect.
6. edit-div-help-content.component & new-div-help-content.component:
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
7. edit-div-help-content.component: If there is no 'divContentId' url param, redirect
8. edit-page-help-content.component:
If there is no 'pageContentId' url param, redirect
Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected or use pageHelpContent.page - if pageId != pageHelpContent.page, redirect) and show it in the p$
9. new-page-help-content.component: Add 'getPage()' method, to get page (if disabled in community, redirect - if pageId is pre-selected) and show it in the page title.
10. page-help-content-form.component: Do not perform a query to get page when it is pre-selected (new & edit do the query now) | Get pages with at least one posiiton enabled.
11. page-help-contents.component: When a page is pre-selected ('pageId' url param exists), check if page is enabled in the community, otherwise redirect | Get pages with at least one posiiton enabled.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56740 d315682c-612b-4755-9ff5-7f18f6832af3
2019-07-24 11:16:42 +02:00
|
|
|
|
|
|
|
handleError(message: string, error) {
|
|
|
|
this.errorMessage = message;
|
|
|
|
console.log('Server responded: ' + error);
|
|
|
|
this.showLoading = false;
|
|
|
|
}
|
2018-02-06 12:06:43 +01:00
|
|
|
}
|