Conversation
|
@t-anjam, |
| return { | ||
| validJsonConfig: { | ||
| valid: false, | ||
| message: "FormControl is invalid", |
There was a problem hiding this comment.
Change the message here to contain what the error is(Look into the parameterValue.errors)
| const valid = this.parameterValue.valid; | ||
| if (valid) { return null; } | ||
| return { | ||
| validJsonConfig: { |
| } | ||
|
|
||
| public isFormValid() { | ||
| return (this.modeState === Modes.NewPoolAndJob && this.jobParams.valid && this.poolParams.valid) || |
There was a problem hiding this comment.
you should just be able to have this.form.valid instead of this
There was a problem hiding this comment.
Different mode will have different conditions for submit
| for (let key of templateParameters) { | ||
| if (template.parameters[key].defaultValue) { | ||
| const defaultValue = String(template.parameters[key].defaultValue); | ||
| templateFormGroup[key] = new FormControl(defaultValue, Validators.required ); |
There was a problem hiding this comment.
don't create the control twice here, do just set the default value to null if needed
| <div [title]="getToolTip()" class="submit-box" *ngIf="modeState !== Modes.None"> | ||
| <bl-server-error [error]="error"> </bl-server-error> | ||
| <bl-button [action]="submit" type="wide" class="submit-job" color="success"> | ||
| <bl-button [disabled]="!isFormValid()" [action]="submit" type="wide" class="submit-job" color="success"> |
There was a problem hiding this comment.
make the tooltip here instead of being on the outer div. also make it a getter public get submitTooltip() instead of a function
|
|
||
| it("should validate minimum value constraint", () => { | ||
| const input = 5; | ||
| testComponent.param = new NcjParameterWrapper("frameEnd", { |
There was a problem hiding this comment.
for those test add the param restriction in the beforeEach() so you have less duplicate and just include both restriction at the same time.
| expect(inputEl.nativeElement.value).toBe(updatedInput); | ||
| }); | ||
|
|
||
| it("should validate minimum length constraint", () => { |
There was a problem hiding this comment.
You should also check for the error message
| } else { | ||
| let messageText = "unknown error"; | ||
| if (this.parameterValue.errors.minlength) { | ||
| messageText = "FormControl minLength error"; |
There was a problem hiding this comment.
use the message provided don't rewrite it. Here you are losing information.
There was a problem hiding this comment.
will add more detail to error message
| let messageText = "unknown error"; | ||
| if (this.parameterValue.errors.minlength) { | ||
| messageText = "FormControl minLength error:"; | ||
| messageText = messageText + " minlength: " + this.parameterValue.errors.minlength.requiredLength; |
There was a problem hiding this comment.
Save this.parameterValue.errors in a local variable so you don't have to repeat all that.
Also make the message look nicer like "Should be at least x characters`
There was a problem hiding this comment.
And try to use string interpolation ${} instead of +
| const error = this.parameterValue.errors; | ||
| if (error.minlength) { | ||
| const minLength = String(error.minlength.requiredLength); | ||
| messageText = `Should be atleast ${minLength} characters`; |
There was a problem hiding this comment.
at least and at most below
| messageText = `Should be atmost ${maxLength} characters`; | ||
| } else if (error.min) { | ||
| const minValue = String(error.min.min); | ||
| messageText = `Should be greater than ${minValue}`; |
| messageText = `Should be greater than ${minValue}`; | ||
| } else if (this.parameterValue.errors.max) { | ||
| const maxValue = String(error.max.max); | ||
| messageText = `Should be less than ${maxValue}`; |
|
|
||
| public get submitToolTip(): string { | ||
| if (this.isFormValid()) { | ||
| return "Click to submit form"; |
There was a problem hiding this comment.
Change to "Click to submit job"
There was a problem hiding this comment.
This tooltip text will also be displayed when user is in pool only mode.
| if (valid) { | ||
| return null; | ||
| } else { | ||
| let messageText = `unknown error`; |
There was a problem hiding this comment.
Nitpick: I noticed below you are using "" instead of ``. Any reason in particular?
Example:
return "Click to submit form";There was a problem hiding this comment.
should actually use `` only if using interpolation. Use "" otherwise
Added validation to the NCJ form. Able to validate for required, minValue, maxValue, minLength, and maxLength. Run button only turns on when form is valid. Also added tool tip to run button. Added unit tests.