refactor(tasks): simplify template conditionals with @if/@else patterns

- Convert sequential @if blocks to @if/@else for mutually exclusive conditions
- Remove redundant nested repeatCfgId check (parent already guarantees condition)
- Remove redundant nested subTasks?.length checks (parent already guarantees condition)

Improves template readability without changing behavior.
This commit is contained in:
Johannes Millan 2026-01-22 11:48:49 +01:00
parent 32eca5a326
commit e93760dfb8

View file

@ -4,11 +4,10 @@
#blockLeftEl
class="block-left bg-400"
>
@if (!t.isDone) {
<mat-icon>check</mat-icon>
}
@if (t.isDone) {
<mat-icon>undo</mat-icon>
} @else {
<mat-icon>check</mat-icon>
}
</div>
<div
@ -16,11 +15,10 @@
class="block-right bg-400"
>
<!--NOTE: non observable should be enough as we only need the initial value-->
@if (!t.repeatCfgId) {
<mat-icon>today</mat-icon>
}
@if (t.repeatCfgId) {
<mat-icon svgIcon="repeat"></mat-icon>
} @else {
<mat-icon>today</mat-icon>
}
</div>
}
@ -90,13 +88,11 @@
@if (!isRepeatTaskCreatedToday()) {
<div class="repeat-date-badge">{{ t.created | shortDate2 }}</div>
}
@if (t.repeatCfgId) {
<mat-icon
[style.transform]="isCurrent() ? 'scale(1.4)' : ''"
svgIcon="repeat"
>
</mat-icon>
}
<mat-icon
[style.transform]="isCurrent() ? 'scale(1.4)' : ''"
svgIcon="repeat"
>
</mat-icon>
</div>
}
@if (t.issueId) {
@ -283,37 +279,32 @@
}
@if (t.subTasks?.length) {
<div class="sub-tasks">
@if (t.subTasks?.length) {
<button
(click)="toggleSubTaskMode()"
[title]="T.F.TASK.CMP.TOGGLE_SUB_TASK_VISIBILITY | translate"
class="toggle-sub-tasks-btn ico-btn mat-elevation-z2"
color=""
mat-mini-fab
>
@if (t._hideSubTasksMode === ShowSubTasksMode.HideAll) {
<mat-icon>add</mat-icon>
}
@if (t._hideSubTasksMode !== ShowSubTasksMode.HideAll) {
<mat-icon
[class.isHideDoneTasks]="t._hideSubTasksMode === ShowSubTasksMode.HideDone"
>remove
</mat-icon>
}
</button>
}
@if (t.subTasks?.length) {
<task-list
[@expandInOnly]
[isHideAll]="!!t._hideSubTasksMode"
[isHideDone]="t._hideSubTasksMode === ShowSubTasksMode.HideDone"
[isSubTaskList]="true"
[listModelId]="t.id"
[parentId]="t.id"
[tasks]="t.subTasks"
listId="SUB"
></task-list>
}
<button
(click)="toggleSubTaskMode()"
[title]="T.F.TASK.CMP.TOGGLE_SUB_TASK_VISIBILITY | translate"
class="toggle-sub-tasks-btn ico-btn mat-elevation-z2"
color=""
mat-mini-fab
>
@if (t._hideSubTasksMode === ShowSubTasksMode.HideAll) {
<mat-icon>add</mat-icon>
} @else {
<mat-icon
[class.isHideDoneTasks]="t._hideSubTasksMode === ShowSubTasksMode.HideDone"
>remove
</mat-icon>
}
</button>
<task-list
[@expandInOnly]
[isHideAll]="!!t._hideSubTasksMode"
[isHideDone]="t._hideSubTasksMode === ShowSubTasksMode.HideDone"
[isSubTaskList]="true"
[listModelId]="t.id"
[parentId]="t.id"
[tasks]="t.subTasks"
listId="SUB"
></task-list>
</div>
}
@if (isDragOver) {