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

docs: Added disabled state in reactive forms #1203

Merged
merged 24 commits into from
Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bf68ea6
added disabled state for datetime
SaiShan Aug 30, 2019
14d4840
Added disabled state for date pciker
SaiShan Aug 30, 2019
424d61d
Added disabled state in input
SaiShan Aug 30, 2019
80b60e3
Added disabled state for multi input
SaiShan Aug 30, 2019
fec771f
Added disabled state for select
SaiShan Aug 30, 2019
1836359
refactor
SaiShan Aug 30, 2019
38ef427
Added disabled state for select native
SaiShan Aug 30, 2019
ca875e3
added disabled state for time picker
SaiShan Aug 30, 2019
71153c3
refactor combobox example
SaiShan Aug 30, 2019
5f358c3
#1179 improve combobox examples in Reactive Form
droshev Aug 31, 2019
733158e
#1179 improve date picker reactive form examples
droshev Aug 31, 2019
f34dfbf
1179 improve date time picker reactive form examples
droshev Aug 31, 2019
06246de
#1179 improve time reactive form examples
droshev Aug 31, 2019
802a45a
1179 improve the layout of the examples
droshev Aug 31, 2019
9cc24dd
#1179 improce toggle reactive form examples
droshev Aug 31, 2019
f3b946c
#1179 update the calendar reactive form examples
droshev Aug 31, 2019
f13a7fc
#1179 update timepicker reactive form examples
droshev Aug 31, 2019
51dcd40
#1179 improve radio button reactive form examples
droshev Aug 31, 2019
5dedf7a
#1179 update textarea reactive form examples
droshev Aug 31, 2019
84714c7
#1179 improve select reactive form examples
droshev Aug 31, 2019
2a686f7
update select native reactive form examples
droshev Aug 31, 2019
825685d
#1179 improve multi input reactive form examples
droshev Sep 1, 2019
2c06b28
#1179 update input reactive form examples
droshev Sep 1, 2019
d1698fb
#1179 improve input group reactive form examples
droshev Sep 1, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,9 @@ <h2>Internationalization</h2>
<code-example [exampleFiles]="calendari18n"></code-example>

<separator></separator>
<h2>Single Mode Calendar in Form</h2>
<h2>Calendar in Reactive Form</h2>
<description>The Calendar component may also be used within Angular Reactive Forms.</description>
<component-example [name]="'ex6'">
<fd-calendar-form-single-example></fd-calendar-form-single-example>
<fd-calendar-form-example></fd-calendar-form-example>
</component-example>
<code-example [exampleFiles]="calendarSingleFormSource"></code-example>

<separator></separator>
<h2>Range Mode Calendar in Form</h2>
<description>The Calendar component may also be used within Angular Reactive Forms.</description>
<component-example [name]="'ex7'">
<fd-calendar-form-range-example></fd-calendar-form-range-example>
</component-example>
<code-example [exampleFiles]="calendarRangeFormSource"></code-example>
<code-example [exampleFiles]="calendarFormSource"></code-example>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as calendarRangeSrc from '!raw-loader!./examples/calendar-range-example
import * as calendarSingleSrc from '!raw-loader!./examples/calendar-single-example.component.ts';
import * as calendarMondayStartSrc from '!raw-loader!./examples/calendar-monday-start-example.component.ts';
import * as calendarIntlSrc from '!raw-loader!./examples/calendar-i18n-example.component.ts';
import * as calendarSingleFormSource from '!raw-loader!./examples/calendar-form-single-example.component.ts';
import * as calendarRangeFormSource from '!raw-loader!./examples/calendar-form-range-example.component.ts';
import * as calendarFormSourceT from '!raw-loader!./examples/calendar-form-examples.component.ts';
import * as calendarFormSourceH from '!raw-loader!./examples/calendar-form-examples.component.html';
import * as calendarProgrammaticallySource from '!raw-loader!./examples/calendar-programmatically-change-example.component.ts';
import { ExampleFile } from '../../core-helpers/code-example/example-file';

Expand Down Expand Up @@ -89,15 +89,15 @@ myDisableFunction = function(d: FdDate): boolean {
code: calendarIntlSrc
}];

calendarSingleFormSource: ExampleFile[] = [{
language: 'typescript',
code: calendarSingleFormSource
}];

calendarRangeFormSource: ExampleFile[] = [{
language: 'typescript',
code: calendarRangeFormSource
}];
calendarFormSource: ExampleFile[] = [
{
language: 'typescript',
code: calendarFormSourceT
}, {
language: 'html',
code: calendarFormSourceH
}
];

