Skip to content

Date/time picker: action buttons customization - master #5027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 11, 2019
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
31 changes: 26 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
# Ignite UI for Angular Change Log

All notable changes for each version of this project will be documented in this file.
## 7.3.1
`igx-core()` now includes some styles for printing layout. In order to turn them off, you need to pass an argument and set it to `false`
## 7.3.4

```
@include igx-core($print-layout: false);
```
- `igxTimePicker` changes
- `onClosing` event is added.
- **Breaking Change** `onOpen` event is renamed to `onOpened`.
- **Breaking Change** `onClose` event is renamed to `onClosed`.
- **Behavioral Change** - action buttons are now available in the dropdown mode.
- **Feature** `IgxTimePickerComponent` now provides the ability for adding custom action buttons. Read up more information in the [ReadMe](https://github.com/IgniteUI/igniteui-angular/tree/master/projects/igniteui-angular/src/lib/time-picker/README.md)

- `igxDatePicker` changes
- `onClosing` event is added.
- **Breaking Change** `onOpen` event is renamed to `onOpened`.
- **Breaking Change** `onClose` event is renamed to `onClosed`.
- **Behavioral Change** - action buttons are now available in the dropdown mode.
- **Feature** `IgxDatePickerComponent` now provides the ability for adding custom action buttons. Read up more information in the [ReadMe](https://github.com/IgniteUI/igniteui-angular/tree/master/projects/igniteui-angular/src/lib/date-picker/README.md)


## 7.3.3

- `igx-core()` now includes some styles for printing layout.
In order to turn them off, you need to pass an argument and set it to `false`
```
@include igx-core($print-layout: false);
```

- `Pager`
- **Behavioral Change** - The pager is now hidden when there are no records in the grid.

## 7.3.1
- `IgxGrid` Custom keyboard navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"version": "7.2.0",
"description": "Updates Ignite UI for Angular from v7.0.2 to v7.2.0",
"factory": "./update-7_2_0"
},
"migration-09": {
"version": "7.3.4",
"description": "Updates Ignite UI for Angular from v7.2.0 to v7.3.4",
"factory": "./update-7_3_4"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "../../common/schema/binding.schema.json",
"changes": [
{
"name": "onOpen",
"replaceWith": "onOpened",
"owner": {
"selector": "igx-time-picker",
"type": "component"
}
},
{
"name": "onClose",
"replaceWith": "onClosed",
"owner": {
"selector": "igx-time-picker",
"type": "component"
}
},
{
"name": "onOpen",
"replaceWith": "onOpened",
"owner": {
"selector": "igx-date-picker",
"type": "component"
}
},
{
"name": "onClose",
"replaceWith": "onClosed",
"owner": {
"selector": "igx-date-picker",
"type": "component"
}
}
]
}
54 changes: 54 additions & 0 deletions projects/igniteui-angular/migrations/update-7_3_4/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as path from 'path';

// tslint:disable:no-implicit-dependencies
import { virtualFs } from '@angular-devkit/core';
import { EmptyTree } from '@angular-devkit/schematics';
// tslint:disable-next-line:no-submodule-imports
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';

describe('Update 7.3.4', () => {
let appTree: UnitTestTree;
const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json'));
const configJson = {
defaultProject: 'testProj',
projects: {
testProj: {
sourceRoot: '/testSrc'
}
},
schematics: {
'@schematics/angular:component': {
prefix: 'appPrefix'
}
}
};

beforeEach(() => {
appTree = new UnitTestTree(new EmptyTree());
appTree.create('/angular.json', JSON.stringify(configJson));
});

it('should update time picker events', done => {
appTree.create(
'/testSrc/appPrefix/component/test.component.html',
`<igx-time-picker (onOpen)="handler" (onClose)="handler"></igx-time-picker>`
);
const tree = schematicRunner.runSchematic('migration-09', {}, appTree);
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html'))
.toEqual(
`<igx-time-picker (onOpened)="handler" (onClosed)="handler"></igx-time-picker>`);
done();
});

it('should update date picker events', done => {
appTree.create(
'/testSrc/appPrefix/component/test.component.html',
`<igx-date-picker (onOpen)="handler" (onClose)="handler"></igx-date-picker>`
);
const tree = schematicRunner.runSchematic('migration-09', {}, appTree);
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html'))
.toEqual(
`<igx-date-picker (onOpened)="handler" (onClosed)="handler"></igx-date-picker>`);
done();
});
});
25 changes: 25 additions & 0 deletions projects/igniteui-angular/migrations/update-7_3_4/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as path from 'path';

// tslint:disable:no-implicit-dependencies
import { normalize } from '@angular-devkit/core';
import {
chain,
Rule,
SchematicContext,
SchematicsException,
Tree
} from '@angular-devkit/schematics';
import { filterSourceDirs } from '../common/filterSourceDirs';
import { getImportModulePositions } from '../common/tsUtils';
import { UpdateChanges } from '../common/UpdateChanges';

const version = '7.3.4';

export default function(): Rule {
return (host: Tree, context: SchematicContext) => {
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);

const update = new UpdateChanges(__dirname, host, context);
update.applyChanges();
};
}
15 changes: 15 additions & 0 deletions projects/igniteui-angular/src/lib/date-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ In order to re-template a date picker in `dropdown` mode, an element should be m
</ng-template>
</igx-date-picker>
```
The DatePicker action buttons could be retemplated.
```html
<igx-date-picker #picker>
<ng-template igxDatePickerActions>
<div class="action-buttons">
<button igxButton="flat" (click)="selectToday(picker)">Today</button>
</div>
</ng-template>
</igx-date-picker>
```
```typescript
public selectToday(picker: IgxDatePickerComponent) {
picker.calendar.value = picker.calendar.viewDate = new Date(Date.now());
}
```

# API

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<igx-calendar #calendar></igx-calendar>
<div class="igx-date-picker__buttons" *ngIf="isReadonly &&
(cancelButtonLabel || todayButtonLabel)">
<button #closeButton *ngIf="cancelButtonLabel" igxButton="flat" igxRipple (click)="closeCalendar()">
{{ cancelButtonLabel }}
</button>
<button #todayButton *ngIf="todayButtonLabel" igxButton="flat" igxRipple (click)="triggerTodaySelection()">
{{ todayButtonLabel }}
</button>
<ng-template #defaultDatePickerActions>
<div *ngIf="cancelButtonLabel || todayButtonLabel" class="igx-date-picker__buttons">
<button #closeButton *ngIf="cancelButtonLabel" igxButton="flat" igxRipple (click)="closeCalendar()">
{{ cancelButtonLabel }}
</button>
<button #todayButton *ngIf="todayButtonLabel" igxButton="flat" igxRipple (click)="triggerTodaySelection()">
{{ todayButtonLabel }}
</button>
</div>
</ng-template>
<div>
<igx-calendar #calendar></igx-calendar>
<ng-container *ngTemplateOutlet="datePickerActions ? datePickerActions.template : defaultDatePickerActions"></ng-container>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ViewChild, Input, Output, EventEmitter, HostListener, HostBinding } from '@angular/core';
import { IgxCalendarComponent } from '../calendar';
import { InteractionMode } from '../core/enums';
import { IgxDatePickerActionsDirective } from './date-picker.directives';

/**
* @hidden
Expand All @@ -26,6 +27,9 @@ export class IgxCalendarContainerComponent {
@Input()
public todayButtonLabel: string;

@Input()
public datePickerActions: IgxDatePickerActionsDirective;

@Output()
public onClose = new EventEmitter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ describe('IgxDatePicker', () => {
const picker = document.getElementsByClassName('igx-calendar-picker');
const formattedSubHeaderText = (picker[0].children[1] as HTMLElement).innerText;
expect(formattedSubHeaderText).toBe('2019/Oct');

const buttons = document.getElementsByClassName('igx-button--flat');
expect(buttons.length).toEqual(1);
expect((buttons[0]as HTMLElement).innerText).toBe('TEST');
});

it('Retemplated calendar in date picker - dropdown mode', () => {
Expand All @@ -295,6 +299,10 @@ describe('IgxDatePicker', () => {
const picker = document.getElementsByClassName('igx-calendar-picker');
const formattedSubHeaderText = (picker[0].children[1] as HTMLElement).innerText;
expect(formattedSubHeaderText).toBe('2019/Oct');

const buttons = document.getElementsByClassName('igx-button--flat');
expect(buttons.length).toEqual(1);
expect((buttons[0]as HTMLElement).innerText).toBe('TEST');
});

it('locale propagate calendar value (de-DE)', () => {
Expand Down Expand Up @@ -1197,6 +1205,9 @@ export class IgxDatePickerEditableComponent {
<span class="date__el" (click)="format.yearView()">{{ format.year.combined }}/</span>
<span class="date__el" (click)="format.monthView()">{{ format.month.combined | titlecase }}</span>
</ng-template>
<ng-template igxDatePickerActions>
<button igxButton="flat">TEST</button>
</ng-template>
</igx-date-picker>
`
})
Expand Down
Loading