Skip to content

Commit 454aba7

Browse files
authored
Merge branch 'master' into iganchev/add-hammerjs-to-test
2 parents f1ddfa2 + 5e91c8e commit 454aba7

20 files changed

+512
-152
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ All notable changes for each version of this project will be documented in this
1717
### New Features
1818
- `IgxGrid`
1919
- `showGroupArea` input is added, which can be used to enable/disable the group area row.
20+
- The event arguments of `onCellEdit`, `onCellEditEnter` and `onCellEditCancel` events will contain a reference to the row data, as well as a reference to the column.
21+
- The event arguments of `onRowEdit`, `onRowEditEnter` and `onRowEditCancel` events will contain a reference to the row data.
2022

2123
- `IgxSelect` support for `igxHint` directive added.
2224
- Allows the user to add `igxHint` to be displayed bellow the input element.

projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ describe('IgxDatePicker', () => {
132132
expect(inputGroup.nativeElement.classList.contains('igx-input-group--disabled')).toBeTruthy();
133133
});
134134

135+
it('should not be able to toggle & clear when disabled', () => {
136+
const date = new Date();
137+
datePicker.value = date;
138+
datePicker.disabled = true;
139+
fixture.detectChanges();
140+
expect(datePicker.collapsed).toBeTruthy();
141+
142+
datePicker.openDialog();
143+
fixture.detectChanges();
144+
expect(datePicker.collapsed).toBeTruthy();
145+
146+
datePicker.clear();
147+
fixture.detectChanges();
148+
expect(datePicker.value).toEqual(date);
149+
});
150+
135151
it('When labelVisability is set to false the label should not be visible', () => {
136152
let label = fixture.debugElement.query(By.directive(IgxLabelDirective));
137153

projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { IgxInputGroupModule, IgxInputDirective, IgxInputGroupComponent, IgxInpu
3434
import { Subject, fromEvent, animationFrameScheduler, interval, Subscription } from 'rxjs';
3535
import { filter, takeUntil, throttle } from 'rxjs/operators';
3636
import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive';
37-
import { IgxTextSelectionModule} from '../directives/text-selection/text-selection.directive';
37+
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
3838
import {
3939
OverlaySettings,
4040
IgxOverlayService,
@@ -144,7 +144,7 @@ const noop = () => { };
144144
`]
145145
})
146146
export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor,
147-
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
147+
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
148148
/**
149149
* Gets/Sets the `IgxDatePickerComponent` label.
150150
* @remarks
@@ -914,10 +914,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
914914
* @param date passed date that has to be set to the calendar.
915915
*/
916916
public selectDate(date: Date): void {
917-
const oldValue = this.value;
917+
const oldValue = this.value;
918918
this.value = date;
919919

920-
this.emitValueChangeEvent(oldValue, this.value );
920+
this.emitValueChangeEvent(oldValue, this.value);
921921
this.onSelection.emit(date);
922922
}
923923

@@ -929,9 +929,9 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
929929
* ```
930930
*/
931931
public deselectDate(): void {
932-
const oldValue = this.value;
932+
const oldValue = this.value;
933933
this.value = null;
934-
this.emitValueChangeEvent(oldValue, this.value );
934+
this.emitValueChangeEvent(oldValue, this.value);
935935
if (this.calendar) {
936936
this.calendar.deselectDate();
937937
}
@@ -946,7 +946,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
946946
* ```
947947
*/
948948
public openDialog(): void {
949-
if (!this.collapsed) {
949+
if (!this.collapsed || this.disabled) {
950950
return;
951951
}
952952

@@ -987,10 +987,12 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
987987
* @hidden @internal
988988
*/
989989
public clear(): void {
990-
this.isEmpty = true;
991-
this.invalidDate = '';
992-
this.deselectDate();
993-
this._setCursorPosition(0);
990+
if (!this.disabled) {
991+
this.isEmpty = true;
992+
this.invalidDate = '';
993+
this.deselectDate();
994+
this._setCursorPosition(0);
995+
}
994996
}
995997

996998
/**
@@ -1008,10 +1010,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10081010
date.setSeconds(this.value.getSeconds());
10091011
date.setMilliseconds(this.value.getMilliseconds());
10101012
}
1011-
const oldValue = this.value;
1013+
const oldValue = this.value;
10121014
this.value = date;
10131015

1014-
this.emitValueChangeEvent(oldValue, this.value );
1016+
this.emitValueChangeEvent(oldValue, this.value);
10151017
this.calendar.viewDate = date;
10161018
this.closeCalendar();
10171019
this.onSelection.emit(date);
@@ -1141,11 +1143,11 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
11411143

11421144
if (this.disabledDates === null
11431145
|| (this.disabledDates !== null && !isDateInRanges(newValue, this.disabledDates))) {
1144-
const oldValue = this.value;
1145-
this.value = newValue;
1146+
const oldValue = this.value;
1147+
this.value = newValue;
11461148

1147-
this.emitValueChangeEvent(oldValue, this.value );
1148-
this.invalidDate = '';
1149+
this.emitValueChangeEvent(oldValue, this.value);
1150+
this.invalidDate = '';
11491151
} else {
11501152
const args: IDatePickerDisabledDateEventArgs = {
11511153
datePicker: this,

projects/igniteui-angular/src/lib/directives/mask/mask.directive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
153153

154154
/** @hidden */
155155
public ngOnInit(): void {
156-
this.renderer.setAttribute(this.nativeElement, 'placeholder',
157-
this.placeholder ? this.placeholder : this.maskOptions.format);
156+
if (!this.nativeElement.placeholder) {
157+
this.renderer.setAttribute(this.nativeElement, 'placeholder', this.maskOptions.format);
158+
}
158159
}
159160

160161
/**

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
144144

145145
const args = cell.createEditEventArgs();
146146

147+
// TODO: emit onCellEdit after value is updated - issue #7304
147148
this.grid.onCellEdit.emit(args);
148149
if (args.cancel) {
149150
return args;
@@ -231,6 +232,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
231232
return args;
232233
}
233234

235+
// TODO: emit onRowEdit after value is updated - issue #7304
234236
grid.onRowEdit.emit(args);
235237

236238
if (args.cancel) {

projects/igniteui-angular/src/lib/grids/columns/column-group.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,14 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
323323
* @memberof IgxColumnGroupComponent
324324
*/
325325
get width() {
326-
let isChildrenWidthInPercent = false, width;
326+
let width;
327327
width = `${this.children.reduce((acc, val) => {
328328
if (val.hidden) {
329329
return acc;
330330
}
331-
if (typeof val.width === 'string' && val.width.indexOf('%') !== -1) {
332-
isChildrenWidthInPercent = true;
333-
return acc + parseInt(val.width, 10);
334-
}
335331
return acc + parseInt(val.calcWidth, 10);
336332
}, 0)}`;
337-
return isChildrenWidthInPercent ? width + '%' : width + 'px';
333+
return width + 'px';
338334
}
339335

340336
set width(val) { }

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ export class IgxColumnComponent implements AfterContentInit {
17621762
* @hidden
17631763
*/
17641764
public getCalcWidth(): any {
1765-
if (this._calcWidth !== null && !isNaN(this.calcPixelWidth)) {
1765+
if (this._calcWidth && !isNaN(this.calcPixelWidth)) {
17661766
return this._calcWidth;
17671767
}
17681768
this.cacheCalcWidth();
@@ -1863,7 +1863,7 @@ export class IgxColumnComponent implements AfterContentInit {
18631863
const colWidth = this.width;
18641864
const isPercentageWidth = colWidth && typeof colWidth === 'string' && colWidth.indexOf('%') !== -1;
18651865
if (isPercentageWidth) {
1866-
this._calcWidth = parseInt(colWidth, 10) / 100 * (grid.calcWidth - grid.featureColumnsWidth());
1866+
this._calcWidth = parseInt(colWidth, 10) / 100 * grid.calcWidth;
18671867
} else if (!colWidth) {
18681868
// no width
18691869
this._calcWidth = this.defaultWidth || grid.getPossibleColumnWidth();

projects/igniteui-angular/src/lib/grids/common/events.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IgxGridCellComponent } from '../cell.component';
77
import { IgxColumnComponent } from '../columns/column.component';
88
import { IgxGridBaseDirective } from '../grid-base.directive';
99
import { IgxRowDirective } from '../row.directive';
10+
import { ColumnType } from './column.interface';
1011
export { GridSelectionRange } from '../selection/selection.service';
1112

1213
export interface IGridClipboardEvent {
@@ -26,9 +27,12 @@ export interface IGridEditEventArgs extends CancelableEventArgs, IBaseEventArgs
2627
columnID: any,
2728
rowIndex: number
2829
};
30+
rowData: any;
2931
oldValue: any;
3032
newValue?: any;
3133
event?: Event;
34+
column?: ColumnType;
35+
owner?: IgxGridBaseDirective & GridType;
3236
}
3337

3438
export interface IPinColumnEventArgs extends IBaseEventArgs {

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,15 +3552,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
35523552
if (this.hasColumnLayouts) {
35533553
return '';
35543554
}
3555-
const colWidth = column.width;
3555+
const colWidth = parseInt(column.calcWidth, 10);
35563556
const minWidth = this.defaultHeaderGroupMinWidth;
3557-
const isPercentageWidth = colWidth && typeof colWidth === 'string' && colWidth.indexOf('%') !== -1;
35583557

3559-
if (!isPercentageWidth && parseInt(colWidth, 10) < minWidth) {
3558+
if (colWidth < minWidth) {
35603559
return minWidth + 'px';
35613560
}
3562-
3563-
return colWidth;
3561+
return colWidth + 'px';
35643562
}
35653563

35663564
/**
@@ -4036,7 +4034,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
40364034
rowIndex: index
40374035
};
40384036

4039-
const cell = new IgxCell(id, index, col, rowData[col.field], rowData[col.field], rowData);
4037+
const cell = new IgxCell(id, index, col, rowData[col.field], rowData[col.field], rowData, this);
40404038
const args = this.gridAPI.update_cell(cell, value);
40414039

40424040
if (this.crudService.cell && this.crudService.sameCell(cell)) {
@@ -4071,7 +4069,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
40714069
if (editableCell && editableCell.id.rowID === rowSelector) {
40724070
this.gridAPI.escape_editMode();
40734071
}
4074-
const row = new IgxRow(rowSelector, -1, this.gridAPI.getRowData(rowSelector));
4072+
const row = new IgxRow(rowSelector, -1, this.gridAPI.getRowData(rowSelector), this);
40754073
this.gridAPI.update_row(row, value);
40764074

40774075
// TODO: fix for #5934 and probably break for #5763

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export class IgxGridNavigationService {
172172

173173
focusTbody(event) {
174174
const gridRows = this.grid.verticalScrollContainer.totalItemCount ?? this.grid.dataView.length;
175+
if (gridRows < 1) { this.activeNode = null; return; }
175176
if (!this.activeNode || this.activeNode.row < 0 || this.activeNode.row > gridRows - 1) {
176177
this.activeNode = { row: 0, column: 0 };
177178
this.grid.navigateTo(0, 0, (obj) => {
@@ -182,7 +183,8 @@ export class IgxGridNavigationService {
182183
}
183184

184185
focusFirstCell(header = true) {
185-
if (this.activeNode && (this.activeNode.row === -1 || this.activeNode.row === this.grid.dataView.length)) { return; }
186+
if (this.grid.dataView.length && this.activeNode &&
187+
(this.activeNode.row === -1 || this.activeNode.row === this.grid.dataView.length)) { return; }
186188
this.activeNode = { row: header ? -1 : this.grid.dataView.length, column: 0,
187189
level: this.grid.hasColumnLayouts ? 1 : 0, mchCache: { level: 0, visibleIndex: 0} };
188190
this.performHorizontalScrollToCell(0);

0 commit comments

Comments
 (0)