[Trunk | Admin]: div-help-contents.component & page-help-contents.component: Bug fix: Cut content when saving and filtering active/inactive too.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56775 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-07-26 10:08:18 +00:00
parent 0a22c81cfe
commit ac0306d4de
2 changed files with 27 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {PageHelpContent} from "../../domain/page-help-content";
@Component({
selector: 'div-help-contents',
@ -150,10 +151,7 @@ export class DivHelpContentsComponent implements OnInit {
const pageIds = pages.map(x => x._id);
if(!this.selectedPageId || pageIds.includes(this.selectedPageId)) {
this.divHelpContents[i].content = this.divHelpContents[i].content.replace(/<[^>]*>/g, '');
if(this.divHelpContents[i].content.length > 200) {
this.divHelpContents[i].content = this.divHelpContents[i].content.substr(0, 200) + "...";
}
this.cutContent(this.divHelpContents[i]);
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent : this.divHelpContents[i], checked : false});
} else {
this.divHelpContents.splice(i, 1);
@ -267,6 +265,7 @@ export class DivHelpContentsComponent implements OnInit {
}
public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) {
this.cutContent(divHelpContent);
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent : divHelpContent, checked : false});
this.divHelpContents.push(divHelpContent);
this.applyCheck(false);
@ -293,10 +292,20 @@ export class DivHelpContentsComponent implements OnInit {
return idFlag && activeFlag && textFlag;
}
public cutContent(divHelpContent: DivHelpContent) {
divHelpContent.content = divHelpContent.content.replace(/<[^>]*>/g, '');
if(divHelpContent.content.length > 200) {
divHelpContent.content = divHelpContent.content.substr(0, 200) + "...";
}
}
public applyFilter() {
this.checkboxes = [];
this.divHelpContents.filter(item => this.filterDivHelpContent(item,this.filters)).forEach(
_ => this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false})
_ => {
this.cutContent(_);
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false})
}
);
this.countDivHelpContents();
}

View File

@ -160,10 +160,7 @@ export class PageHelpContentsComponent implements OnInit {
for (let i = 0; i < this.pageHelpContents.length; i++) {
let page: Page = this.pageHelpContents[i].page as Page;
if(!this.selectedPageId || (page._id == this.selectedPageId)) {
this.pageHelpContents[i].content = this.pageHelpContents[i].content.replace(/<[^>]*>/g, '');
if(this.pageHelpContents[i].content.length > 200) {
this.pageHelpContents[i].content = this.pageHelpContents[i].content.substr(0, 200) + "...";
}
this.cutContent(this.pageHelpContents[i]);
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent : this.pageHelpContents[i], checked : false});
} else {
this.pageHelpContents.splice(i, 1);
@ -281,6 +278,7 @@ export class PageHelpContentsComponent implements OnInit {
}
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
this.cutContent(pageHelpContent);
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent : pageHelpContent, checked : false});
this.pageHelpContents.push(pageHelpContent);
this.applyCheck(false);
@ -303,10 +301,20 @@ export class PageHelpContentsComponent implements OnInit {
return idFlag && activeFlag && textFlag;
}
public cutContent(pageHelpContent: PageHelpContent) {
pageHelpContent.content = pageHelpContent.content.replace(/<[^>]*>/g, '');
if(pageHelpContent.content.length > 200) {
pageHelpContent.content = pageHelpContent.content.substr(0, 200) + "...";
}
}
public applyFilter() {
this.checkboxes = [];
this.pageHelpContents.filter(item => this.filterPageHelpContent(item,this.filters)).forEach(
_ => this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
_ => {
this.cutContent(_);
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
}
);
this.countPageHelpContents();
}