RED-5546: update sanitize

This commit is contained in:
Dan Percic 2022-11-21 16:26:56 +02:00
parent a41c82214c
commit 74ec276e00
11 changed files with 114 additions and 80 deletions

View File

@ -0,0 +1,64 @@
<div>
<div class="cell filename">
<div [matTooltip]="item.filename" class="table-item-title heading" matTooltipPosition="above">
<span
*ngIf="item.highlights.filename; else defaultFilename"
[innerHTML]="sanitize(item.highlights.filename[0])"
class="highlights"
></span>
<ng-template #defaultFilename>{{ item.filename }}</ng-template>
</div>
<ng-container *ngIf="item.highlights['sections.text'] as highlights">
<div *ngIf="highlights.length > 0" class="small-label">
<span [innerHTML]="sanitize(highlights[0])" class="highlights"></span>
</div>
<div *ngIf="highlights.length > 1" class="small-label">
<span [innerHTML]="sanitize(highlights[1])" class="highlights"></span>
</div>
</ng-container>
<div *ngIf="item.unmatched?.length && item.unmatched as unmatched" class="small-label">
<span>
{{ 'search-screen.missing' | translate }}:<span *ngFor="let term of unmatched"
>&nbsp;<s>{{ term }}</s></span
>.&nbsp;{{ 'search-screen.must-contain' | translate }}:
<span (click)="$event.stopPropagation(); mustContain.emit(term)" *ngFor="let term of unmatched"
>&nbsp;<u>{{ term }}</u></span
>
</span>
</div>
</div>
<div class="cell">
<iqser-initials-avatar [user]="item.assignee" [withName]="true"></iqser-initials-avatar>
</div>
<div class="cell">
<iqser-status-bar
[configs]="[
{
color: item.status,
label: fileStatusTranslations[item.status] | translate,
length: 1,
cssClass: 'all-caps-label'
}
]"
[small]="true"
></iqser-status-bar>
</div>
<div class="cell small-label stats-subtitle">
<div>
<mat-icon *ngIf="item.archived" svgIcon="red:archive"></mat-icon>
{{ item.dossierName }}
</div>
</div>
<div class="cell small-label stats-subtitle">
<div>
<mat-icon svgIcon="iqser:pages"></mat-icon>
{{ item.numberOfPages }}
</div>
</div>
</div>

View File

@ -0,0 +1,9 @@
@use 'common-mixins';
.cell .highlights::ng-deep {
@include common-mixins.line-clamp(1);
em {
background-color: var(--iqser-highlight-color);
}
}

View File

@ -0,0 +1,21 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { workflowFileStatusTranslations } from '@translations/file-status-translations';
import { ISearchListItem } from '@red/domain';
import { stripHtml } from 'string-strip-html';
@Component({
selector: 'redaction-search-item-template',
templateUrl: './search-item-template.component.html',
styleUrls: ['./search-item-template.component.scss'],
})
export class SearchItemTemplateComponent {
@Input() item: ISearchListItem;
@Output() readonly mustContain = new EventEmitter<string>();
readonly fileStatusTranslations = workflowFileStatusTranslations;
sanitize(value: string) {
return stripHtml(value, {
ignoreTags: ['em'],
}).result;
}
}

View File

