Skip to content

Commit 507bc1c

Browse files
Merge branch 'bpenkov/date-time-editor' of https://github.com/IgniteUI/igniteui-angular into bpenkov/date-time-editor
2 parents 90b6836 + bee8a48 commit 507bc1c

35 files changed

+1681
-789
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ All notable changes for each version of this project will be documented in this
1414
### New Features
1515

1616
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
17+
- Added ability to pin rows to top or bottom depending on the new `pinning` input.
18+
And new API methods `pinRow` and `unpinRow`.
19+
```html
20+
<igx-grid [data]="data" [pinning]="pinningConfiguration"></igx-grid>
21+
```
22+
```typescript
23+
public pinningConfiguration: IPinningConfig = { rows: RowPinningPosition.Bottom };
24+
```
25+
```typescript
26+
this.grid.pinRow(rowID);
27+
```
1728
- Added support for pinning columns on the right. Change the position of pinning using the new `pinning` input.
1829
```html
1930
<igx-grid [data]="data" [pinning]="pinningConfiguration"></igx-grid>

projects/igniteui-angular/src/lib/core/styles/components/navbar/_navbar-theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,6 @@
155155

156156
%igx-navbar-title {
157157
@include igx-type-style($type-scale, $title);
158+
margin-bottom: 0;
158159
}
159160
}

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.common.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ export interface IgxDateTimeEditorEventArgs {
33
newValue: Date | string;
44
}
55

6+
/**
7+
* An @Enum that allows you to specify a particular date, time or AmPm part.
8+
*/
69
export enum DatePart {
710
Date = 'date',
811
Month = 'month',

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts

+120-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ import {
1212
} from '../../date-picker/date-picker.utils';
1313
import { IgxDateTimeEditorEventArgs, DatePartInfo, DatePart } from './date-time-editor.common';
1414

15+
/**
16+
* Date Time Editor provides a functionality to input, edit and format date and time.
17+
*
18+
* @igxModule IgxDateTimeEditorModule
19+
*
20+
* @igxParent IgxInputGroup
21+
*
22+
* @igxTheme igx-input-theme
23+
*
24+
* @igxKeywords date, time, editor
25+
*
26+
* @igxGroup Scheduling
27+
*
28+
* @remarks
29+
*
30+
* The Ignite UI Date Time Editor Directive makes it easy for developers to manipulate date/time user input.
31+
* It requires input in a specified or default input format which is visible in the input element as a placeholder.
32+
* It allows to input only date(ex: 'dd/MM/yyyy'), only time(ex:'HH:mm tt') or both at once, if needed.
33+
* Supports display format that may differ from the input format.
34+
* Provides methods to increment and decrement any specific/targeted `DatePart`.
35+
*
36+
* @example
37+
* ```html
38+
* <igx-input-group>
39+
* <input type="text" igxInput [igxDateTimeEditor]="'dd/MM/yyyy'" [displayFormat]="'shortDate'" [(ngModel)]="date"/>
40+
* </igx-input-group>
41+
* ```
42+
*/
1543
@Directive({
1644
selector: '[igxDateTimeEditor]',
1745
exportAs: 'igxDateTimeEditor',
@@ -20,25 +48,65 @@ import { IgxDateTimeEditorEventArgs, DatePartInfo, DatePart } from './date-time-
2048
]
2149
})
2250
export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnInit, ControlValueAccessor {
51+
/**
52+
* An @Input property that allows you to set the locale settings used in `displayFormat`.
53+
* @example
54+
*```html
55+
* <input igxDateTimeEditor [locale]="'en'">
56+
*```
57+
*/
2358
@Input()
2459
public locale = 'en';
2560

61+
/**
62+
* An @Input property that allows you to set the minimum possible value the editor will allow.
63+
* @example
64+
*```html
65+
* <input igxDateTimeEditor [minValue]="minDate">
66+
*```
67+
*/
2668
@Input()
2769
public minValue: string | Date;
2870

71+
/**
72+
* An @Input property that allows you to set the maximum possible value the editor will allow.
73+
* @example
74+
*```html
75+
* <input igxDateTimeEditor [maxValue]="maxDate">
76+
*```
77+
*/
2978
@Input()
3079
public maxValue: string | Date;
3180

81+
/**
82+
* An @Input property that allows you to specify if the currently spun date segment should loop over.
83+
* @example
84+
*```html
85+
* <input igxDateTimeEditor [isSpinLoop]="false">
86+
*```
87+
*/
3288
@Input()
3389
public isSpinLoop = true;
3490

91+
/**
92+
* An @Input property that allows you to set both pre-defined format options such as `shortDate` and `longDate`,
93+
* as well as constructed format string using characters supported by `DatePipe`, e.g. `EE/MM/yyyy`.
94+
* @example
95+
*```html
96+
* <input igxDateTimeEditor [displayFormat]="'shortDate'">
97+
*```
98+
*/
3599
@Input()
36100
public displayFormat: string;
37101

38-
public get inputFormat(): string {
39-
return this._format;
40-
}
41-
102+
/**
103+
* An @Input property that allows you to get/set the expected user input format(and placeholder).
104+
* for the editor.
105+
* @example
106+
*```html
107+
* <input [igxDateTimeEditor]="'dd/MM/yyyy'">
108+
*```
109+
*/
42110
@Input(`igxDateTimeEditor`)
43111
public set inputFormat(value: string) {
44112
if (value) {
@@ -48,19 +116,44 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
48116
this.mask = value.indexOf('tt') !== -1 ? mask.substring(0, mask.length - 2) + 'LL' : mask;
49117
}
50118

51-
public get value() {
52-
return this._value;
119+
public get inputFormat(): string {
120+
return this._format;
53121
}
54122

123+
/**
124+
* An @Input property that gets/sets the component date value.
125+
* @example
126+
* ```html
127+
* <input igxDateTimeEditor [value]="date">
128+
* ```
129+
*/
55130
@Input()
56131
public set value(value: Date) {
57132
this._value = value;
58133
this.updateMask();
59134
}
60135

136+
public get value() {
137+
return this._value;
138+
}
139+
140+
/**
141+
* Emitted when the editor's value has changed.
142+
* @example
143+
* ```html
144+
* <input igxDateTimeEditor (valueChanged)="onValueChanged($event)"/>
145+
* ```
146+
*/
61147
@Output()
62148
public valueChanged = new EventEmitter<IgxDateTimeEditorEventArgs>();
63149

150+
/**
151+
* Emitted when the editor is not within a specified range.
152+
* @example
153+
* ```html
154+
* <input igxDateTimeEditor [minValue]="minDate" [maxValue]="maxDate" (validationFailed)="onValidationFailed($event)"/>
155+
* ```
156+
*/
64157
@Output()
65158
public validationFailed = new EventEmitter<IgxDateTimeEditorEventArgs>();
66159

@@ -107,18 +200,25 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
107200
this._document = this.document as Document;
108201
}
109202

110-
/** @hidden */
203+
/** @hidden @internal */
111204
public ngOnInit(): void {
112205
this._dateTimeFormatParts = DatePickerUtil.parseDateTimeFormat(this.inputFormat);
113206
this.renderer.setAttribute(this.nativeElement, 'placeholder', this.inputFormat);
114207
this.updateMask();
115208
}
116209

210+
/**
211+
* Clear the input element value.
212+
*/
117213
public clear(): void {
118214
this.updateValue(null);
119215
this.updateMask();
120216
}
121217

218+
/**
219+
* Increment specified DatePart.
220+
* @param datePart The optional DatePart to increment. Defaults to Date or Hours(when Date is absent from the inputFormat - ex:'HH:mm').
221+
*/
122222
public increment(datePart?: DatePart): void {
123223
const newValue = datePart
124224
? this.calculateValueOnSpin(datePart, 1)
@@ -127,6 +227,11 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
127227
this.updateMask();
128228
}
129229

230+
/**
231+
* Decrement specified DatePart.
232+
*
233+
* @param datePart The optional DatePart to decrement. Defaults to Date or Hours(when Date is absent from the inputFormat - ex:'HH:mm').
234+
*/
130235
public decrement(datePart?: DatePart): void {
131236
const newValue = datePart
132237
? this.calculateValueOnSpin(datePart, -1)
@@ -135,21 +240,21 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
135240
this.updateMask();
136241
}
137242

138-
/** @hidden */
243+
/** @hidden @internal */
139244
public writeValue(value: any): void {
140245
this.value = value;
141246
}
142247

143-
/** @hidden */
248+
/** @hidden @internal */
144249
public registerOnChange(fn: any): void { this.onChangeCallback = fn; }
145250

146-
/** @hidden */
251+
/** @hidden @internal */
147252
public registerOnTouched(fn: any): void { this.onTouchCallback = fn; }
148253

149-
/** @hidden */
254+
/** @hidden @internal */
150255
public setDisabledState?(isDisabled: boolean): void { }
151256

152-
/** @hidden */
257+
/** @hidden @internal */
153258
public onKeyDown(event: KeyboardEvent) {
154259
super.onKeyDown(event);
155260
if (event.key === KEYS.UP_ARROW || event.key === KEYS.UP_ARROW_IE ||
@@ -166,15 +271,15 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
166271
this.moveCursor(event);
167272
}
168273

169-
/** @hidden */
274+
/** @hidden @internal */
170275
public onFocus(): void {
171276
this._isFocused = true;
172277
this.onTouchCallback();
173278
this.updateMask();
174279
super.onFocus();
175280
}
176281

177-
/** @hidden */
282+
/** @hidden @internal */
178283
public onBlur(event): void {
179284
this._isFocused = false;
180285

@@ -197,7 +302,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
197302
super.onBlur(event);
198303
}
199304

200-
/** @hidden */
305+
/** @hidden @internal */
201306
public updateMask() {
202307
if (!this.value || !this.isValidDate(this.value)) {
203308
this.inputValue = this.emptyMask;

projects/igniteui-angular/src/lib/drop-down/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { IgxDropDownItemBaseDirective } from './drop-down-item.base';
1111

1212
export * from './drop-down.component';
1313
export * from './drop-down-item.component';
14-
export { ISelectionEventArgs, IDropDownNavigationDirective, } from './drop-down.common';
14+
export { ISelectionEventArgs, IDropDownNavigationDirective } from './drop-down.common';
1515
export * from './drop-down-navigation.directive';
1616
export * from './drop-down.base';
1717
export * from './drop-down-item.base';

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

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
8686
}
8787

8888
public get_row_by_key(rowSelector: any): IgxRowDirective<IgxGridBaseDirective & GridType> {
89+
if (!this.grid) {
90+
return null;
91+
}
8992
const primaryKey = this.grid.primaryKey;
9093
if (primaryKey !== undefined && primaryKey !== null) {
9194
return this.grid.dataRowList.find((row) => row.rowData[primaryKey] === rowSelector);

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,14 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
462462
this.expressionsList[0].expression.searchVal === null &&
463463
this.expressionsList[0].expression.condition.isUnary === false) {
464464
this.filteringService.getExpressions(this.column.field).pop();
465+
466+
this.filter();
465467
} else {
466-
this.expressionsList.forEach((item) => {
467-
if (item.expression.searchVal === null && !item.expression.condition.isUnary) {
468-
this.filteringService.removeExpression(this.column.field, this.expressionsList.indexOf(item));
469-
}
470-
});
468+
const condToRemove = this.expressionsList.filter(ex => ex.expression.searchVal === null && !ex.expression.condition.isUnary);
469+
if (condToRemove && condToRemove.length > 0) {
470+
condToRemove.forEach(c => this.filteringService.removeExpression(this.column.field, this.expressionsList.indexOf(c)));
471+
this.filter();
472+
}
471473
}
472474

473475
this.filteringService.isFilterRowVisible = false;

0 commit comments

Comments
 (0)