Skip to content

Commit

Permalink
Migrate control flow & replace bkdLet with @let #705
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Oct 17, 2024
1 parent 36f8e34 commit 519cc85
Show file tree
Hide file tree
Showing 134 changed files with 5,202 additions and 5,008 deletions.
4,528 changes: 2,483 additions & 2,045 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
},
"private": true,
"dependencies": {
"@angular/animations": "18.0.3",
"@angular/common": "18.0.3",
"@angular/compiler": "18.0.3",
"@angular/core": "18.0.3",
"@angular/forms": "18.0.3",
"@angular/localize": "18.0.3",
"@angular/platform-browser": "18.0.3",
"@angular/platform-browser-dynamic": "18.0.3",
"@angular/router": "18.0.3",
"@angular/animations": "18.2.8",
"@angular/common": "18.2.8",
"@angular/compiler": "18.2.8",
"@angular/core": "18.2.8",
"@angular/forms": "18.2.8",
"@angular/localize": "18.2.8",
"@angular/platform-browser": "18.2.8",
"@angular/platform-browser-dynamic": "18.2.8",
"@angular/router": "18.2.8",
"@ng-bootstrap/ng-bootstrap": "17.0.0",
"@ng-select/ng-select": "13.2.0",
"@ngx-translate/core": "15.0.0",
Expand All @@ -57,18 +57,18 @@
"ngx-infinite-scroll": "18.0.0",
"rxjs": "7.8.1",
"tslib": "2.6.3",
"zone.js": "0.14.7"
"zone.js": "0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "18.0.4",
"@angular-devkit/build-angular": "18.2.8",
"@angular-eslint/builder": "18.0.1",
"@angular-eslint/eslint-plugin": "18.0.1",
"@angular-eslint/eslint-plugin-template": "18.0.1",
"@angular-eslint/schematics": "18.0.1",
"@angular-eslint/template-parser": "18.0.1",
"@angular/cli": "18.0.4",
"@angular/compiler-cli": "18.0.3",
"@angular/language-service": "18.0.3",
"@angular/cli": "18.2.8",
"@angular/compiler-cli": "18.2.8",
"@angular/language-service": "18.2.8",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/jasmine": "5.1.4",
"@types/lodash-es": "4.17.12",
Expand All @@ -89,7 +89,7 @@
"karma-jasmine-html-reporter": "2.1.0",
"karma-spec-reporter": "0.0.36",
"lint-staged": "15.2.7",
"prettier": "3.3.2",
"prettier": "3.3.3",
"typescript": "5.4.5"
},
"lint-staged": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<a *ngIf="!externalLink" [routerLink]="link" [queryParams]="linkParams">
<ng-container *ngTemplateOutlet="actionContent"></ng-container>
</a>
@if (!externalLink) {
<a [routerLink]="link" [queryParams]="linkParams">
<ng-container *ngTemplateOutlet="actionContent"></ng-container>
</a>
}

<a *ngIf="externalLink" [href]="externalLink">
<ng-container *ngTemplateOutlet="actionContent"></ng-container>
</a>
@if (externalLink) {
<a [href]="externalLink">
<ng-container *ngTemplateOutlet="actionContent"></ng-container>
</a>
}

