mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4436] - added option for select item to display None (#7113)
* [ACA-4436] - added option for select item to display None * [ACA-4436] - added unit test and fixed wrong default behaviour * [ACA-4436] - fixed property check * [ACA-4436] - fixed unit test * [ACA-4436] - fixed unit test
This commit is contained in:
@@ -40,7 +40,22 @@ describe('CardViewSelectItemModel', () => {
|
||||
|
||||
itemModel.displayValue.subscribe((value) => {
|
||||
expect(value).toBe(mockData[1].label);
|
||||
expect(itemModel.displayNoneOption).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should set true for none option when passed through the properties', fakeAsync(() => {
|
||||
properties.displayNoneOption = true;
|
||||
const itemModel = new CardViewSelectItemModel(properties);
|
||||
|
||||
expect(itemModel.displayNoneOption).toBe(true);
|
||||
}));
|
||||
|
||||
it('should set false for none option when passed through the properties', fakeAsync(() => {
|
||||
properties.displayNoneOption = false;
|
||||
const itemModel = new CardViewSelectItemModel(properties);
|
||||
|
||||
expect(itemModel.displayNoneOption).toBe(false);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -25,12 +25,15 @@ import { switchMap } from 'rxjs/operators';
|
||||
export class CardViewSelectItemModel<T> extends CardViewBaseItemModel implements CardViewItem, DynamicComponentModel {
|
||||
type: string = 'select';
|
||||
options$: Observable<CardViewSelectItemOption<T>[]>;
|
||||
displayNoneOption: boolean;
|
||||
|
||||
valueFetch$: Observable<string> = null;
|
||||
|
||||
constructor(cardViewSelectItemProperties: CardViewSelectItemProperties<T>) {
|
||||
super(cardViewSelectItemProperties);
|
||||
|
||||
this.displayNoneOption = cardViewSelectItemProperties.displayNoneOption !== undefined ? cardViewSelectItemProperties.displayNoneOption : true;
|
||||
|
||||
this.options$ = cardViewSelectItemProperties.options$;
|
||||
|
||||
this.valueFetch$ = this.options$.pipe(
|
||||
|
Reference in New Issue
Block a user