@ -24,70 +24,7 @@
</section>
<ng-template #tableItemTemplate let-item="entity">
<div>
<div class="cell filename">
<div [matTooltip]="item.filename" class="table-item-title heading" matTooltipPosition="above">
<span
*ngIf="item.highlights.filename; else defaultFilename"
[innerHTML]="stripHtmlForView(item.highlights.filename[0])"
class="highlights"
></span>
<ng-template #defaultFilename>{{ item.filename }}</ng-template>
</div>
<ng-container *ngIf="item.highlights['sections.text'] as highlights">
<div *ngIf="highlights.length > 0" class="small-label">
<span [innerHTML]="highlights[0]" class="highlights"></span>
</div>
<div *ngIf="highlights.length > 1" class="small-label">
<span [innerHTML]="highlights[1]" class="highlights"></span>
</div>
</ng-container>
<div *ngIf="item.unmatched?.length && item.unmatched as unmatched" class="small-label">
<span>
{{ 'search-screen.missing' | translate }}:<span *ngFor="let term of unmatched"
>&nbsp;<s>{{ term }}</s></span
>.&nbsp;{{ 'search-screen.must-contain' | translate }}:
<span (click)="$event.stopPropagation(); mustContain(term)" *ngFor="let term of unmatched"
>&nbsp;<u>{{ term }}</u></span
>
</span>
</div>
</div>
<div class="cell">
<iqser-initials-avatar [user]="item.assignee" [withName]="true"></iqser-initials-avatar>
</div>
<div class="cell">
<iqser-status-bar
[configs]="[
{
color: item.status,
label: fileStatusTranslations[item.status] | translate,
length: 1,
cssClass: 'all-caps-label'
}
]"
[small]="true"
></iqser-status-bar>
</div>
<div class="cell small-label stats-subtitle">
<div>
<mat-icon *ngIf="item.archived" svgIcon="red:archive"></mat-icon>
{{ item.dossierName }}
</div>
</div>
<div class="cell small-label stats-subtitle">
<div>
<mat-icon svgIcon="iqser:pages"></mat-icon>
{{ item.numberOfPages }}
</div>
</div>
</div>
<redaction-search-item-template [item]="item" (mustContain)="mustContain($event)"></redaction-search-item-template>
</ng-template>
<ng-container *ngIf="dossierTemplates$ | async"></ng-container>

View File

@ -1,9 +0,0 @@
@use 'common-mixins';
.cell .highlights::ng-deep {
@include common-mixins.line-clamp(1);
em {
background-color: var(--iqser-highlight-color);
}
}

View File

@ -42,7 +42,6 @@ import { stripHtml } from 'string-strip-html';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SearchScreenComponent extends ListingComponent<ISearchListItem> implements OnDestroy {
readonly fileStatusTranslations = workflowFileStatusTranslations;
readonly searchPositions = SearchPositions;
readonly tableHeaderLabel = _('search-screen.table-header');

View File

@ -5,11 +5,12 @@ import { RouterModule } from '@angular/router';
import { IqserListingModule, IqserSharedModule, IqserUsersModule } from '@iqser/common-ui';
import { SharedModule } from '@shared/shared.module';
import { TranslateModule } from '@ngx-translate/core';
import { SearchItemTemplateComponent } from './search-item-template/search-item-template.component';
const routes = [{ path: '', component: SearchScreenComponent }];
@NgModule({
declarations: [SearchScreenComponent],
declarations: [SearchScreenComponent, SearchItemTemplateComponent],
imports: [
CommonModule,
RouterModule.forChild(routes),

View File

@ -145,7 +145,11 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
this._editDossierDialogRef.close();
await this._router.navigate([this.dossier.dossiersListRouterLink]);
this._loadingService.stop();
this._toaster.success(_('edit-dossier-dialog.delete-successful'), { params: this.dossier });
this._toaster.success(_('edit-dossier-dialog.delete-successful'), {
params: {
dossierName: this.dossier.dossierName,
},
});
});
}
@ -165,7 +169,11 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
if (result === ConfirmOptions.CONFIRM) {
this._loadingService.start();
await firstValueFrom(this._archivedDossiersService.archive([this.dossier]));
this._toaster.success(_('dossier-listing.archive.archive-succeeded'), { params: this.dossier });
this._toaster.success(_('dossier-listing.archive.archive-succeeded'), {
params: {
dossierName: this.dossier.dossierName,
},
});
this._editDossierDialogRef.close();
this._loadingService.stop();
}

View File

@ -21,7 +21,11 @@ export class ArchivedDossiersService extends DossiersService {
archive(dossiers: Dossier[]): Observable<unknown> {
const showArchiveFailedToast = () => {
this._toaster.error(_('dossier-listing.archive.archive-failed'), { params: dossiers });
this._toaster.error(_('dossier-listing.archive.archive-failed'), {
params: {
dossierName: dossiers.map(d => d.dossierName).join(', '),
},
});
return of({});
};

View File

@ -32,7 +32,7 @@ export class TrashService extends EntitiesService<TrashItem, TrashItem> {
deleteDossier(dossier: Dossier): Observable<unknown> {
const showToast = () => {
this._toaster.error(_('dossier-listing.delete.delete-failed'), { params: dossier });
this._toaster.error(_('dossier-listing.delete.delete-failed'), { params: { dossierName: dossier.dossierName } });
return of({});
};

@ -1 +1 @@
Subproject commit c925503fc6dba39824a1a2fac0e106c0a806d157
Subproject commit 2f10819460065591e726c839175002b73ca75a3d