<ng-template #actionContent>
<span class="label">{{ label | translate }}</span>
<div>
<ng-content></ng-content>
<span class="count" *ngIf="hasCount(count); else icon">{{ count }}</span>
<ng-template #icon>
@if (hasCount(count)) {
<span class="count">{{ count }}</span>
} @else {
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand All @@ -23,6 +28,6 @@
d="m12 20-1.425-1.4 5.6-5.6H4v-2h12.175l-5.6-5.6L12 4l8 8-8 8Z"
/>
</svg>
</ng-template>
}
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NgIf, NgTemplateOutlet } from "@angular/common";
import { NgTemplateOutlet } from "@angular/common";
import { Component, Input } from "@angular/core";
import { Params, RouterLink } from "@angular/router";
import { TranslateModule } from "@ngx-translate/core";
Expand All @@ -8,7 +8,7 @@ import { TranslateModule } from "@ngx-translate/core";
templateUrl: "./dashboard-action.component.html",
styleUrls: ["./dashboard-action.component.scss"],
standalone: true,
imports: [NgIf, RouterLink, NgTemplateOutlet, TranslateModule],
imports: [RouterLink, NgTemplateOutlet, TranslateModule],
})
export class DashboardActionComponent {
@Input() label: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,62 @@
<bkd-dashboard-action
*ngIf="dashboardService.hasPresenceControl$ | async"
[label]="'dashboard.actions.presence-control'"
[link]="['/presence-control']"
></bkd-dashboard-action>
@if (dashboardService.hasPresenceControl$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.presence-control'"
[link]="['/presence-control']"
></bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="
(dashboardService.hasLessonTeacherRole$ | async) &&
(dashboardService.editAbsencesParams$ | async)
"
[label]="'dashboard.actions.edit-absences'"
[link]="['/edit-absences']"
[linkParams]="dashboardService.editAbsencesParams$ | async"
[count]="dashboardService.editAbsencesCount$ | async"
></bkd-dashboard-action>
@if (
(dashboardService.hasLessonTeacherRole$ | async) &&
(dashboardService.editAbsencesParams$ | async)
) {
<bkd-dashboard-action
[label]="'dashboard.actions.edit-absences'"
[link]="['/edit-absences']"
[linkParams]="dashboardService.editAbsencesParams$ | async"
[count]="dashboardService.editAbsencesCount$ | async"
></bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="dashboardService.hasOpenAbsences$ | async"
[label]="'dashboard.actions.open-absences'"
[link]="['/open-absences']"
[count]="dashboardService.openAbsencesCount$ | async"
></bkd-dashboard-action>
@if (dashboardService.hasOpenAbsences$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.open-absences'"
[link]="['/open-absences']"
[count]="dashboardService.openAbsencesCount$ | async"
></bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="dashboardService.hasTeacherRole$ | async"
[label]="'dashboard.actions.tests'"
[link]="['/events']"
>
<bkd-dashboard-deadline
*ngIf="(dashboardService.coursesToRateCount$ | async) ?? 0 > 0"
[count]="dashboardService.coursesToRateCount$ | async"
></bkd-dashboard-deadline>
</bkd-dashboard-action>
@if (dashboardService.hasTeacherRole$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.tests'"
[link]="['/events']"
>
@if ((dashboardService.coursesToRateCount$ | async) ?? 0 > 0) {
<bkd-dashboard-deadline
[count]="dashboardService.coursesToRateCount$ | async"
></bkd-dashboard-deadline>
}
</bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="dashboardService.hasStudentRole$ | async"
[label]="'dashboard.actions.my-absences-report'"
[link]="['/my-absences', 'report']"
>
</bkd-dashboard-action>
@if (dashboardService.hasStudentRole$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.my-absences-report'"
[link]="['/my-absences', 'report']"
>
</bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="dashboardService.hasStudentRole$ | async"
[label]="'dashboard.actions.my-absences'"
[link]="['/my-absences']"
[count]="dashboardService.myAbsencesCount$ | async"
></bkd-dashboard-action>
@if (dashboardService.hasStudentRole$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.my-absences'"
[link]="['/my-absences']"
[count]="dashboardService.myAbsencesCount$ | async"
></bkd-dashboard-action>
}

<bkd-dashboard-action
*ngIf="dashboardService.hasSubstituteAdministratorRole$ | async"
[label]="'dashboard.actions.substitutions'"
[externalLink]="substitutionsAdminLink"
></bkd-dashboard-action>
@if (dashboardService.hasSubstituteAdministratorRole$ | async) {
<bkd-dashboard-action
[label]="'dashboard.actions.substitutions'"
[externalLink]="substitutionsAdminLink"
></bkd-dashboard-action>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsyncPipe, NgIf } from "@angular/common";
import { AsyncPipe } from "@angular/common";
import { Component, Inject } from "@angular/core";
import { SETTINGS, Settings } from "../../../settings";
import { DashboardService } from "../../services/dashboard.service";
Expand All @@ -10,12 +10,7 @@ import { DashboardDeadlineComponent } from "../dashboard-deadline/dashboard-dead
templateUrl: "./dashboard-actions.component.html",
styleUrls: ["./dashboard-actions.component.scss"],
standalone: true,
imports: [
NgIf,
DashboardActionComponent,
DashboardDeadlineComponent,
AsyncPipe,
],
imports: [DashboardActionComponent, DashboardDeadlineComponent, AsyncPipe],
})
export class DashboardActionsComponent {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<div
*bkdLet="{
loading: dashboardService.loading$ | async,
hasSearch: dashboardService.hasSearch$ | async,
hasActions: dashboardService.hasActions$ | async,
hasTimetable: dashboardService.hasTimetable$ | async,
} as data"
>
@let loading = dashboardService.loading$ | async;
@let hasSearch = dashboardService.hasSearch$ | async;
@let hasActions = dashboardService.hasActions$ | async;
@let hasTimetable = dashboardService.hasTimetable$ | async;
<div>
<h1
[class.visually-hidden]="
data.loading || data.hasSearch || data.hasActions || data.hasTimetable
"
[class.visually-hidden]="loading || hasSearch || hasActions || hasTimetable"
>
{{ "dashboard.heading" | translate }}
</h1>
<bkd-spinner *ngIf="data.loading"></bkd-spinner>
<p
*ngIf="
!data.loading && !data.hasSearch && !data.hasActions && !data.hasTimetable
"
>
{{ "dashboard.no-access" | translate }}
</p>
@if (loading) {
<bkd-spinner></bkd-spinner>
}
@if (!loading && !hasSearch && !hasActions && !hasTimetable) {
<p>
{{ "dashboard.no-access" | translate }}
</p>
}

<div class="columns">
<div
class="search-actions-column"
*ngIf="data.hasSearch || data.hasActions"
>
<div *ngIf="data.hasSearch">
<h2>{{ "dashboard.search.title" | translate }}</h2>
<bkd-dashboard-search></bkd-dashboard-search>
@if (hasSearch || hasActions) {
<div class="search-actions-column">
@if (hasSearch) {
<div>
<h2>{{ "dashboard.search.title" | translate }}</h2>
<bkd-dashboard-search></bkd-dashboard-search>
</div>
}
@if (hasActions) {
<div>
<h2>{{ "dashboard.actions.title" | translate }}</h2>
<bkd-dashboard-actions></bkd-dashboard-actions>
</div>
}
</div>
<div *ngIf="data.hasActions">
<h2>{{ "dashboard.actions.title" | translate }}</h2>
<bkd-dashboard-actions></bkd-dashboard-actions>
}
@if (hasTimetable) {
<div class="timetable-column">
<h2>{{ "dashboard.timetable.title" | translate }}</h2>
<bkd-dashboard-timetable></bkd-dashboard-timetable>
</div>
</div>
<div *ngIf="data.hasTimetable" class="timetable-column">
<h2>{{ "dashboard.timetable.title" | translate }}</h2>
<bkd-dashboard-timetable></bkd-dashboard-timetable>
</div>
}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AsyncPipe, NgIf } from "@angular/common";
import { AsyncPipe } from "@angular/common";
import { ChangeDetectionStrategy, Component } from "@angular/core";
import { TranslateModule } from "@ngx-translate/core";
import { SpinnerComponent } from "../../../shared/components/spinner/spinner.component";
import { LetDirective } from "../../../shared/directives/let.directive";
import { DashboardService } from "../../services/dashboard.service";
import { DashboardActionsComponent } from "../dashboard-actions/dashboard-actions.component";
import { DashboardSearchComponent } from "../dashboard-search/dashboard-search.component";
Expand All @@ -15,8 +14,6 @@ import { DashboardTimetableComponent } from "../dashboard-timetable/dashboard-ti
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
LetDirective,
NgIf,
SpinnerComponent,
DashboardSearchComponent,
DashboardActionsComponent,
Expand Down
Loading

0 comments on commit 519cc85

Please sign in to comment.