[Library|Trunk]
String utils: add function HTMLToString create HTMLToStringPipe git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60647 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
372f33cb21
commit
50dda276c6
|
@ -5,7 +5,7 @@
|
|||
<div class="uk-grid helper-grid">
|
||||
<div class="uk-width-expand ">
|
||||
<div
|
||||
class="uk-card-body uk-padding-remove-bottom uk-padding-remove-top " [class.portal-hr]="
|
||||
class="uk-card-body uk-padding-remove-bottom uk-padding-remove-top " [class.paging-hr]="
|
||||
!pageLoading && claims && claims.length > 0">
|
||||
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
|
||||
[texts]="pageContents['top']"></helper>
|
||||
|
@ -62,10 +62,10 @@
|
|||
|
||||
</div>
|
||||
<div *ngIf="resultsNum" class="uk-width-1-2 uk-grid uk-flex-right uk-flex-middle ">
|
||||
<div>
|
||||
<span class="portal-color">{{resultsNum|number}}</span> links, page <span
|
||||
class="portal-color">{{page | number}}</span> of <span
|
||||
class="portal-color">{{totalPages(resultsNum)|number}}</span>
|
||||
<div class="uk-text-muted uk-text-uppercase">
|
||||
<span class="uk-text-bold">{{resultsNum|number}}</span> links, page <span
|
||||
class="uk-text-bold">{{page | number}}</span> of <span
|
||||
class="uk-text-bold">{{totalPages(resultsNum)|number}}</span>
|
||||
</div>
|
||||
<paging-no-load [currentPage]="page" [totalResults]="resultsNum" [size]="size"
|
||||
[loading]="pageLoading"
|
||||
|
@ -91,7 +91,7 @@
|
|||
<div class="uk-alert uk-alert-primary ">No entries found.</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div class="uk-margin-small-top">
|
||||
|
||||
<div *ngFor="let claim of claims "
|
||||
class="uk-card uk-card-default uk-card-body uk-margin-bottom ng-star-inserted">
|
||||
|
@ -128,12 +128,12 @@
|
|||
</div>
|
||||
<div *ngIf="!( showErrorMessage || showForbiddenMessage || userValidMessage.length > 0 || (claims
|
||||
&& claims.length
|
||||
==0))" class="portal-hr uk-margin-top">
|
||||
==0))" class="paging-hr uk-margin-top">
|
||||
<div class="uk-grid ">
|
||||
<div *ngIf="resultsNum>0" class="uk-width-1-2">
|
||||
<span class="portal-color">{{resultsNum|number}}</span> links, page <span
|
||||
class="portal-color">{{page | number}}</span> of <span
|
||||
class="portal-color">{{totalPages(resultsNum)|number}}</span>
|
||||
<div *ngIf="resultsNum>0" class="uk-width-1-2 uk-text-muted uk-text-uppercase">
|
||||
<span class="uk-text-bold">{{resultsNum|number}}</span> links, page <span
|
||||
class="uk-text-bold">{{page | number}}</span> of <span
|
||||
class="uk-text-bold">{{totalPages(resultsNum)|number}}</span>
|
||||
|
||||
</div>
|
||||
<div *ngIf="resultsNum" class="uk-width-1-2 ">
|
||||
|
|
|
@ -17,6 +17,7 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
|||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
|
||||
@Component({
|
||||
selector: 'div-help-contents',
|
||||
|
@ -363,8 +364,7 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public cutContent(divHelpContent: DivHelpContent) {
|
||||
divHelpContent.content = divHelpContent.content.replace(/<[^>]*>/g, '');
|
||||
divHelpContent.content = divHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
|
||||
divHelpContent.content = StringUtils.HTMLToString(divHelpContent.content);
|
||||
if (divHelpContent.content.length > 200) {
|
||||
divHelpContent.content = divHelpContent.content.substr(0, 200) + "...";
|
||||
}
|
||||
|
|
|
@ -86,7 +86,8 @@
|
|||
<div *ngIf="!selectedPageId" >
|
||||
<div class="page" href="#">{{check.pageHelpContent.page.name}}</div>
|
||||
</div>
|
||||
<div class="content">{{check.pageHelpContent.content}}</div>
|
||||
<div class="content multi-line-ellipsis lines-2">
|
||||
<p>{{check.pageHelpContent.content|htmlToString}}</p></div>
|
||||
</div>
|
||||
<div class="uk-grid uk-width-1-1 uk-margin-left">
|
||||
<div class=" ">
|
||||
|
|
|
@ -187,7 +187,6 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
this.checkboxes = [];
|
||||
|
||||
for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
|
||||
this.cutContent(this.pageHelpContents[i]);
|
||||
this.checkboxes.unshift(<CheckPageHelpContent>{
|
||||
pageHelpContent: this.pageHelpContents[i],
|
||||
checked: false
|
||||
|
@ -331,7 +330,6 @@ 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);
|
||||
|
@ -355,20 +353,11 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
return idFlag && activeFlag && textFlag;
|
||||
}
|
||||
|
||||
public cutContent(pageHelpContent: PageHelpContent) {
|
||||
pageHelpContent.content = pageHelpContent.content.replace(/<[^>]*>/g, '');
|
||||
pageHelpContent.content = pageHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
|
||||
|
||||
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.cutContent(_);
|
||||
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
|
||||
}
|
||||
);
|
||||
|
|
|
@ -17,12 +17,13 @@ import {IconsModule} from '../../utils/icons/icons.module';
|
|||
import {IconsService} from '../../utils/icons/icons.service';
|
||||
import {add, arrow_left} from '../../utils/icons/icons';
|
||||
import {LoadingModule} from '../../utils/loading/loading.module';
|
||||
import {HTMLToStringPipeModule} from '../../utils/pipes/HTMLToStringPipe.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, RouterModule, FormsModule, SafeHtmlPipeModule,
|
||||
AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, AdminToolServiceModule, InputModule, PageHelpContentsRoutingModule, PageContentModule,
|
||||
SearchInputModule, IconsModule, LoadingModule
|
||||
SearchInputModule, IconsModule, LoadingModule, HTMLToStringPipeModule
|
||||
],
|
||||
declarations: [
|
||||
PageHelpContentsComponent
|
||||
|
|
|
@ -6,6 +6,7 @@ import {Notification, NotificationUser} from "./notifications";
|
|||
import {CustomOptions} from "../services/servicesUtils/customOptions.class";
|
||||
import {not} from "rxjs/internal-compatibility";
|
||||
import {map} from "rxjs/operators";
|
||||
import {StringUtils} from '../utils/string-utils.class';
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
|
@ -46,8 +47,7 @@ export class NotificationService {
|
|||
if (notification.title) {
|
||||
notification.preview = notification.title;
|
||||
} else {
|
||||
notification.preview = notification.message.replace(/<[^>]*>/g, '');
|
||||
notification.preview = notification.preview.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
|
||||
notification.preview = StringUtils.HTMLToString(notification.message);
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {SafeUrl} from '@angular/platform-browser';
|
||||
import {StringUtils} from '../string-utils.class';
|
||||
|
||||
@Pipe({ name: 'htmlToString'})
|
||||
export class HTMLToStringPipe implements PipeTransform {
|
||||
constructor() {}
|
||||
|
||||
transform(value):SafeUrl {
|
||||
return StringUtils.HTMLToString(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import {HTMLToStringPipe} from './HTMLToString.pipe';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
||||
],
|
||||
declarations: [
|
||||
HTMLToStringPipe
|
||||
],
|
||||
providers:[],
|
||||
exports: [
|
||||
HTMLToStringPipe
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
export class HTMLToStringPipeModule{
|
||||
|
||||
}
|
|
@ -363,4 +363,14 @@ export class StringUtils {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public static HTMLToString( html:string){
|
||||
try {
|
||||
html = html.replace(/ /g, ' ');
|
||||
html = html.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
|
||||
html = html.replace(/<[^>]*>/g, '');
|
||||
}catch( e){
|
||||
}
|
||||
console.log(html);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue