Skip to content
Snippets Groups Projects
Commit c17b2572 authored by François Grand's avatar François Grand
Browse files

fix: pab-table input: fix separator (.) for decimal value

refs #628
parent 851e23e8
No related branches found
No related tags found
1 merge request!229Resolve "Le séparateur décimal est passé à la virgule sur certaines configurations"
350-modifier-l-avertissement-de-limite-d-ennoiement-de-villemonte devel
...@@ -86,9 +86,9 @@ ...@@ -86,9 +86,9 @@
[class.select]="isSelect(cell)" [attr.rowspan]="rowSpan(cell)" [attr.colspan]="colSpan(cell)" [class.select]="isSelect(cell)" [attr.rowspan]="rowSpan(cell)" [attr.colspan]="colSpan(cell)"
[title]="cellTitle(cell)"> [title]="cellTitle(cell)">
<input matInput *ngIf="isNumberInput(cell)" step="0.00000000000001" type="number" required <input matInput *ngIf="isNumberInput(cell)" type="text" required
[ngModel]="getCellValue(cell)" (ngModelChange)="setCellValue(cell,$event)" [ngModel]="getCellValue(cell)" (ngModelChange)="setCellValue(cell,$event)"
(input)="inputValueChanged($event, cell)"> (input)="inputValueChanged($event, cell)" (keypress) ="invalidNANInputValue($event)">
<mat-select #selectWidget *ngIf="isSelect(cell)" [value]="cell.modelValue" <mat-select #selectWidget *ngIf="isSelect(cell)" [value]="cell.modelValue"
(selectionChange)="loiDebitSelected($event, cell)"> (selectionChange)="loiDebitSelected($event, cell)">
......
...@@ -1388,12 +1388,24 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni ...@@ -1388,12 +1388,24 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
return round(cell.model.singleValue, this.nDigits); return round(cell.model.singleValue, this.nDigits);
} }
public setCellValue(cell, event) { public setCellValue(cell, $event) {
try { if (/^-?[0-9]*\.?[0-9]*$/g.test($event) === false) {
cell.model.singleValue = event $event = $event.replace(/[^0-9\-.]/g, '');
cell.modelValidity = undefined; }
} catch (error) { if($event !== "-" && $event !== "") {
cell.modelValidity = false; try {
cell.model.singleValue = $event;
cell.modelValidity = undefined;
} catch (error) {
cell.modelValidity = false
}
}
}
public invalidNANInputValue(e: any) {
var rgx = /^-?[0-9]*\.?[0-9]*$/;
if(e.key.match(rgx) === null) {
e.preventDefault();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment