diff --git a/angular.json b/angular.json index f39f78efcb..8f6b059d48 100644 --- a/angular.json +++ b/angular.json @@ -36,10 +36,7 @@ "node_modules/leaflet/dist/leaflet.css" ], "stylePreprocessorOptions": { - "includePaths": [ - "node_modules/", - "src/styles" - ] + "includePaths": ["node_modules/", "src/styles"] }, "vendorChunk": true, "extractLicenses": false, @@ -105,20 +102,14 @@ "builder": "@angular-devkit/build-angular:karma", "options": { "karmaConfig": "./karma.conf.js", - "polyfills": [ - "src/polyfills.ts", - "zone.js/testing" - ], + "polyfills": ["src/polyfills.ts", "zone.js/testing"], "tsConfig": "src/tsconfig.spec.json", "styles": [ "src/styles/styles.scss", "src/styles/themes/ndb-theme.scss" ], "stylePreprocessorOptions": { - "includePaths": [ - "node_modules/", - "src/styles" - ] + "includePaths": ["node_modules/", "src/styles"] }, "assets": [ "src/assets", @@ -152,10 +143,7 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": [ - "src/**/*.ts", - "src/**/*.html" - ] + "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } }, "cypress-open": { @@ -199,8 +187,6 @@ }, "cli": { "analytics": "0bd2cce5-bfb0-4375-af96-a8222d782810", - "schematicCollections": [ - "@angular-eslint/schematics" - ] + "schematicCollections": ["@angular-eslint/schematics"] } } diff --git a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.html b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.html index f801786c3a..e0c5fd0e8a 100644 --- a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.html +++ b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.html @@ -1,76 +1,59 @@ - - -
- - - - - - - - -
+ + + + + + + + + + + + - + + + + + + - - - + +
+ + +
- -
-
- - - -
-
-
-
no absences recorded
- - -
-
+ + diff --git a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.spec.ts b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.spec.ts index 2c5ce30059..d9b7e87bd1 100644 --- a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.spec.ts +++ b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.spec.ts @@ -71,8 +71,7 @@ describe("AttendanceWeekDashboardComponent", () => { await component.ngOnInit(); - expect(component.loadingDone).toBeTrue(); - expect(component.tableDataSource.data).toEqual([ + expect(component.entries).toEqual([ [ { childId: absentChild.getId(), diff --git a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.ts b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.ts index 2778c7310d..08039dc1ef 100644 --- a/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.ts +++ b/src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.ts @@ -1,10 +1,4 @@ -import { - AfterViewInit, - Component, - Input, - OnInit, - ViewChild, -} from "@angular/core"; +import { Component, Input, OnInit } from "@angular/core"; import { Router } from "@angular/router"; import { Child } from "../../../children/model/child"; import { AttendanceLogicalStatus } from "../../model/attendance-status"; @@ -14,16 +8,14 @@ import { ActivityAttendance } from "../../model/activity-attendance"; import { RecurringActivity } from "../../model/recurring-activity"; import moment, { Moment } from "moment"; import { groupBy } from "../../../../utils/utils"; -import { MatTableDataSource, MatTableModule } from "@angular/material/table"; -import { MatPaginator, MatPaginatorModule } from "@angular/material/paginator"; +import { MatTableModule } from "@angular/material/table"; import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator"; import { NgForOf, NgIf } from "@angular/common"; import { DisplayEntityComponent } from "../../../../core/basic-datatypes/entity/display-entity/display-entity.component"; -import { DashboardWidgetComponent } from "../../../../core/dashboard/dashboard-widget/dashboard-widget.component"; import { AttendanceDayBlockComponent } from "./attendance-day-block/attendance-day-block.component"; -import { WidgetContentComponent } from "../../../../core/dashboard/dashboard-widget/widget-content/widget-content.component"; import { DashboardWidget } from "../../../../core/dashboard/dashboard-widget/dashboard-widget"; import { EventNote } from "../../model/event-note"; +import { DashboardListWidgetComponent } from "../../../../core/dashboard/dashboard-list-widget/dashboard-list-widget.component"; interface AttendanceWeekRow { childId: string; @@ -36,21 +28,19 @@ interface AttendanceWeekRow { selector: "app-attendance-week-dashboard", templateUrl: "./attendance-week-dashboard.component.html", styleUrls: ["./attendance-week-dashboard.component.scss"], + standalone: true, imports: [ NgIf, MatTableModule, NgForOf, - MatPaginatorModule, DisplayEntityComponent, - DashboardWidgetComponent, - WidgetContentComponent, AttendanceDayBlockComponent, + DashboardListWidgetComponent, ], - standalone: true, }) export class AttendanceWeekDashboardComponent extends DashboardWidget - implements OnInit, AfterViewInit + implements OnInit { static getRequiredEntities() { return EventNote.ENTITY_TYPE; @@ -90,10 +80,7 @@ export class AttendanceWeekDashboardComponent */ @Input() attendanceStatusType: string; - @ViewChild("paginator") paginator: MatPaginator; - tableDataSource = new MatTableDataSource(); - - loadingDone = false; + entries: AttendanceWeekRow[][]; constructor( private attendanceService: AttendanceService, @@ -137,10 +124,9 @@ export class AttendanceWeekDashboardComponent } const groups = groupBy(records, "childId"); - this.tableDataSource.data = groups + this.entries = groups .filter(([childId]) => lowAttendanceCases.has(childId)) .map(([_, attendance]) => attendance); - this.loadingDone = true; } private generateRowsFromActivityAttendance( @@ -196,8 +182,4 @@ export class AttendanceWeekDashboardComponent goToChild(childId: string) { this.router.navigate([Child.route, childId]); } - - ngAfterViewInit() { - this.tableDataSource.paginator = this.paginator; - } } diff --git a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.html b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.html index b7dd268cac..bed67fd18d 100644 --- a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.html +++ b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.html @@ -1,47 +1,45 @@ - - -
- - - - - - - - - +
+
- -
+ + + + + + + + + + + + - - - + +
+ + + + >  + + {{ entityNoteInfo.daysSinceLastNote | number: "1.0-0" }} days + - - >  - - {{ entityNoteInfo.daysSinceLastNote | number: "1.0-0" }} days -
- - -
-
+
- - - +
+ diff --git a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.spec.ts b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.spec.ts index f62ed2e634..1547930e35 100644 --- a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.spec.ts +++ b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.spec.ts @@ -59,7 +59,7 @@ describe("NotesDashboardComponent", () => { component.ngOnInit(); tick(); - expect(component.dataSource.data).toHaveSize(3); + expect(component.entries).toHaveSize(3); })); }); @@ -92,9 +92,9 @@ describe("NotesDashboardComponent", () => { tick(); - expect(component.dataSource.data).toHaveSize(3); + expect(component.entries).toHaveSize(3); - expect(component.dataSource.data[0]).toEqual({ + expect(component.entries[0]).toEqual({ entityId: "5", daysSinceLastNote: 50, moreThanDaysSince: false, @@ -110,11 +110,11 @@ describe("NotesDashboardComponent", () => { component.ngOnInit(); tick(); - expect(component.dataSource.data).toHaveSize(1); + expect(component.entries).toHaveSize(1); - expect(component.dataSource.data[0].entityId).toBe(childId1); - expect(component.dataSource.data[0].moreThanDaysSince).toBeTrue(); - expect(component.dataSource.data[0].daysSinceLastNote).toBeFinite(); + expect(component.entries[0].entityId).toBe(childId1); + expect(component.entries[0].moreThanDaysSince).toBeTrue(); + expect(component.entries[0].daysSinceLastNote).toBeFinite(); })); it("should load notes related to the configured entity", () => { diff --git a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.ts b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.ts index 1329575419..32ea5ff410 100644 --- a/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.ts +++ b/src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.ts @@ -1,24 +1,16 @@ -import { - AfterViewInit, - Component, - Input, - OnInit, - ViewChild, -} from "@angular/core"; +import { Component, Input, OnInit } from "@angular/core"; import { ChildrenService } from "../../../children/children.service"; import moment from "moment"; -import { MatTableDataSource, MatTableModule } from "@angular/material/table"; -import { MatPaginator, MatPaginatorModule } from "@angular/material/paginator"; +import { MatTableModule } from "@angular/material/table"; import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator"; import { Child } from "../../../children/model/child"; import { EntityRegistry } from "../../../../core/entity/database-entity.decorator"; import { EntityConstructor } from "../../../../core/entity/model/entity"; import { DecimalPipe, NgIf } from "@angular/common"; import { DisplayEntityComponent } from "../../../../core/basic-datatypes/entity/display-entity/display-entity.component"; -import { DashboardWidgetComponent } from "../../../../core/dashboard/dashboard-widget/dashboard-widget.component"; -import { WidgetContentComponent } from "../../../../core/dashboard/dashboard-widget/widget-content/widget-content.component"; import { DashboardWidget } from "../../../../core/dashboard/dashboard-widget/dashboard-widget"; import { Note } from "../../model/note"; +import { DashboardListWidgetComponent } from "../../../../core/dashboard/dashboard-list-widget/dashboard-list-widget.component"; interface NotesDashboardConfig { entity?: string; @@ -38,20 +30,18 @@ interface NotesDashboardConfig { selector: "app-no-recent-notes-dashboard", templateUrl: "./notes-dashboard.component.html", styleUrls: ["./notes-dashboard.component.scss"], + standalone: true, imports: [ NgIf, MatTableModule, DisplayEntityComponent, DecimalPipe, - MatPaginatorModule, - DashboardWidgetComponent, - WidgetContentComponent, + DashboardListWidgetComponent, ], - standalone: true, }) export class NotesDashboardComponent extends DashboardWidget - implements OnInit, AfterViewInit, NotesDashboardConfig + implements OnInit, NotesDashboardConfig { static getRequiredEntities(config: NotesDashboardConfig) { return config?.entity || Note.ENTITY_TYPE; @@ -78,14 +68,10 @@ export class NotesDashboardComponent /** * Entities displayed in the template with additional "daysSinceLastNote" field */ - dataSource = new MatTableDataSource(); + entries: EntityWithRecentNoteInfo[]; subtitle: string; - @ViewChild("paginator") paginator: MatPaginator; - - isLoading = true; - constructor( private childrenService: ChildrenService, private entities: EntityRegistry, @@ -116,10 +102,6 @@ export class NotesDashboardComponent } } - ngAfterViewInit() { - this.dataSource.paginator = this.paginator; - } - private async loadConcernedEntities( filter: (stat: [string, number]) => boolean, dayRangeBoundary: number, @@ -133,12 +115,10 @@ export class NotesDashboardComponent this._entity.ENTITY_TYPE, queryRange, ); - this.dataSource.data = Array.from(recentNotesMap) + this.entries = Array.from(recentNotesMap) .filter(filter) .map((stat) => statsToEntityWithRecentNoteInfo(stat, queryRange)) .sort((a, b) => order * (b.daysSinceLastNote - a.daysSinceLastNote)); - - this.isLoading = false; } get tooltip(): string { diff --git a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.html b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.html index 9824d9f747..ea31f4a2af 100644 --- a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.html +++ b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.html @@ -1,51 +1,36 @@ - - -
- - no birthdays in the next {{ threshold - 1 }} days - -
-
- - - - - - - - - - - - - - - - -
- - - {{ entity.birthday | date: "E dd.MM" }} - {{ entity.newAge }} yrs
-
- - -
-
+
+ + + + + + + + + + + + + + + + +
+ + + {{ entity.birthday | date: "E dd.MM" }} + {{ entity.newAge }} yrs
+
+ diff --git a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.spec.ts b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.spec.ts index f058325831..1903e95c5d 100644 --- a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.spec.ts +++ b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.spec.ts @@ -65,7 +65,7 @@ describe("BirthdayDashboardComponent", () => { tick(); const expectedNextBirthday = birthdaySoon.add(10, "years"); - expect(component.dataSource.data).toEqual([ + expect(component.entries).toEqual([ { entity: child1, birthday: expectedNextBirthday.toDate(), newAge: 10 }, ]); })); @@ -90,7 +90,7 @@ describe("BirthdayDashboardComponent", () => { const expectedFirstBirthday = firstBirthday.add(12, "years"); const expectedSecondBirthday = secondBirthday.add(15, "years"); - expect(component.dataSource.data).toEqual([ + expect(component.entries).toEqual([ { entity: child1, birthday: expectedFirstBirthday.toDate(), newAge: 12 }, { entity: child2, birthday: expectedSecondBirthday.toDate(), newAge: 15 }, ]); @@ -123,7 +123,7 @@ describe("BirthdayDashboardComponent", () => { component.ngOnInit(); tick(); - expect(component.dataSource.data).toEqual([ + expect(component.entries).toEqual([ { entity: e1, birthday: moment().add(1, "day").startOf("day").toDate(), diff --git a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.ts b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.ts index 69610e9273..c53d14b9f7 100644 --- a/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.ts +++ b/src/app/features/dashboard-widgets/birthday-dashboard-widget/birthday-dashboard/birthday-dashboard.component.ts @@ -1,21 +1,14 @@ -import { - AfterViewInit, - Component, - Input, - OnInit, - ViewChild, -} from "@angular/core"; +import { Component, Input, OnInit } from "@angular/core"; import { EntityMapperService } from "../../../../core/entity/entity-mapper/entity-mapper.service"; import { Child } from "../../../../child-dev-project/children/model/child"; import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator"; -import { MatTableDataSource, MatTableModule } from "@angular/material/table"; -import { MatPaginator, MatPaginatorModule } from "@angular/material/paginator"; +import { MatTableModule } from "@angular/material/table"; import { Entity } from "../../../../core/entity/model/entity"; import { DatePipe, NgIf } from "@angular/common"; import { DisplayEntityComponent } from "../../../../core/basic-datatypes/entity/display-entity/display-entity.component"; -import { DashboardWidgetComponent } from "../../../../core/dashboard/dashboard-widget/dashboard-widget.component"; -import { WidgetContentComponent } from "../../../../core/dashboard/dashboard-widget/widget-content/widget-content.component"; + import { DashboardWidget } from "../../../../core/dashboard/dashboard-widget/dashboard-widget"; +import { DashboardListWidgetComponent } from "../../../../core/dashboard/dashboard-list-widget/dashboard-list-widget.component"; interface BirthdayDashboardConfig { entities: EntityPropertyMap; @@ -27,26 +20,23 @@ interface BirthdayDashboardConfig { selector: "app-birthday-dashboard", templateUrl: "./birthday-dashboard.component.html", styleUrls: ["./birthday-dashboard.component.scss"], + standalone: true, imports: [ NgIf, MatTableModule, DisplayEntityComponent, DatePipe, - MatPaginatorModule, - DashboardWidgetComponent, - WidgetContentComponent, + DashboardListWidgetComponent, ], - standalone: true, }) export class BirthdayDashboardComponent extends DashboardWidget - implements BirthdayDashboardConfig, OnInit, AfterViewInit + implements BirthdayDashboardConfig, OnInit { static getRequiredEntities(config: BirthdayDashboardConfig) { return config?.entities ? Object.keys(config.entities) : Child.ENTITY_TYPE; } - @ViewChild(MatPaginator) paginator: MatPaginator; private readonly today: Date; /** @@ -64,8 +54,7 @@ export class BirthdayDashboardComponent */ @Input() threshold = 32; - dataSource = new MatTableDataSource(); - isLoading = true; + entries: EntityWithBirthday[]; constructor(private entityMapper: EntityMapperService) { super(); @@ -91,12 +80,7 @@ export class BirthdayDashboardComponent data.sort( (a, b) => this.daysUntil(a.birthday) - this.daysUntil(b.birthday), ); - this.dataSource.data = data; - this.isLoading = false; - } - - ngAfterViewInit() { - this.dataSource.paginator = this.paginator; + this.entries = data; } private getNextBirthday(dateOfBirth: Date): Date { diff --git a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.html b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.html index cbf45a7d32..e1debc6bc1 100644 --- a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.html +++ b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.html @@ -1,13 +1,13 @@ - - +
@@ -50,5 +50,5 @@ - - + + diff --git a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.scss b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.scss index 36511c292b..3ac3adfea4 100644 --- a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.scss +++ b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.scss @@ -15,4 +15,8 @@ position: absolute; left: 0; bottom: 0; + margin: 4px; +} +.widget-container { + position: relative; } diff --git a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.ts b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.ts index 71d7268521..b852f7e699 100644 --- a/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.ts +++ b/src/app/features/dashboard-widgets/progress-dashboard-widget/progress-dashboard/progress-dashboard.component.ts @@ -13,25 +13,23 @@ import { MatTableModule } from "@angular/material/table"; import { MatProgressBarModule } from "@angular/material/progress-bar"; import { MatButtonModule } from "@angular/material/button"; import { FontAwesomeModule } from "@fortawesome/angular-fontawesome"; -import { DashboardWidgetComponent } from "../../../../core/dashboard/dashboard-widget/dashboard-widget.component"; -import { WidgetContentComponent } from "../../../../core/dashboard/dashboard-widget/widget-content/widget-content.component"; import { SyncStateSubject } from "../../../../core/session/session-type"; import { DashboardWidget } from "../../../../core/dashboard/dashboard-widget/dashboard-widget"; +import { DashboardListWidgetComponent } from "../../../../core/dashboard/dashboard-list-widget/dashboard-list-widget.component"; @Component({ selector: "app-progress-dashboard", templateUrl: "./progress-dashboard.component.html", styleUrls: ["./progress-dashboard.component.scss"], + standalone: true, imports: [ PercentPipe, MatTableModule, MatProgressBarModule, MatButtonModule, FontAwesomeModule, - DashboardWidgetComponent, - WidgetContentComponent, + DashboardListWidgetComponent, ], - standalone: true, }) @DynamicComponent("ProgressDashboard") export class ProgressDashboardComponent