Skip to content

Commit 04edfd1

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into ha-mutliview-calendar-2
2 parents d752ee1 + 78d94aa commit 04edfd1

20 files changed

+378
-56
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ All notable changes for each version of this project will be documented in this
1414
- **Breaking Change** `igxExcelStyleMovingTemplate` directive is renamed to `igxExcelStyleMoving`.
1515
- **Breaking Change** `igxExcelStyleHidingTemplate` directive is renamed to `igxExcelStyleHiding`.
1616
- **Breaking Change** `igxExcelStylePinningTemplate` directive is renamed to `igxExcelStylePinning`.
17+
## 8.1.4
18+
- `IgxDialog` new @Input `positionSettings` is now available. It provides the ability to get/set both position and animation settings of the Dialog component.
1719

1820
## 8.1.3
1921
- `IgxCombo`

projects/igniteui-angular/src/lib/core/styles/components/navdrawer/_navdrawer-theme.scss

+8-3
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@
209209
%aside--mini {
210210
width: rem(60px);
211211
transition-duration: .2s, .2s;
212+
213+
%item {
214+
justify-content: center;
215+
}
212216
}
213217

214218
%aside--normal {
@@ -251,17 +255,18 @@
251255
%item {
252256
position: relative;
253257
display: flex;
258+
align-items: center;
254259
flex-flow: row nowrap;
255260
color: --var($theme, 'item-text-color');
256261
max-height: rem(48px);
257-
padding: rem(12px) rem(16px);
262+
min-width: rem(32px);
263+
padding: rem(12px) rem(8px);
258264
cursor: pointer;
259-
align-items: center;
260265
user-select: none;
261266
outline: transparent;
262267
white-space: nowrap;
263268
border-radius: --var($theme, 'item-border-radius');
264-
margin: 8px;
269+
margin: rem(8px) rem(8px);
265270

266271
> igx-icon + span {
267272
margin-left: rem(32px);

projects/igniteui-angular/src/lib/dialog/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,23 @@ or
9393
<div igxDialogActions>BUTTONS</div>
9494
</igx-dialog>
9595
```
96+
97+
You can now set set the position and animation settings used by the dialog by using `positionSettings` @Input
98+
99+
```typescript
100+
import { slideInLeft, slideOutRight } from 'igniteui-angular';
101+
...
102+
@ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
103+
public newPositionSettings: PositionSettings = {
104+
openAnimation: useAnimation(slideInTop, { params: { duration: '2000ms' } }),
105+
closeAnimation: useAnimation(slideOutBottom, { params: { duration: '2000ms'} }),
106+
horizontalDirection: HorizontalAlignment.Left,
107+
verticalDirection: VerticalAlignment.Middle,
108+
horizontalStartPoint: HorizontalAlignment.Left,
109+
verticalStartPoint: VerticalAlignment.Middle,
110+
minSize: { height: 100, width: 100 }
111+
};
112+
113+
this.alert.positionSettings = this.newPositionSettings;
114+
```
115+

projects/igniteui-angular/src/lib/dialog/dialog.component.spec.ts

+108-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { Component, DebugElement, ElementRef, ViewChild } from '@angular/core';
2-
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
1+
import { Component, ViewChild } from '@angular/core';
2+
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
66
import { IDialogEventArgs, IgxDialogComponent, IgxDialogModule } from './dialog.component';
77
import { configureTestSuite } from '../test-utils/configure-suite';
8+
import { PositionSettings, slideInTop, slideOutBottom, HorizontalAlignment, VerticalAlignment } from 'igniteui-angular';
9+
import { useAnimation } from '@angular/animations';
810

911
const OVERLAY_MAIN_CLASS = 'igx-overlay';
1012
const OVERLAY_WRAPPER_CLASS = `${OVERLAY_MAIN_CLASS}__wrapper`;
1113
const OVERLAY_MODAL_WRAPPER_CLASS = `${OVERLAY_WRAPPER_CLASS}--modal`;
14+
const CLASS_OVERLAY_CONTENT_MODAL = `${OVERLAY_MAIN_CLASS}__content--modal`;
1215

1316
describe('Dialog', () => {
1417
configureTestSuite();
@@ -21,7 +24,8 @@ describe('Dialog', () => {
2124
NestedDialogsComponent,
2225
CustomTemplates1DialogComponent,
2326
CustomTemplates2DialogComponent,
24-
DialogSampleComponent
27+
DialogSampleComponent,
28+
PositionSettingsDialogComponent
2529
],
2630
imports: [BrowserAnimationsModule, NoopAnimationsModule, IgxDialogModule]
2731
}).compileComponents();
@@ -322,6 +326,78 @@ describe('Dialog', () => {
322326
expect(dialog.isOpen).toEqual(false);
323327
}));
324328

329+
describe('Position settings', () => {
330+
let fix;
331+
let dialog;
332+
let detect;
333+
334+
beforeEach( fakeAsync(() => {
335+
fix = TestBed.createComponent(PositionSettingsDialogComponent);
336+
fix.detectChanges();
337+
dialog = fix.componentInstance.dialog;
338+
detect = () => dialog.cdr.detectChanges();
339+
}));
340+
341+
it('Define different position settings ', (async() => {
342+
const currentElement = fix.componentInstance;
343+
dialog.open();
344+
fix.detectChanges();
345+
await wait(16);
346+
347+
expect(dialog.isOpen).toEqual(true);
348+
const firstContentRect = document.getElementsByClassName(CLASS_OVERLAY_CONTENT_MODAL)[0].getBoundingClientRect();
349+
const middleDialogPosition = document.documentElement.offsetHeight / 2 - firstContentRect.height / 2;
350+
expect(firstContentRect.left).toEqual(0, 'OffsetLeft position check');
351+
expect(firstContentRect.top).toBeGreaterThanOrEqual(middleDialogPosition - 2, 'OffsetTop position check');
352+
expect(firstContentRect.top).toBeLessThanOrEqual(middleDialogPosition + 2, 'OffsetTop position check');
353+
354+
dialog.close();
355+
fix.detectChanges();
356+
await wait(16);
357+
358+
expect(dialog.isOpen).toEqual(false);
359+
dialog.positionSettings = currentElement.newPositionSettings;
360+
fix.detectChanges();
361+
await wait(16);
362+
363+
dialog.open();
364+
fix.detectChanges();
365+
await wait(16);
366+
367+
expect(dialog.isOpen).toEqual(true);
368+
const secondContentRect = document.getElementsByClassName(CLASS_OVERLAY_CONTENT_MODAL)[0].getBoundingClientRect();
369+
const topDialogPosition = document.documentElement.offsetWidth / 2 - secondContentRect.width / 2;
370+
expect(secondContentRect.top).toEqual(0, 'OffsetTop position check');
371+
expect(secondContentRect.left).toBeGreaterThanOrEqual(topDialogPosition - 2, 'OffsetLeft position check');
372+
expect(secondContentRect.left).toBeLessThanOrEqual(topDialogPosition + 2, 'OffsetLeft position check');
373+
374+
dialog.close();
375+
fix.detectChanges();
376+
await wait(16);
377+
378+
expect(dialog.isOpen).toEqual(false);
379+
}));
380+
381+
it('Set animation settings', (async() => {
382+
const currentElement = fix.componentInstance;
383+
384+
// Check initial animation settings
385+
expect(dialog.positionSettings.openAnimation.animation.type).toEqual(8, 'Animation type is set');
386+
expect(dialog.positionSettings.openAnimation.options.params.duration).toEqual('200ms', 'Animation duration is set to 200ms');
387+
388+
expect(dialog.positionSettings.closeAnimation.animation.type).toEqual(8, 'Animation type is set');
389+
expect(dialog.positionSettings.closeAnimation.options.params.duration).toEqual('200ms', 'Animation duration is set to 200ms');
390+
391+
dialog.positionSettings = currentElement.animationSettings;
392+
fix.detectChanges();
393+
await wait(16);
394+
395+
// Check the new animation settings
396+
expect(dialog.positionSettings.openAnimation.options.params.duration).toEqual('800ms', 'Animation duration is set to 800ms');
397+
expect(dialog.positionSettings.closeAnimation.options.params.duration).toEqual('700ms', 'Animation duration is set to 700ms');
398+
}));
399+
});
400+
325401
function dispatchEvent(element: HTMLElement, eventType: string) {
326402
const event = new Event(eventType);
327403
element.dispatchEvent(event);
@@ -436,3 +512,32 @@ class CustomTemplates1DialogComponent {
436512
class CustomTemplates2DialogComponent {
437513
@ViewChild('dialog', { static: true }) public dialog: IgxDialogComponent;
438514
}
515+
516+
517+
@Component({
518+
template: `<igx-dialog #dialog title="Notification" message="Your email has been sent successfully!" leftButtonLabel="OK"
519+
[positionSettings]="positionSettings" >
520+
</igx-dialog>` })
521+
class PositionSettingsDialogComponent {
522+
@ViewChild('dialog', { static: true }) public dialog: IgxDialogComponent;
523+
524+
public positionSettings: PositionSettings = {
525+
horizontalDirection: HorizontalAlignment.Left,
526+
verticalDirection: VerticalAlignment.Middle,
527+
horizontalStartPoint: HorizontalAlignment.Left,
528+
verticalStartPoint: VerticalAlignment.Middle,
529+
openAnimation: useAnimation(slideInTop, { params: { duration: '200ms' } }),
530+
closeAnimation: useAnimation(slideOutBottom, { params: { duration: '200ms'} })
531+
};
532+
533+
public newPositionSettings: PositionSettings = {
534+
horizontalDirection: HorizontalAlignment.Center,
535+
verticalDirection: VerticalAlignment.Top
536+
};
537+
538+
public animationSettings: PositionSettings = {
539+
openAnimation: useAnimation(slideInTop, { params: { duration: '800ms' } }),
540+
closeAnimation: useAnimation(slideOutBottom, { params: { duration: '700ms'} })
541+
};
542+
543+
}

projects/igniteui-angular/src/lib/dialog/dialog.component.ts

+37-2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,41 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
216216
this._closeOnOutsideSelect = val;
217217
}
218218

219+
/**
220+
* Get the position and animation settings used by the dialog.
221+
* ```typescript
222+
* @ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
223+
* let currentPosition: PositionSettings = this.alert.positionSettings
224+
* ```
225+
*/
226+
@Input()
227+
public get positionSettings(): PositionSettings {
228+
return this._positionSettings;
229+
}
230+
231+
/**
232+
* Set the position and animation settings used by the dialog.
233+
* ```typescript
234+
* import { slideInLeft, slideOutRight } from 'igniteui-angular';
235+
* ...
236+
* @ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
237+
* public newPositionSettings: PositionSettings = {
238+
* openAnimation: useAnimation(slideInTop, { params: { duration: '2000ms' } }),
239+
* closeAnimation: useAnimation(slideOutBottom, { params: { duration: '2000ms'} }),
240+
* horizontalDirection: HorizontalAlignment.Left,
241+
* verticalDirection: VerticalAlignment.Middle,
242+
* horizontalStartPoint: HorizontalAlignment.Left,
243+
* verticalStartPoint: VerticalAlignment.Middle,
244+
* minSize: { height: 100, width: 100 }
245+
* };
246+
* this.alert.positionSettings = this.newPositionSettings;
247+
* ```
248+
*/
249+
public set positionSettings(settings: PositionSettings) {
250+
this._positionSettings = settings;
251+
this._overlayDefaultSettings.positionStrategy = new GlobalPositionStrategy(this._positionSettings);
252+
}
253+
219254
/**
220255
* An event that is emitted when the dialog is opened.
221256
*```html
@@ -258,7 +293,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
258293
@Output()
259294
public onRightButtonSelect = new EventEmitter<IDialogEventArgs>();
260295

261-
private _animaitonSettings: PositionSettings = {
296+
private _positionSettings: PositionSettings = {
262297
openAnimation: useAnimation(slideInBottom, { params: { fromPosition: 'translateY(100%)' } }),
263298
closeAnimation: useAnimation(slideOutTop, { params: { toPosition: 'translateY(-100%)' } })
264299
};
@@ -365,7 +400,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
365400
this._titleId = IgxDialogComponent.NEXT_ID++ + '_title';
366401

367402
this._overlayDefaultSettings = {
368-
positionStrategy: new GlobalPositionStrategy(this._animaitonSettings),
403+
positionStrategy: new GlobalPositionStrategy(this._positionSettings),
369404
scrollStrategy: new NoOpScrollStrategy(),
370405
modal: this.isModal,
371406
closeOnOutsideClick: this.closeOnOutsideSelect

projects/igniteui-angular/src/lib/directives/drag-drop/drag-drop.directive.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
942942

943943
const totalMovedX = pageX - this._startX;
944944
const totalMovedY = pageY - this._startY;
945-
this._dragGhostHostX = this.dragGhostHost ? this.getdragGhostHostOffsetLeft(this.dragGhostHost) : 0;
946-
this._dragGhostHostY = this.dragGhostHost ? this.getdragGhostHostOffsetTop(this.dragGhostHost) : 0;
945+
this._dragGhostHostX = this.dragGhostHost ? this.getDragGhostHostOffsetLeft(this.dragGhostHost) : 0;
946+
this._dragGhostHostY = this.dragGhostHost ? this.getDragGhostHostOffsetTop(this.dragGhostHost) : 0;
947947

948948
this.dragGhost.style.transitionDuration = '0.0s';
949949
this.dragGhost.style.position = 'absolute';
@@ -1220,21 +1220,21 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
12201220
return window.scrollX ? window.scrollX : (window.pageXOffset ? window.pageXOffset : 0);
12211221
}
12221222

1223-
protected getdragGhostHostOffsetLeft(dragGhostHost: any) {
1224-
if (dragGhostHost.computedStyleMap().get('position').value === 'static' &&
1225-
dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
1223+
protected getDragGhostHostOffsetLeft(dragGhostHost: any) {
1224+
const ghostPosition = document.defaultView.getComputedStyle(dragGhostHost).getPropertyValue('position');
1225+
if (ghostPosition === 'static' && dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
12261226
return 0;
1227-
} else if (dragGhostHost.computedStyleMap().get('position').value === 'static' && dragGhostHost.offsetParent) {
1227+
} else if (ghostPosition === 'static' && dragGhostHost.offsetParent) {
12281228
return dragGhostHost.offsetParent.getBoundingClientRect().left;
12291229
}
12301230
return dragGhostHost.getBoundingClientRect().left;
12311231
}
12321232

1233-
protected getdragGhostHostOffsetTop(dragGhostHost: any) {
1234-
if (dragGhostHost.computedStyleMap().get('position').value === 'static' &&
1235-
dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
1233+
protected getDragGhostHostOffsetTop(dragGhostHost: any) {
1234+
const ghostPosition = document.defaultView.getComputedStyle(dragGhostHost).getPropertyValue('position');
1235+
if (ghostPosition === 'static' && dragGhostHost.offsetParent && dragGhostHost.offsetParent === document.body) {
12361236
return 0;
1237-
} else if (dragGhostHost.computedStyleMap().get('position').value === 'static' && dragGhostHost.offsetParent) {
1237+
} else if (ghostPosition === 'static' && dragGhostHost.offsetParent) {
12381238
return dragGhostHost.offsetParent.getBoundingClientRect().top;
12391239
}
12401240
return dragGhostHost.getBoundingClientRect().top;

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

-2
Original file line numberDiff line numberDiff line change
@@ -2003,8 +2003,6 @@ export class IgxColumnLayoutComponent extends IgxColumnGroupComponent implements
20032003
}
20042004

20052005
this.children.forEach(child => {
2006-
child.disableHiding = true;
2007-
child.disablePinning = true;
20082006
child.movable = false;
20092007
});
20102008
}

projects/igniteui-angular/src/lib/grids/grid-toolbar.component.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
AbsoluteScrollStrategy
2222
} from '../services/index';
2323
import { GridBaseAPIService } from './api.service';
24+
import { IgxButtonDirective } from '../directives/button/button.directive';
2425
import { IgxGridBaseComponent, IGridDataBindable } from './grid-base.component';
2526
import { IgxDropDownComponent } from '../drop-down/drop-down.component';
2627
import { IgxColumnHidingComponent } from './column-hiding.component';
@@ -104,8 +105,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
104105
* const hidingButton = this.grid.toolbar.columnHidingButton;
105106
* ```
106107
*/
107-
@ViewChild('columnHidingButton', { static: false })
108-
public columnHidingButton;
108+
@ViewChild('columnHidingButton', { read: IgxButtonDirective, static: false })
109+
public columnHidingButton: IgxButtonDirective;
109110

110111
/**
111112
* Provides a reference to the `IgxDropDownComponent` of the Export button.
@@ -122,8 +123,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
122123
* const exportBtn = this.grid.toolbar.exportButton;
123124
* ```
124125
*/
125-
@ViewChild('btnExport', { static: false })
126-
public exportButton;
126+
@ViewChild('btnExport', { read: IgxButtonDirective, static: false })
127+
public exportButton: IgxButtonDirective;
127128

128129
/**
129130
* Provides a reference to the `IgxDropDownComponent` of the Column Pinning UI.
@@ -149,8 +150,8 @@ export class IgxGridToolbarComponent extends DisplayDensityBase {
149150
* const pinningButton = this.grid.toolbar.columnPinningButton;
150151
* ```
151152
*/
152-
@ViewChild('columnPinningButton', { static: false })
153-
public columnPinningButton;
153+
@ViewChild('columnPinningButton', { read: IgxButtonDirective, static: false })
154+
public columnPinningButton: IgxButtonDirective;
154155

155156
/**
156157
* Returns a reference to the `IgxGridComponent` component, hosting the `IgxGridToolbarComponent`.

projects/igniteui-angular/src/lib/grids/grid/grid-toolbar.spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { first } from 'rxjs/operators';
66
import { IgxCsvExporterOptions, IgxCsvExporterService, IgxExcelExporterOptions, IgxExcelExporterService } from '../../services/index';
7+
import { IgxButtonDirective } from '../../directives/button/button.directive';
78
import { IgxGridComponent } from './grid.component';
89
import { IgxGridModule } from './index';
910
import { DisplayDensity } from '../../core/displayDensity';
@@ -582,6 +583,28 @@ describe('IgxGrid - Grid Toolbar Custom Content', () => {
582583
expect(customContainer).not.toBe(null);
583584
});
584585

586+
it('should expose the toolbar buttons with their correct type', () => {
587+
fixture = TestBed.createComponent(GridToolbarTestPage1Component);
588+
fixture.detectChanges();
589+
grid = fixture.componentInstance.grid1;
590+
591+
grid.showToolbar = true;
592+
grid.columnHiding = true;
593+
grid.columnPinning = true;
594+
grid.exportExcel = true;
595+
grid.exportCsv = true;
596+
fixture.detectChanges();
597+
598+
let aButton = grid.toolbar.columnHidingButton;
599+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'column hiding button has wrong type');
600+
601+
aButton = grid.toolbar.columnPinningButton;
602+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'column pinning button has wrong type');
603+
604+
aButton = grid.toolbar.exportButton;
605+
expect(aButton instanceof IgxButtonDirective).toBe(true, 'export button has wrong type');
606+
});
607+
585608
});
586609

587610
function getToolbar(fixture) {

0 commit comments

Comments
 (0)