Skip to content

Commit

Permalink
Merge branch 'main' into add-new-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-krechan authored Dec 17, 2024
2 parents 0efc0d1 + dfc1c0c commit 480105f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@
</td>
<td class="px-6 py-4 conditions-column">
@if (line.conditions) {
<p
[innerHTML]="
getDisplayText(line.conditions, i) | highlight: highlight()
"
></p>
@for (
condition of addConditionLineBreaks(
getDisplayText(line.conditions, i)
);
track $index
) {
<div [innerHTML]="condition | highlight: highlight()"></div>
}
@if (shouldShowToggle(line.conditions)) {
<button
(click)="toggleExpand(i)"
Expand Down
20 changes: 13 additions & 7 deletions src/app/features/ahbs/components/ahb-table/ahb-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,13 @@ export class AhbTableComponent {
return mapping[key] || '';
}

// split before [<condition>] and remove empty strings
addConditionLineBreaks(conditions: string): string[] {
return conditions ? conditions.split('\n') : [];
if (!conditions) return [];
return conditions
.split(/(?=\[\d+\])/)
.map((s) => s.trim())
.filter((s) => s);
}

toggleExpand(index: number) {
Expand All @@ -210,17 +215,18 @@ export class AhbTableComponent {
// "mehr/weniger anzeigen" toggle for 'Bedingungen/Hinweise' column if len > COLLAPSE_LENGTH
shouldShowToggle(conditions: string): boolean {
if (!conditions) return false;
return conditions.length > this.COLLAPSE_LENGTH;
const allConditions = this.addConditionLineBreaks(conditions);
return allConditions.length > 1;
}

getDisplayText(conditions: string, rowIndex: number): string {
if (!conditions) return '';
if (
this.isExpanded(rowIndex) ||
conditions.length <= this.COLLAPSE_LENGTH
) {
const allConditions = this.addConditionLineBreaks(conditions);

if (this.isExpanded(rowIndex)) {
return conditions;
}
return conditions.substring(0, this.COLLAPSE_LENGTH) + ' ...';

return allConditions[0];
}
}

0 comments on commit 480105f

Please sign in to comment.