From 987d4420badcb3cfc6be0b87c8ae724735f0f83e Mon Sep 17 00:00:00 2001 From: Akash Shah Date: Wed, 17 Jul 2019 11:27:05 -0400 Subject: [PATCH] restricted input of ' --- .../empty-error-editor.component.ts | 19 ++++++++++++++++++- .../in-det-qty-editor.component.ts | 8 +++++--- .../src/app/customer/customer.component.html | 4 ++-- .../src/app/customer/customer.component.ts | 4 +++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/AstuteClient2/src/app/ag-grid-components/empty-error-editor/empty-error-editor.component.ts b/AstuteClient2/src/app/ag-grid-components/empty-error-editor/empty-error-editor.component.ts index 0d934b1..a156c6b 100644 --- a/AstuteClient2/src/app/ag-grid-components/empty-error-editor/empty-error-editor.component.ts +++ b/AstuteClient2/src/app/ag-grid-components/empty-error-editor/empty-error-editor.component.ts @@ -4,7 +4,7 @@ import {ToastManagerService} from '../../services/toast-manager/toast-service.se @Component({ selector: 'app-empty-error-editor', template: ` - + ` }) export class EmptyErrorEditorComponent implements AfterViewInit { @@ -27,6 +27,23 @@ export class EmptyErrorEditorComponent implements AfterViewInit { return this.textInput.nativeElement.value; } + onKeyPress(event) { + if (event.key === '\'') { + event.preventDefault(); + this.notif('Cannot use \' (apostrophes)'); + setTimeout(() => { + this.textInput.nativeElement.focus(); + }); + } + if (event.key === '\'') { + event.preventDefault(); + this.notif('Cannot use \' (apostrophes)'); + setTimeout(() => { + this.textInput.nativeElement.focus(); + }); + } + } + onKeyDown(event) { if (event.keyCode === 9 || event.keyCode === 13) { if (!this.textInput.nativeElement.value) { diff --git a/AstuteClient2/src/app/ag-grid-components/in-det-qty-editor/in-det-qty-editor.component.ts b/AstuteClient2/src/app/ag-grid-components/in-det-qty-editor/in-det-qty-editor.component.ts index 4432bbc..323bc71 100644 --- a/AstuteClient2/src/app/ag-grid-components/in-det-qty-editor/in-det-qty-editor.component.ts +++ b/AstuteClient2/src/app/ag-grid-components/in-det-qty-editor/in-det-qty-editor.component.ts @@ -4,7 +4,7 @@ import {ToastManagerService} from '../../services/toast-manager/toast-service.se @Component({ selector: 'app-in-det-qty-editor', template: ` - + ` }) export class InDetQtyEditorComponent implements AfterViewInit { @@ -37,9 +37,11 @@ export class InDetQtyEditorComponent implements AfterViewInit { setTimeout(() => { this.numberInput.nativeElement.focus(); }); - } else if (this.numberInput.nativeElement.value < 0 || this.numberInput.nativeElement.value > this.remainingQty) { + } else if (!(this.numberInput.nativeElement.value >= 0 + && parseInt((this.numberInput.nativeElement.value * 100000).toFixed(0), 10) - + parseInt((this.remainingQty * 100000).toFixed(0), 10) <= 1)) { event.stopPropagation(); - this.notif('Value should between 0 and ' + this.remainingQty); + this.notif('Value should between 0 and ' + this.remainingQty.toPrecision(2)); setTimeout(() => { this.numberInput.nativeElement.focus(); }); diff --git a/AstuteClient2/src/app/customer/customer.component.html b/AstuteClient2/src/app/customer/customer.component.html index a1e7cc1..3a8f707 100644 --- a/AstuteClient2/src/app/customer/customer.component.html +++ b/AstuteClient2/src/app/customer/customer.component.html @@ -45,7 +45,7 @@ ID* - + @@ -135,7 +135,7 @@ - Ext* + Ext diff --git a/AstuteClient2/src/app/customer/customer.component.ts b/AstuteClient2/src/app/customer/customer.component.ts index a0c0fd5..92dcb76 100644 --- a/AstuteClient2/src/app/customer/customer.component.ts +++ b/AstuteClient2/src/app/customer/customer.component.ts @@ -32,7 +32,7 @@ export class CustomerComponent implements OnInit { {headerName: 'Address 2 ✎', field: 'add2', editable: true, cellEditor: 'emptyErrorEditorComponent'}, {headerName: 'City ✎', field: 'city', editable: true, cellEditor: 'emptyErrorEditorComponent'}, {headerName: 'State ✎', field: 'state', editable: true, cellEditor: 'emptyErrorEditorComponent'}, - {headerName: 'ZIP ✎', field: 'zip', editable: true, cellEditor: 'emptyErrorEditorComponent'}, + {headerName: 'ZIP ✎', field: 'zip', editable: true, cellEditor: 'numericEditorComponent'}, {headerName: 'ZIP-4 ✎', field: 'ziplast4', editable: true, cellEditor: 'numericEditorComponent'} ]; frameworkComponents = { @@ -109,6 +109,8 @@ export class CustomerComponent implements OnInit { {headerName: 'Address ✎', field: 'address', editable: true} ]; + idMask = [/[^']/, /[^']/, /[^']/, /[^']/, /[^']/, /[^']/, /[^']/, /[^']/, /[^']/, /[^']/]; + // address: "123 Test Drive" // contactId: 1 // customerId: "MDOT"