Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lvostinar committed Apr 10, 2024
2 parents a7a5718 + 93f3c1d commit 91f0e1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
1 change: 0 additions & 1 deletion projects/bootstrapcomponents/src/textbox/textbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
[autocomplete]="autocomplete"
[type]="inputType == 'password-with-eye' && showPass ? 'text' : inputType == 'password-with-eye' ? 'password' : inputType"
[findmode]="findmode"
(blur)="dateLostfocus($event)"
/>
<div id="svy-textbox-eyeDiv" *ngIf="inputType == 'password-with-eye'"
(click)="showHidePass()"
Expand Down
34 changes: 4 additions & 30 deletions projects/bootstrapcomponents/src/textbox/textbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,10 @@ export class ServoyBootstrapTextbox extends ServoyBootstrapBasefield<HTMLInputEl

showPass = false;
classForEye = '';
isEditDate = false;

constructor(renderer: Renderer2, cdRef: ChangeDetectorRef, @Inject(DOCUMENT) doc: Document, protected windowService: WindowRefService) {
super(renderer, cdRef, doc);
}

@HostListener('keydown', ['$event'])
onKeyDown(event: KeyboardEvent) {
if (this.isDateType()) {
this.isEditDate = true;
if (event.key === 'Enter') {
this.changeDate();
}
}
}

svyOnInit() {
super.svyOnInit();
Expand All @@ -62,12 +51,15 @@ export class ServoyBootstrapTextbox extends ServoyBootstrapBasefield<HTMLInputEl
}

onModelChange(newValue) {
if (this.isEditDate) return;
// if format or invalid date, force dataprovider display with formated value / invalid date text
if(this.format || (newValue && typeof newValue.getTime === 'function' && isNaN(newValue.getTime()))) {
this.svyFormat.writeValue(newValue);
}
this.dataProviderID = newValue;

if (this.isDateType()) {
this.pushUpdate();
}
}

setInputType(inputType: string) {
Expand Down Expand Up @@ -112,26 +104,8 @@ export class ServoyBootstrapTextbox extends ServoyBootstrapBasefield<HTMLInputEl
}
}

dateLostfocus(event) {
if (this.isDateType()) {
this.changeDate();
}
}

isDateType() {
const types = ['date', 'time', 'datetime-local', 'month', 'week'];
return types.includes(this.inputType);
}

changeDate() {
this.isEditDate = false;
this.svyFormat.input(this.elementRef.nativeElement.value);
this.pushUpdate();
}

pushUpdate() {
if (!this.isEditDate) {
super.pushUpdate();
}
}
}

0 comments on commit 91f0e1c

Please sign in to comment.