Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ All notable changes for each version of this project will be documented in this
### New Features
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- When triggering an export of the grid via the toolbar and the export takes more than 500 milliseconds, the export button becomes disabled and an indeterminate progress bar is shown at the bottom of the toolbar until the export is finished.
- ` IGX_INPUT_GROUP_TYPE` injection token
- Allows for setting an input group `type` on a global level, so all input-group instances, including components using such an instance as a template will have their input group type set to the one specified by the token. It can be overridden on a component level by explicitly setting a `type`.
- ` IgxExcelExporterService`
- Added `worksheetName` property to the `IgxExcelExporterOptions`, that allows setting the name of the worksheet.

Expand Down
54 changes: 36 additions & 18 deletions projects/igniteui-angular/src/lib/combo/combo.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ describe('igxCombo', () => {
mockSelection.get.and.returnValue(new Set([]));
const mockIconService = new IgxIconService(null, null);
it('should correctly implement interface methods - ControlValueAccessor ', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
expect(mockInjector.get).toHaveBeenCalledWith(NgControl, null);
Expand Down Expand Up @@ -133,7 +134,8 @@ describe('igxCombo', () => {
pending('Convert existing form test here');
});
it('should properly call dropdown methods on toggle', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['open', 'close', 'toggle']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand All @@ -156,7 +158,8 @@ describe('igxCombo', () => {
expect(combo.collapsed).toBe(false);
});
it(`should not focus search input when property autoFocusSearch=false`, () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
const dropdownContainer = { nativeElement: { focus: () => { } } };
combo['dropdownContainer'] = dropdownContainer;
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
Expand All @@ -175,7 +178,8 @@ describe('igxCombo', () => {
expect(combo.focusSearchInput).toHaveBeenCalledTimes(1);
});
it('should call dropdown toggle with correct overlaySettings', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['toggle']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand All @@ -193,7 +197,8 @@ describe('igxCombo', () => {
expect(combo.dropdown.toggle).toHaveBeenCalledWith(expectedSettings);
});
it('should properly get/set displayKey', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
combo.valueKey = 'field';
Expand All @@ -203,7 +208,8 @@ describe('igxCombo', () => {
expect(combo.displayKey === combo.valueKey).toBeFalsy();
});
it('should properly call "writeValue" method', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
combo.data = data;
Expand All @@ -221,7 +227,8 @@ describe('igxCombo', () => {
});
it('should select items through setSelctedItem method', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -256,7 +263,8 @@ describe('igxCombo', () => {
});
it('should set selectedItems correctly on selectItems method call', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand All @@ -281,7 +289,8 @@ describe('igxCombo', () => {
});
it('should fire onSelectionChange event on item selection', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -352,7 +361,8 @@ describe('igxCombo', () => {
});
it('should properly emit added and removed values in change event on single value selection', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -384,7 +394,8 @@ describe('igxCombo', () => {
});
it('should properly emit added and removed values in change event on multiple values selection', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -432,7 +443,8 @@ describe('igxCombo', () => {
});
it('should handle select/deselect ALL items', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand All @@ -452,7 +464,8 @@ describe('igxCombo', () => {
});
it('should emit onSelectonChange event on select/deselect ALL items method call', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -489,7 +502,8 @@ describe('igxCombo', () => {
});
it('should properly handle selection manipulation through onSelectionChange emit', () => {
const selectionService = new IgxSelectionAPIService();
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand All @@ -507,7 +521,8 @@ describe('igxCombo', () => {
expect(combo.selectedItems()).toEqual([]);
});
it('should not throw error when setting data to null', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
let errorMessage = '';
Expand All @@ -522,7 +537,8 @@ describe('igxCombo', () => {
expect(combo.data.length).toBe(0);
});
it('should not throw error when setting data to undefined', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
let errorMessage = '';
Expand All @@ -537,7 +553,8 @@ describe('igxCombo', () => {
expect(combo.data.length).toBe(0);
});
it('should properly handleInputChange', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
Expand Down Expand Up @@ -573,7 +590,8 @@ describe('igxCombo', () => {
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(2);
});
it('should be able to cancel onSearchInput', () => {
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService, mockIconService, null, mockInjector);
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
mockIconService, null, null, mockInjector);
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
combo.ngOnInit();
combo.data = data;
Expand Down
10 changes: 9 additions & 1 deletion projects/igniteui-angular/src/lib/combo/combo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { IgxComboAddItemComponent } from './combo-add-item.component';
import { IgxComboAPIService } from './combo.api';
import { EditorProvider } from '../core/edit-provider';
import { IgxInputState, IgxInputDirective } from '../directives/input/input.directive';
import { IgxInputGroupType, IGX_INPUT_GROUP_TYPE } from '../input-group/public_api';

/**
* @hidden
Expand Down Expand Up @@ -174,6 +175,7 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
protected _prevInputValue = '';
private _dataType = '';
private _searchValue = '';
private _type = null;
private ngControl: NgControl = null;
private destroy$ = new Subject<any>();
private _data = [];
Expand All @@ -199,6 +201,7 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
protected comboAPI: IgxComboAPIService,
private _iconService: IgxIconService,
@Optional() @Inject(DisplayDensityToken) protected _displayDensityOptions: IDisplayDensityOptions,
@Optional() @Inject(IGX_INPUT_GROUP_TYPE) private _inputGroupType: IgxInputGroupType,
@Optional() private _injector: Injector) {
super(_displayDensityOptions);
this.comboAPI.register(this);
Expand Down Expand Up @@ -859,8 +862,13 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
* ```
*/
@Input()
public type = 'box';
public get type(): IgxInputGroupType {
return this._type || this._inputGroupType || 'box';
}

public set type(val: IgxInputGroupType) {
this._type = val;
}
/**
* An @Input property that controls whether the combo's search box
* should be focused after the `onOpened` event is called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ describe('IgxDatePicker', () => {
};
moduleRef = {};
injector = { get: () => ngModel };
inputGroup = new IgxInputGroupComponent(null, null, document);
inputGroup = new IgxInputGroupComponent(null, null, null, document);
});

it('should initialize date picker with required correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Component, ViewChild, ElementRef } from '@angular/core';
import { Component, ViewChild, ElementRef, Inject } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { IgxInputGroupComponent, IgxInputGroupModule, IgxInputGroupType } from './input-group.component';
import { IgxInputGroupComponent, IgxInputGroupModule } from './input-group.component';
import { DisplayDensityToken, DisplayDensity } from '../core/displayDensity';
import { UIInteractions } from '../test-utils/ui-interactions.spec';
import { IgxIconModule } from '../icon/public_api';
import { IgxInputDirective } from '../directives/input/input.directive';
import { configureTestSuite } from '../test-utils/configure-suite';
import { IgxPrefixDirective, IgxSuffixDirective } from '../chips/public_api';
import { IGX_INPUT_GROUP_TYPE, IgxInputGroupType } from './inputGroupType';

const INPUT_GROUP_CSS_CLASS = 'igx-input-group';
const INPUT_GROUP_BOX_CSS_CLASS = 'igx-input-group--box';
Expand Down Expand Up @@ -40,7 +41,7 @@ describe('IgxInputGroup', () => {
}));

it('Initializes an input group.', () => {
const fixture = TestBed.createComponent(InputGroupComponent);
const fixture = TestBed.createComponent(InputGroupDisabledComponent);
fixture.detectChanges();

const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
Expand Down Expand Up @@ -86,28 +87,40 @@ describe('IgxInputGroup', () => {
testInputGroupType('search', igxInputGroup, inputGroupElement);
});

it('Should be able to change input group type programmatically.', () => {
it('Should respect type Token and be able to change input group type programmatically.', () => {
const fixture = TestBed.createComponent(InputGroupComponent);
fixture.detectChanges();

const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
const igxInputGroup = fixture.componentInstance.igxInputGroup;

igxInputGroup.type = 'box';
fixture.detectChanges();
// a Token is passed and can be obtained
expect(fixture.componentInstance.IGTOKEN).toBe('box');

// type set via Token is 'box'
testInputGroupType('box', igxInputGroup, inputGroupElement);

// user can override Token passing other igxInputGroup types
igxInputGroup.type = 'border';
fixture.detectChanges();
testInputGroupType('border', igxInputGroup, inputGroupElement);

igxInputGroup.type = 'box';
fixture.detectChanges();
testInputGroupType('box', igxInputGroup, inputGroupElement);

igxInputGroup.type = 'search';
fixture.detectChanges();
testInputGroupType('search', igxInputGroup, inputGroupElement);

igxInputGroup.type = 'line';
fixture.detectChanges();
testInputGroupType('line', igxInputGroup, inputGroupElement);

// Set type as null, so the Token type should be used again
igxInputGroup.type = null;
fixture.detectChanges();
testInputGroupType('box', igxInputGroup, inputGroupElement);
});

it('disabled input should properly detect changes.', () => {
Expand Down Expand Up @@ -250,14 +263,17 @@ describe('IgxInputGroup', () => {
<igx-prefix>PREFIX</igx-prefix>
<igx-suffix>SUFFIX</igx-suffix>
<input #igxInput igxInput />
</igx-input-group>`
</igx-input-group>`,
providers: [{ provide: IGX_INPUT_GROUP_TYPE, useValue: 'box'}]
})
class InputGroupComponent {
@ViewChild('igxInputGroup', { static: true }) public igxInputGroup: IgxInputGroupComponent;
@ViewChild('igxInput', { read: IgxInputDirective, static: true }) public igxInput: IgxInputDirective;
@ViewChild(IgxPrefixDirective, { read: ElementRef }) public prefix: ElementRef;
@ViewChild(IgxSuffixDirective, { read: ElementRef }) public suffix: ElementRef;
public suppressInputAutofocus = false;

constructor(@Inject(IGX_INPUT_GROUP_TYPE) public IGTOKEN: IgxInputGroupType) {}
}

@Component({
Expand Down
Loading