Skip to content

Commit

Permalink
chore(demo): InputDateTime simplify example
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 27, 2024
1 parent 8629cfb commit b23af89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ describe('InputDateTime', () => {
await inputDateTime.textfield.fill('11');
await inputDateTime.textfield.blur();

// allow animations to capture tui-error validation message on screenshot
await expect(example).toHaveScreenshot(
'04-input-data-time-with-validator.png',
{animations: 'allow'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<form [formGroup]="testForm">
<tui-input-date-time formControlName="testValue">Choose date and time</tui-input-date-time>
<tui-error
formControlName="testValue"
[error]="[] | tuiFieldError | async"
></tui-error>
<tui-input-date-time [formControl]="control">Choose date and time</tui-input-date-time>
<tui-error
[error]="[] | tuiFieldError | async"
[formControl]="control"
></tui-error>

<p>Form value:</p>
<p>Form value:</p>

<pre><code>{{ testForm.value | json }}</code></pre>
</form>
<pre><code>{{ control.value | json }}</code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Component} from '@angular/core';
import {
AbstractControl,
FormControl,
FormGroup,
ValidationErrors,
ValidatorFn,
} from '@angular/forms';
Expand All @@ -22,10 +21,8 @@ const completeDateTimeValidator: ValidatorFn = (
changeDetection,
})
export class TuiInputDateTimeExample6 {
readonly testForm = new FormGroup({
testValue: new FormControl(
[new TuiDay(2017, 2, 15), null],
completeDateTimeValidator,
),
});
readonly control = new FormControl(
[new TuiDay(2017, 2, 15), null],
completeDateTimeValidator,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,8 @@ <h3>DI-tokens for input-configurations:</h3>
id="with-validator"
heading="With validator"
[content]="example6"
[description]="withValidatorDescription"
>
<tui-input-date-time-example-6></tui-input-date-time-example-6>

<ng-template #withValidatorDescription>
Create custom validator function to verify input value. Custom
<code>completeDateTimeValidator</code>
using to check if data is complete
</ng-template>
</tui-doc-example>
</ng-template>

Expand Down

0 comments on commit b23af89

Please sign in to comment.