calendarProgrammaticallySource: ExampleFile[] = [{
language: 'typescript',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<form [formGroup]="customForm" class="flex-form">
<div fd-form-item>
<fd-calendar
[calType]="'single'"
formControlName="date"
[startingDayOfWeek]="1">
</fd-calendar>
Touched: {{customForm.controls.date.touched}}<br/>
Dirty: {{customForm.controls.date.dirty}}<br/>
Valid: {{customForm.controls.date.valid}}<br/>
Selected Date: {{ customForm.controls.date.value.toDateString() ? customForm.controls.date.value.toDateString() : 'null' }} <br />
<button fd-button (click)="setInvalid()">Set Invalid Single Date</button>
</div>
<div fd-form-item>
<fd-calendar
[calType]="'range'"
formControlName="dateRange"
[startingDayOfWeek]="1">
</fd-calendar>
Touched: {{customForm.controls.dateRange.touched}}<br/>
Dirty: {{customForm.controls.dateRange.dirty}}<br/>
Selected Start Date: {{ customForm.controls.dateRange.value.start ? customForm.controls.dateRange.value.start.toDateString() : 'null' }} <br/>
Selected End Date: {{ customForm.controls.dateRange.value.end ? customForm.controls.dateRange.value.end.toDateString() : 'null' }} <br/>
Valid: {{ customForm.controls.dateRange.valid }} <br/>
<button fd-button (click)="setInvalidRange()">Set Invalid Range Date</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component } from '@angular/core';
import { FdDate } from '../../../../../../library/src/lib/calendar/models/fd-date';
import { FormControl, FormGroup } from '@angular/forms';

@Component({
selector: 'fd-calendar-form-example',
templateUrl: 'calendar-form-examples.component.html',
styles: [`
button {
margin-top: 1rem;
}

.flex-form{
display:flex;
justify-content:space-between;
}
`]
})
export class CalendarFormExamplesComponent {
customForm = new FormGroup({
date: new FormControl(FdDate.getToday()),
dateRange: new FormControl({
value: {
start: new FdDate(2019, 10, 11),
end: new FdDate(2019, 10, 19)
}, disabled: false
})
});

setInvalid() {
this.customForm.controls['date'].setValue(new FdDate(null, null, null));
}

setInvalidRange() {
this.customForm.controls['dateRange'].setValue(new FdDate(null, null, null));
}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ <h2>Custom Item Template</h2>
<code-example [exampleFiles]="comboboxTemplateExample"></code-example>

<separator></separator>
<h2>Disabled Combobox In A Reactive Form</h2>
<h2>Combobox In A Reactive Form</h2>
<description>
This example shows how to put <code>combobox</code> in a Reactive Form and sets it state to <code>disabled</code>
This examples shows how to put <code>combobox</code> in a Reactive Form. Also how to sets it's state to <code>disabled</code>
</description>
<component-example [name]="'ex7'">
<fd-combobox-disabled-example></fd-combobox-disabled-example>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
<form [formGroup]="customForm">
<div fd-form-set>
<div fd-form-set class="flex-form">
<div fd-form-item>
<label fd-form-label for="form-combo-1">Selected Value:</label>
<label fd-form-label for="form-combo-1">Select Fruit:</label>
<fd-combobox
formControlName="comboControl"
[dropdownValues]="dropdownValues"
fd-form-control
id="form-control-1"></fd-combobox>
id="form-combo-1"></fd-combobox>
Disabled: {{ customForm.controls.comboControl.disabled }}<br/>
Selected Value: {{ customForm.controls.comboControl.value }}
</div>
<div fd-form-item>
<label fd-form-label for="form-combo-2">Select Fruit:</label>
<fd-combobox
formControlName="disabledComboControl"
fd-form-control
id="form-combo-2"></fd-combobox>
Disabled: {{ customForm.controls.disabledComboControl.disabled }}<br/>
Selected Value: {{ customForm.controls.disabledComboControl.value }}
</div>
</div>
</form>

Disabled: {{ customForm.controls.comboControl.disabled }}

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import { FormGroup, FormControl, Validators } from '@angular/forms';

@Component({
selector: 'fd-combobox-disabled-example',
styles: [`
.flex-form{
display:flex;
justify-content: space-between
}
`],
templateUrl: './combobox-disabled-example.component.html'
})
export class ComboboxDisabledExampleComponent {

dropdownValues = [
'Apple',
'Pineapple',
'Banana',
'Kiwi',
'Strawberry'
];

customForm = new FormGroup({
comboControl: new FormControl({ value: 'Nancy', disabled: true }, Validators.required)
comboControl: new FormControl('Banana', Validators.required),
disabledComboControl: new FormControl({ value: 'Kiwi', disabled: true }, Validators.required)
});

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ <h2>Null Validity</h2>
<code-example [exampleFiles]="datePickerAllowNull"></code-example>

<separator></separator>
<h2>Date Picker in Form</h2>
<h2>Date Picker in Reactive Form</h2>
<description>The date-picker component may also be used within Angular Reactive Forms.</description>
<component-example [name]="'ex6'">
<fd-date-picker-form-example></fd-date-picker-form-example>
</component-example>
<code-example [exampleFiles]="datePickerForm"></code-example>

<separator></separator>
<h2>Date Picker in Form with a Range of Dates</h2>
<h2>Date Picker in Reactive Form with a Range of Dates</h2>
<component-example [name]="'ex7'">
<fd-date-picker-form-range-example></fd-date-picker-form-range-example>
</component-example>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@ import { FdDate } from '../../../../../../library/src/lib/calendar/models/fd-dat

@Component({
selector: 'fd-date-picker-form-example',
styles: [`
.flex-form{
display:flex;
justify-content: space-between;
}
`],
template: `
<form [formGroup]="customForm">
<fd-date-picker formControlName="date"></fd-date-picker>
<form [formGroup]="customForm" class="flex-form">
<div>
<fd-date-picker formControlName="date"></fd-date-picker><br/>
Touched: {{customForm.controls.date.touched}}<br/>
Dirty: {{customForm.controls.date.dirty}}<br/>
Valid: {{customForm.controls.date.valid}}<br/>
Selected Date: {{ customForm.controls.date.value ? customForm.controls.date.value.toDateString() : 'null' }}
</div>
<div>
<fd-date-picker formControlName="disabledDate"></fd-date-picker><br/>
Touched: {{customForm.controls.disabledDate.touched}}<br/>
Dirty: {{customForm.controls.disabledDate.dirty}}<br/>
Valid: {{customForm.controls.disabledDate.valid}}<br/>
Disabled: {{customForm.controls.disabledDate.disabled}} <br/>
Selected Date: {{ customForm.controls.disabledDate.value ? customForm.controls.date.value.toDateString() : 'null' }}
</div>
</form>

Touched: {{customForm.controls.date.touched}}<br/>
Dirty: {{customForm.controls.date.dirty}}<br/>
Valid: {{customForm.controls.date.valid}}<br/>

Selected Date: {{ customForm.controls.date.value ? customForm.controls.date.value.toDateString() : 'null' }}
`
})
export class DatePickerFormExampleComponent {
customForm = new FormGroup({
date: new FormControl(FdDate.getToday())
date: new FormControl(FdDate.getToday()),
disabledDate: new FormControl({ value: FdDate.getToday(), disabled: true })
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ <h2>Disabled State</h2>

<separator></separator>

<h2>Use in a Form</h2>
<h2>Date Time Picker in Reactive Form</h2>
<description>The date-time-picker component may also be used within Angular Reactive Forms.</description>
<component-example [name]="'ex5'">
<fd-datetime-form-example></fd-datetime-form-example>
</component-example>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<form [formGroup]="customForm">
<fd-datetime-picker formControlName="date"></fd-datetime-picker>
</form>
<br/>
Touched: {{customForm.controls.date.touched}}<br/>
Dirty: {{customForm.controls.date.dirty}}<br/>
Valid: {{customForm.controls.date.valid}}<br/>

Selected Date: {{ customForm.controls.date.value ? customForm.controls.date.value.toLocaleDateString() : 'null' }}
<form [formGroup]="customForm" class="flex-form">
<div>
<fd-datetime-picker formControlName="date"></fd-datetime-picker><br/>
Touched: {{customForm.controls.date.touched}}<br/>
Dirty: {{customForm.controls.date.dirty}}<br/>
Valid: {{customForm.controls.date.valid}}<br/>
Selected Date: {{ customForm.controls.date.value ? customForm.controls.date.value.toLocaleDateString() : 'null' }}
</div>
<div>
<fd-datetime-picker formControlName="disabledDate"></fd-datetime-picker><br/>
Touched: {{customForm.controls.disabledDate.touched}}<br/>
Dirty: {{customForm.controls.disabledDate.dirty}}<br/>
Valid: {{customForm.controls.disabledDate.valid}}<br/>
Disabled: {{customForm.controls.disabledDate.disabled}}<br/>
Selected Date: {{ customForm.controls.disabledDate.value ? customForm.controls.disabledDate.value.toLocaleDateString() : 'null' }}
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import { FdDatetime } from '../../../../../../../library/src/lib/datetime-picker

@Component({
selector: 'fd-datetime-form-example',
styles: [`
.flex-form{
display:flex;
justify-content: space-between;
}
`],
templateUrl: './datetime-form-example.component.html'
})
export class DatetimeFormExampleComponent {
customForm = new FormGroup({
date: new FormControl(FdDatetime.getToday())
date: new FormControl(FdDatetime.getToday()),
disabledDate: new FormControl({ value: FdDatetime.getToday(), disabled: true })
});
}