mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-3427] fixed wrong validation for dropdown widget and date widget (#3745)
* [ADF-3427] fixed wrong validation for dropdown widget and date widget * [ADF-3427] fixed unit test
This commit is contained in:
parent
5b534c409f
commit
04799f0c95
@ -9,8 +9,9 @@
|
||||
[id]="column.id"
|
||||
[required]="column.required"
|
||||
[disabled]="!column.editable"
|
||||
(focusout)="onDateChanged($event.srcElement.value)">
|
||||
(focusout)="onDateChanged($event.srcElement.value)"
|
||||
(dateChange)="onDateChanged($event)">
|
||||
<mat-datepicker-toggle *ngIf="column.editable" matSuffix [for]="datePicker" class="adf-date-editor-button" ></mat-datepicker-toggle>
|
||||
</mat-form-field>
|
||||
<mat-datepicker #datePicker (dateChange)="onDateChanged($event)" [touchUi]="true"></mat-datepicker>
|
||||
<mat-datepicker #datePicker [touchUi]="true"></mat-datepicker>
|
||||
</div>
|
||||
|
@ -67,7 +67,7 @@ describe('DateEditorComponent', () => {
|
||||
});
|
||||
|
||||
it('should update row value upon user input', () => {
|
||||
const input = '14-03-2016';
|
||||
const input = {value: '14-03-2016' };
|
||||
|
||||
component.ngOnInit();
|
||||
component.onDateChanged(input);
|
||||
@ -78,7 +78,7 @@ describe('DateEditorComponent', () => {
|
||||
|
||||
it('should flush value on user input', () => {
|
||||
spyOn(table, 'flushValue').and.callThrough();
|
||||
const input = '14-03-2016';
|
||||
const input = {value: '14-03-2016' };
|
||||
|
||||
component.ngOnInit();
|
||||
component.onDateChanged(input);
|
||||
|
@ -65,12 +65,12 @@ export class DateEditorComponent implements OnInit {
|
||||
let momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
momentDateAdapter.overrideDisplyaFormat = this.DATE_FORMAT;
|
||||
|
||||
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_FORMAT);
|
||||
this.value = moment(this.table.getCellValue(this.row, this.column), 'YYYY-MM-DD');
|
||||
}
|
||||
|
||||
onDateChanged(newDateValue) {
|
||||
if (newDateValue) {
|
||||
let momentDate = moment(newDateValue, this.DATE_FORMAT, true);
|
||||
if (newDateValue && newDateValue.value) {
|
||||
let momentDate = moment(newDateValue.value, this.DATE_FORMAT, true);
|
||||
|
||||
if (!momentDate.isValid()) {
|
||||
this.row.value[this.column.id] = '';
|
||||
|
@ -8,7 +8,7 @@
|
||||
[(ngModel)]="value"
|
||||
[required]="column.required"
|
||||
[disabled]="!column.editable"
|
||||
(change)="onValueChanged(row, column, $event)">
|
||||
(selectionChange)="onValueChanged(row, column, $event)">
|
||||
<mat-option></mat-option>
|
||||
<mat-option *ngFor="let opt of options" [value]="opt.name" [id]="opt.id">{{opt.name}}</mat-option>
|
||||
</mat-select>
|
||||
|
Loading…
x
Reference in New Issue
Block a user