Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(int-value): fix int-value validation (DEV-1277) #815

Merged
merged 2 commits into from Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,7 +5,7 @@
<ng-template #showForm>
<span [formGroup]="form">
<mat-form-field class="large-field child-value-component" floatLabel="never">
<input matInput [formControlName]="'value'" class="value" placeholder="Int value" type="number" [errorStateMatcher]="matcher">
<input matInput [formControlName]="'value'" class="value" placeholder="Int value" [errorStateMatcher]="matcher">
<mat-error *ngIf="valueFormControl.hasError('valueNotChanged') &&
(valueFormControl.touched || valueFormControl.dirty)">
<span class="custom-error-message">New value must be different than the current value.</span>
Expand Down
Expand Up @@ -9,6 +9,8 @@ import { ValueErrorStateMatcher } from '../value-error-state-matcher';
// https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror
const resolvedPromise = Promise.resolve(null);

const DECIMAL_VALUE = 10;

@Component({
selector: 'app-int-value',
templateUrl: './int-value.component.html',
Expand Down Expand Up @@ -87,7 +89,7 @@ export class IntValueComponent extends BaseValueDirective implements OnInit, OnC

const newIntValue = new CreateIntValue();

newIntValue.int = this.valueFormControl.value;
newIntValue.int = parseInt(this.valueFormControl.value, DECIMAL_VALUE);

if (this.commentFormControl.value !== null && this.commentFormControl.value !== '') {
newIntValue.valueHasComment = this.commentFormControl.value;
Expand All @@ -105,7 +107,7 @@ export class IntValueComponent extends BaseValueDirective implements OnInit, OnC

updatedIntValue.id = this.displayValue.id;

updatedIntValue.int = this.valueFormControl.value;
updatedIntValue.int = parseInt(this.valueFormControl.value, DECIMAL_VALUE);

// add the submitted comment to updatedIntValue only if user has added a comment
if (this.commentFormControl.value !== null && this.commentFormControl.value !== '') {
Expand Down