diff --git a/projects/common/components/compound-elements/cloze/cloze.component.ts b/projects/common/components/compound-elements/cloze/cloze.component.ts index 10bd922d0db25d4d5cdaf1f8bd6b27116170fc7a..146f5fef6536a11e23c47e0cb04b226b3d229482 100644 --- a/projects/common/components/compound-elements/cloze/cloze.component.ts +++ b/projects/common/components/compound-elements/cloze/cloze.component.ts @@ -139,14 +139,14 @@ import { ClozeElement } from 'common/models/elements/compound-elements/cloze/clo <ng-template #paragraphChildren let-part> <ng-container *ngFor="let subPart of part.content"> <ng-container *ngIf="$any(subPart).type === 'text' && - (!(subPart.marks | markList).includes('superscript')) && - (!(subPart.marks | markList).includes('subscript'))"> + (!(subPart.marks | markList | arrayIncludes:'superscript')) && + (!(subPart.marks | markList | arrayIncludes:'subscript'))"> <span [ngStyle]="subPart.marks | styleMarks">{{subPart.text}}</span> </ng-container> - <ng-container *ngIf="$any(subPart).type === 'text' && (subPart.marks | markList).includes('superscript')"> + <ng-container *ngIf="$any(subPart).type === 'text' && ((subPart.marks | markList) | arrayIncludes:'superscript')"> <sup [ngStyle]="subPart.marks | styleMarks">{{subPart.text}}</sup> </ng-container> - <ng-container *ngIf="$any(subPart).type === 'text' && (subPart.marks | markList).includes('subscript')"> + <ng-container *ngIf="$any(subPart).type === 'text' && ((subPart.marks | markList) | arrayIncludes:'subscript')"> <sub [ngStyle]="subPart.marks | styleMarks">{{subPart.text}}</sub> </ng-container> <ng-container *ngIf="$any(subPart).type === 'image'"> @@ -155,7 +155,7 @@ import { ClozeElement } from 'common/models/elements/compound-elements/cloze/clo [style.height]="'1em'" [style.vertical-align]="'middle'"> </ng-container> - <span *ngIf="['ToggleButton', 'DropList', 'TextField', 'Button'].includes(subPart.type)"> + <span *ngIf="['ToggleButton', 'DropList', 'TextField', 'Button'] | arrayIncludes:subPart.type"> <aspect-compound-child-overlay [style.display]="'inline-block'" [parentForm]="parentForm" [element]="$any(subPart).attrs.model" diff --git a/projects/common/pipes/array-includes.pipe.ts b/projects/common/pipes/array-includes.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..3041ddc5d8f1cbfe6e1f8738702a0222c5b5b906 --- /dev/null +++ b/projects/common/pipes/array-includes.pipe.ts @@ -0,0 +1,10 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'arrayIncludes' +}) +export class ArrayIncludesPipe implements PipeTransform { + transform(valueList: string[], searchValue: string): unknown { + return valueList.includes(searchValue); + } +} diff --git a/projects/common/shared.module.ts b/projects/common/shared.module.ts index 102cb183d48b3da6f3c640f4b40b1bd13838eb22..0eafaec25e9d31ce0e9ce6a93bb40da49d1d3a4c 100644 --- a/projects/common/shared.module.ts +++ b/projects/common/shared.module.ts @@ -67,6 +67,7 @@ import { CompoundChildOverlayComponent } from './components/compound-elements/cl import { MarkListPipe } from './pipes/mark-list.pipe'; import { IsDisabledDirective } from './directives/is-disabled.directive'; import { GeometryComponent } from './components/geometry/geometry.component'; +import { ArrayIncludesPipe } from './pipes/array-includes.pipe'; @NgModule({ imports: [ @@ -124,7 +125,8 @@ import { GeometryComponent } from './components/geometry/geometry.component'; CompoundChildOverlayComponent, MarkListPipe, IsDisabledDirective, - GeometryComponent + GeometryComponent, + ArrayIncludesPipe ], exports: [ CommonModule,