Fix dropdown should show the value in readonly mode (#2380)

This commit is contained in:
Maurizio Vitale 2017-09-27 14:06:49 +01:00 committed by Eugenio Romano
parent 092528db4f
commit e1573ddbde
2 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,7 @@
<md-option *ngFor="let opt of field.options"
[value]="getOptionValue(opt, field.value)"
[id]="opt.id">{{opt.name}}</md-option>
<md-option id="readonlyOption" *ngIf="field.readOnly" [value]="field.value">{{field.value}}</md-option>
</md-select>
<error-widget [error]="field.validationSummary" ></error-widget>
<error-widget class="adf-dropdown-required-message" *ngIf="isInvalidFieldRequired()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>

View File

@ -288,6 +288,26 @@ describe('DropdownWidgetComponent', () => {
expect(dropDownElement.getAttribute('aria-disabled')).toBe('true');
});
}));
it('should show the option value when the field is readonly', () => {
widget.field = new FormFieldModel(new FormModel({processDefinitionId: 'fake-process-id'}), {
id: 'dropdown-id',
name: 'date-name',
type: 'dropdown',
value: 'FakeValue',
readOnly: true
});
const trigger = fixture.debugElement.query(By.css('.mat-select-trigger')).nativeElement;
trigger.click();
fixture.detectChanges();
fixture.whenStable()
.then(() => {
fixture.detectChanges();
expect(element.querySelector('#dropdown-id')).not.toBeNull();
const option = fixture.debugElement.query(By.css('.mat-option')).nativeElement;
expect(option.innerText).toEqual('FakeValue');
});
});
});
});
});