Skip to content

Commit 596ff79

Browse files
authored
Merge branch '9.1.x' into nalipiev/mask-placeholder
2 parents 38890aa + dbfc657 commit 596ff79

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

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/services/transaction/igx-hierarchical-transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction
5555
* Applies all transactions over the provided data
5656
* @param data Data source to update
5757
* @param primaryKey Primary key of the hierarchical data
58-
* @param childDataKey Kye of child data collection
58+
* @param childDataKey Key of child data collection
5959
* @param id Optional record id to commit transactions for
6060
*/
6161
public commit(data: any[], primaryKey?: any, childDataKey?: any, id?: any): void {
@@ -65,10 +65,10 @@ export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction
6565
transactions = transactions.filter(t => t.id === id);
6666
}
6767
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKey, true);
68+
this.clear(id);
6869
} else {
6970
super.commit(data, id);
7071
}
71-
this.clear(id);
7272
}
7373

7474
// TODO: remove this method. Force cloning to strip child arrays when needed instead

projects/igniteui-angular/src/lib/services/transaction/igx-transaction.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,5 +945,26 @@ describe('IgxTransaction', () => {
945945
expect(transaction.canUndo).toBeFalsy();
946946
expect(transaction.getAggregatedChanges(false).length).toBe(0);
947947
});
948+
949+
it('Should emit onStateUpdate once when commiting a hierarchical transaction', () => {
950+
const data = SampleTestData.employeeTreeData();
951+
const transaction = new IgxHierarchicalTransactionService();
952+
spyOn(transaction.onStateUpdate, 'emit').and.callThrough();
953+
expect(transaction).toBeDefined();
954+
955+
const updateTransaction: HierarchicalTransaction = {
956+
id: 475,
957+
type: TransactionType.UPDATE,
958+
newValue: {
959+
Age: 60
960+
},
961+
path: [data[0].ID]
962+
};
963+
transaction.add(updateTransaction, data[0].Employees[0]);
964+
expect(transaction.onStateUpdate.emit).toHaveBeenCalledTimes(1);
965+
966+
transaction.commit(data, 'ID');
967+
expect(transaction.onStateUpdate.emit).toHaveBeenCalledTimes(2);
968+
});
948969
});
949970
});

0 commit comments

Comments
 (0)