From 3a3dc920857c3984fb21040d84077d13c5bd08ce Mon Sep 17 00:00:00 2001 From: dysTOS Date: Fri, 19 Jan 2024 13:57:55 +0100 Subject: [PATCH] fix date-input --- package-lock.json | 14 ++++---- package.json | 2 +- .../termin-details.component.ts | 13 ++++++- .../termine-overview.component.ts | 2 +- .../mkj-date-input.component.html | 23 +++++++++++-- .../mkj-date-input.component.ts | 34 +++++++++++++++++-- 6 files changed, 72 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37978be..2f7dd5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "normalize.css": "^8.0.1", "primeflex": "3.3", "primeicons": "^6.0.1", - "primeng": "^17.3.2", + "primeng": "^17.3.3", "prismjs": "^1.27.0", "rxjs": "^7.4.0", "subsink": "^1.0.2", @@ -13027,9 +13027,9 @@ "integrity": "sha512-KDeO94CbWI4pKsPnYpA1FPjo79EsY9I+M8ywoPBSf9XMXoe/0crjbUK7jcQEDHuc0ZMRIZsxH3TYLv4TUtHmAA==" }, "node_modules/primeng": { - "version": "17.3.2", - "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.3.2.tgz", - "integrity": "sha512-QFnh2YWTE3jeyfMLKpLHY/mSI4z1KZbXWDS+fFJdwVut8+E9iSHxDVLPF0fHyljKByAqvUF4fP2/F3JSYdF6cg==", + "version": "17.3.3", + "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.3.3.tgz", + "integrity": "sha512-Bdm8BGMAwz51mppbB6tt+kVliVR6h8G3uOVXLFwzMQLMGEQezefnT0ywmWuJEicpS8Se7PRqP7U3hzLW+pi3EQ==", "dependencies": { "tslib": "^2.3.0" }, @@ -26126,9 +26126,9 @@ "integrity": "sha512-KDeO94CbWI4pKsPnYpA1FPjo79EsY9I+M8ywoPBSf9XMXoe/0crjbUK7jcQEDHuc0ZMRIZsxH3TYLv4TUtHmAA==" }, "primeng": { - "version": "17.3.2", - "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.3.2.tgz", - "integrity": "sha512-QFnh2YWTE3jeyfMLKpLHY/mSI4z1KZbXWDS+fFJdwVut8+E9iSHxDVLPF0fHyljKByAqvUF4fP2/F3JSYdF6cg==", + "version": "17.3.3", + "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.3.3.tgz", + "integrity": "sha512-Bdm8BGMAwz51mppbB6tt+kVliVR6h8G3uOVXLFwzMQLMGEQezefnT0ywmWuJEicpS8Se7PRqP7U3hzLW+pi3EQ==", "requires": { "tslib": "^2.3.0" } diff --git a/package.json b/package.json index 3c89372..6f17e6b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "normalize.css": "^8.0.1", "primeflex": "3.3", "primeicons": "^6.0.1", - "primeng": "^17.3.2", + "primeng": "^17.3.3", "prismjs": "^1.27.0", "rxjs": "^7.4.0", "subsink": "^1.0.2", diff --git a/src/app/components/termine/termin-details/termin-details.component.ts b/src/app/components/termine/termin-details/termin-details.component.ts index c8c83f7..5623f99 100644 --- a/src/app/components/termine/termin-details/termin-details.component.ts +++ b/src/app/components/termine/termin-details/termin-details.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from "@angular/core"; -import { ActivatedRoute } from "@angular/router"; +import { ActivatedRoute, Router } from "@angular/router"; import { MenuItem } from "primeng/api"; import { Menu } from "primeng/menu"; import { Mitglied } from "src/app/models/Mitglied"; @@ -13,6 +13,7 @@ import { ExportService } from "../../../services/export.service"; import { NotenListDatasource } from "src/app/utilities/_list-datasources/noten-list-datasource.class"; import { NotenAutoCompleteConfigiguration } from "src/app/utilities/_autocomplete-configurations/noten-autocomplete-config.class"; import { AppConfigService } from "src/app/services/app-config.service"; +import { PermissionMap } from "src/app/models/User"; @Component({ selector: "app-termin-details", @@ -50,6 +51,7 @@ export class TerminDetailsComponent implements OnInit { constructor( public notenDatasource: NotenListDatasource, public configService: AppConfigService, + private router: Router, private route: ActivatedRoute, private termineApiService: TermineApiService, private infoService: InfoService, @@ -77,6 +79,15 @@ export class TerminDetailsComponent implements OnInit { public updateToolbarButtons() { this.toolbarService.buttons = [ + { + icon: "pi pi-pencil", + label: "Bearbeiten", + permissions: [PermissionMap.TERMIN_SAVE], + click: () => + this.router.navigate(["../../", this.termin.id], { + relativeTo: this.route, + }), + }, { icon: "pi pi-download", label: "Exportieren", diff --git a/src/app/components/termine/termine-overview/termine-overview.component.ts b/src/app/components/termine/termine-overview/termine-overview.component.ts index 8a57ee2..1d63681 100644 --- a/src/app/components/termine/termine-overview/termine-overview.component.ts +++ b/src/app/components/termine/termine-overview/termine-overview.component.ts @@ -46,7 +46,7 @@ export class TermineOverviewComponent { command: () => this.duplicateAusrueckung(this.selectedRow), }, { - label: "Editieren", + label: "Bearbeiten", icon: "pi pi-pencil", visible: this.userService.hasOneOfPermissions([ PermissionMap.TERMIN_SAVE, diff --git a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.html b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.html index fbb9557..b55d456 100644 --- a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.html +++ b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.html @@ -1,21 +1,38 @@ + diff --git a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts index 14a2ce0..6fc8692 100644 --- a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts +++ b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts @@ -9,6 +9,7 @@ import { import { controlValueAccessor } from "src/app/providers/control-value-accessor"; import moment from "moment"; import { ControlValueAccessor, FormControl, NgControl } from "@angular/forms"; +import { UtilFunctions } from "src/app/helpers/util-functions"; export enum MkjDateType { DATE = "date", @@ -42,6 +43,8 @@ export class MkjDateInputComponent public _registerOnChange: (_: any) => void; public _registerOnTouched: () => void; public isDisabled: boolean = false; + public isDesktop: boolean = UtilFunctions.isDesktop(); + public nativeModel: string; private _value: string | Date; @Input() @@ -70,22 +73,21 @@ export class MkjDateInputComponent writeValue(obj: any): void { if (obj) { + this.nativeModel = obj; switch (this.type) { case MkjDateType.DATE: this.internModel = new Date(obj); - break; case MkjDateType.TIME: this.internModel = obj; - break; case MkjDateType.COMBINED: this.internModel = new Date(obj); - break; } } else { this.internModel = null; + this.nativeModel = null; } } @@ -108,6 +110,32 @@ export class MkjDateInputComponent return; } + switch (this.type) { + case MkjDateType.DATE: + const date = moment(newDate).format("YYYY-MM-DD"); + this.valueChanged.emit(date); + this._registerOnChange?.(date); + break; + case MkjDateType.TIME: + const time = moment(newDate).format("hh:mm"); + this.valueChanged.emit(time); + this._registerOnChange?.(time); + break; + case MkjDateType.COMBINED: + const combined = moment(newDate).format("YYYY-MM-DD hh:mm:ss"); + this.valueChanged.emit(date); + this._registerOnChange?.(combined); + break; + } + } + + public onNativeModelChange(newDate: string) { + if (!newDate) { + this.valueChanged.emit(null); + this._registerOnChange?.(null); + return; + } + switch (this.type) { case MkjDateType.DATE: const date = moment(newDate).format("YYYY-MM-DD");