From 0180017a339d1d1b39695f530c16fec6c32e444c Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Thu, 9 Nov 2023 08:37:08 +0100 Subject: [PATCH 1/6] Add support for minDate and maxDate for native date picker --- script/component/MaterialIcon.ts | 1 + script/component/form/TextField.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/script/component/MaterialIcon.ts b/script/component/MaterialIcon.ts index a98d79e..e4db8e5 100644 --- a/script/component/MaterialIcon.ts +++ b/script/component/MaterialIcon.ts @@ -761,6 +761,7 @@ export type MaterialIcon = "settings_system_daydream" | "settings_voice" | "share" | + "shield" | "shop" | "shop_two" | "shopping_basket" | diff --git a/script/component/form/TextField.ts b/script/component/form/TextField.ts index 817fb6d..f94d2cc 100644 --- a/script/component/form/TextField.ts +++ b/script/component/form/TextField.ts @@ -39,6 +39,9 @@ export class TextField extends Field { */ public pattern: HTMLInputElement["pattern"] | undefined; + public maxDate: string | undefined; + + public minDate: string | undefined; get input() { return this._input; @@ -84,9 +87,14 @@ export class TextField extends Field { if (name) { this._input.name = name; } - this._input.readOnly = this.readOnly; - + if(this.maxDate) { + this._input.attr("max", this.maxDate); + } + if(this.minDate) { + this._input.attr("min", this.minDate); + } + this._input.readOnly = this.readOnly; if (this.invalidMsg) { this.applyInvalidMsg(); From d905acb9eb9bc03b9a7cca6d9a8ee804a73d2498 Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Fri, 10 Nov 2023 14:17:31 +0100 Subject: [PATCH 2/6] return full response on unsuccesful fetch request --- script/data/RestDataSource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/data/RestDataSource.ts b/script/data/RestDataSource.ts index d262c2b..56b48d9 100644 --- a/script/data/RestDataSource.ts +++ b/script/data/RestDataSource.ts @@ -58,7 +58,7 @@ export class RestDataSource exten return fetch(this.uri + path, baseOpts).then(response => { if (response.status != 200) { - throw response.statusText; + // throw response.body;//.statusText; } return response.json(); From 1ed50f608e48d6fd15f0b65d3f229405c084bd0c Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Thu, 16 Nov 2023 10:35:40 +0100 Subject: [PATCH 3/6] Added icon, add klunky setType function to TextField --- script/component/MaterialIcon.ts | 1 + script/component/form/TextField.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/script/component/MaterialIcon.ts b/script/component/MaterialIcon.ts index e4db8e5..4df8066 100644 --- a/script/component/MaterialIcon.ts +++ b/script/component/MaterialIcon.ts @@ -660,6 +660,7 @@ export type MaterialIcon = "playlist_add_check" | "playlist_play" | "plus_one" | + "policy" | "poll" | "polymer" | "pool" | diff --git a/script/component/form/TextField.ts b/script/component/form/TextField.ts index f94d2cc..0e008c7 100644 --- a/script/component/form/TextField.ts +++ b/script/component/form/TextField.ts @@ -55,6 +55,15 @@ export class TextField extends Field { } } + public setType(t: TextFieldType) { + this.type = t; + if(this._input) { + // Not sure why, but TS / GOUI is setting the _input.type readonly... + // @ts-ignore + this._input.type = t; + } + } + focus(o?: FocusOptions) { if (!this._input) { super.focus(o); From 8f3b2121b609c0826698a278d04f832f175f8ad3 Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Fri, 5 Jan 2024 10:27:13 +0100 Subject: [PATCH 4/6] Material icon --- script/component/MaterialIcon.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/component/MaterialIcon.ts b/script/component/MaterialIcon.ts index 781923d..dbb59f3 100644 --- a/script/component/MaterialIcon.ts +++ b/script/component/MaterialIcon.ts @@ -195,6 +195,7 @@ export type MaterialIcon = "confirmation_number" | "contact_mail" | "contact_phone" | + "contact_support" | "contacts" | "content_copy" | "content_cut" | @@ -605,6 +606,7 @@ export type MaterialIcon = "pause_circle_filled" | "pause_circle_outline" | "payment" | + "pending_actions" | "people" | "people_outline" | "perm_camera_mic" | @@ -724,6 +726,7 @@ export type MaterialIcon = "router" | "rowing" | "rss_feed" | + "rsvp" | "rv_hookup" | "satellite" | "save" | From 3ed9f6894fc7a603a50a0034391cd501c1015996 Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Fri, 12 Jan 2024 09:31:32 +0100 Subject: [PATCH 5/6] Re-remove textfield min/maxdate, restdatasource will return full output upon error --- script/component/form/TextField.ts | 10 ---------- script/data/RestDataSource.ts | 4 ---- 2 files changed, 14 deletions(-) diff --git a/script/component/form/TextField.ts b/script/component/form/TextField.ts index 34f792a..ceee307 100644 --- a/script/component/form/TextField.ts +++ b/script/component/form/TextField.ts @@ -39,10 +39,6 @@ export class TextField extends Field { */ public pattern: HTMLInputElement["pattern"] | undefined; - public maxDate: string | undefined; - - public minDate: string | undefined; - get input() { return this._input; } @@ -100,12 +96,6 @@ export class TextField extends Field { if (name) { this._input.name = name; } - if(this.maxDate) { - this._input.attr("max", this.maxDate); - } - if(this.minDate) { - this._input.attr("min", this.minDate); - } this._input.readOnly = this.readOnly; diff --git a/script/data/RestDataSource.ts b/script/data/RestDataSource.ts index c39d5fc..ba7de8c 100644 --- a/script/data/RestDataSource.ts +++ b/script/data/RestDataSource.ts @@ -57,10 +57,6 @@ export class RestDataSource exten } return fetch(this.uri + path, baseOpts).then(response => { - if (response.status != 200) { - // throw response.body;//.statusText; - } - return response.json(); }); } From e1a3463dd6f10f62a53d1dc8a773cb27ba6fa506 Mon Sep 17 00:00:00 2001 From: Joachim van de Haterd Date: Wed, 7 Feb 2024 11:30:09 +0100 Subject: [PATCH 6/6] Added minLength to autocomplene --- script/component/form/AutocompleteField.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/component/form/AutocompleteField.ts b/script/component/form/AutocompleteField.ts index a6e9579..21c488c 100644 --- a/script/component/form/AutocompleteField.ts +++ b/script/component/form/AutocompleteField.ts @@ -43,6 +43,7 @@ export class AutocompleteField extends TextField { public readonly menu: Menu; protected readonly menuButton: Button; public readonly picker; + public minLength = 0; /** * @@ -189,6 +190,9 @@ export class AutocompleteField extends TextField { } private onInput(ev: KeyboardEvent) { + if(this.input!.value.length <= this.minLength) { + return; + } this.menuButton.showMenu(); this.fire("autocomplete", this, this.input!.value); }