Skip to content

Commit 3c41e3b

Browse files
authored
Merge branch 'master' into SKrastev/fix-date-picker
2 parents 8034855 + d6f9c84 commit 3c41e3b

19 files changed

+327
-57
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ All notable changes for each version of this project will be documented in this
3030
- `setOffset` method added. It offsets the content along the corresponding axis by the provided amount.
3131
- `IgxToggleDirective`:
3232
- `setOffset` method added. It offsets the content along the corresponding axis by the provided amount.
33+
- `IgxRowDragGhost` directive is added. It allows providing a custom template for the drag ghost when dragging a row.
34+
```html
35+
<igx-grid #grid1 [data]="remote | async" primaryKey="ProductID"
36+
[rowDraggable]="true">
37+
<igx-column field="ProductName"></igx-column>
38+
<igx-column field="ProductID"></igx-column>
39+
<igx-column field="UnitsInStock"></igx-column>
40+
<ng-template let-data igxRowDragGhost>
41+
<div>
42+
Moving {{data.ProductName}}!
43+
</div>
44+
</ng-template>
45+
</igx-grid>
46+
```
3347

3448
## 8.2.6
3549

projects/igniteui-angular/schematics/ng-add/index.spec.ts

+28-26
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ describe('ng-add schematics', () => {
99
const collectionPath = path.join(__dirname, '../collection.json');
1010
const runner: SchematicTestRunner = new SchematicTestRunner('cli-schematics', collectionPath);
1111
let tree: UnitTestTree;
12+
const sourceRoot = 'testSrc';
1213
const ngJsonConfig = {
1314
defaultProject: 'testProj',
1415
projects: {
1516
testProj: {
16-
sourceRoot: 'src',
17+
sourceRoot: sourceRoot,
1718
projectType: ProjectType.Application,
1819
architect: {
1920
serve: {},
2021
build: {
2122
options: {
22-
main: 'src/main.ts',
23+
main: `${sourceRoot}/main.ts`,
24+
polyfills: `${sourceRoot}/polyfills.ts`,
2325
scripts: []
2426
}
2527
}
@@ -42,7 +44,7 @@ describe('ng-add schematics', () => {
4244
tree = new UnitTestTree(new EmptyTree());
4345
tree.create('/angular.json', JSON.stringify(ngJsonConfig));
4446
tree.create('/package.json', JSON.stringify(pkgJsonConfig));
45-
tree.create('src/main.ts', '// test comment');
47+
tree.create(`${sourceRoot}/main.ts`, '// test comment');
4648
});
4749

4850
it('should create the needed files correctly', () => {
@@ -71,7 +73,7 @@ describe('ng-add schematics', () => {
7173

7274
it('should add hammer.js to the main.ts file', () => {
7375
runner.runSchematic('ng-add', { normalizeCss: false }, tree);
74-
const mainTs = tree.read('src/main.ts').toString();
76+
const mainTs = tree.read(`${sourceRoot}/main.ts`).toString();
7577
expect(mainTs).toContain('import \'hammerjs\';');
7678
});
7779

@@ -82,12 +84,12 @@ describe('ng-add schematics', () => {
8284
tree.overwrite('angular.json', JSON.stringify(workspace));
8385
runner.runSchematic('ng-add', { normalizeCss: false }, tree);
8486

85-
const newContent = tree.read('src/main.ts').toString();
87+
const newContent = tree.read(`${sourceRoot}/main.ts`).toString();
8688
expect(newContent.split('import \'hammerjs\';\n// test comment').length).toEqual(1);
8789
});
8890

8991
it('should not add hammer.js if it exists in main.ts', () => {
90-
const mainTsPath = 'src/main.ts';
92+
const mainTsPath = `${sourceRoot}/main.ts`;
9193
const content = tree.read(mainTsPath).toString();
9294
tree.overwrite(mainTsPath, 'import \'hammerjs\';\n' + content);
9395
runner.runSchematic('ng-add', { normalizeCss: false }, tree);
@@ -138,54 +140,54 @@ import 'core-js/es6/set';
138140
import 'web-animations-js'; // Run \`npm install --save web-animations-js\`.
139141
`;
140142

141-
tree.create('src/polyfills.ts', polyfills);
143+
tree.create(`${sourceRoot}/polyfills.ts`, polyfills);
142144
runner.runSchematic('ng-add', { polyfills: true, normalizeCss: false }, tree);
143-
expect(tree.readContent('src/polyfills.ts').replace(/\r\n/g, '\n')).toEqual(result.replace(/\r\n/g, '\n'));
145+
expect(tree.readContent(`${sourceRoot}/polyfills.ts`).replace(/\r\n/g, '\n')).toEqual(result.replace(/\r\n/g, '\n'));
144146
});
145147

146148
it('should properly add css reset', () => {
147-
tree.create('src/styles.scss', '');
149+
tree.create(`${sourceRoot}/styles.scss`, '');
148150
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
149151
let pkgJsonData = JSON.parse(tree.readContent('/package.json'));
150-
expect(tree.readContent('src/styles.scss')).toEqual(scssImport);
152+
expect(tree.readContent(`${sourceRoot}/styles.scss`)).toEqual(scssImport);
151153
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
152154
resetJsonConfigs(tree);
153-
tree.delete('src/styles.scss');
155+
tree.delete(`${sourceRoot}/styles.scss`);
154156

155-
tree.create('src/styles.sass', '');
157+
tree.create(`${sourceRoot}/styles.sass`, '');
156158
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
157159
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
158-
expect(tree.readContent('src/styles.sass')).toEqual(scssImport);
160+
expect(tree.readContent(`${sourceRoot}/styles.sass`)).toEqual(scssImport);
159161
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
160162
resetJsonConfigs(tree);
161-
tree.delete('src/styles.sass');
163+
tree.delete(`${sourceRoot}/styles.sass`);
162164

163-
tree.create('src/styles.css', '');
165+
tree.create(`${sourceRoot}/styles.css`, '');
164166
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
165167
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
166-
expect(tree.readContent('src/styles.css')).toBe('');
168+
expect(tree.readContent(`${sourceRoot}/styles.css`)).toBe('');
167169
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
168170
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
169171
resetJsonConfigs(tree);
170-
tree.delete('src/styles.css');
172+
tree.delete(`${sourceRoot}/styles.css`);
171173

172-
tree.create('src/styles.less', '');
174+
tree.create(`${sourceRoot}/styles.less`, '');
173175
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
174176
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
175-
expect(tree.readContent('src/styles.less')).toBe('');
177+
expect(tree.readContent(`${sourceRoot}/styles.less`)).toBe('');
176178
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
177179
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
178180
resetJsonConfigs(tree);
179-
tree.delete('src/styles.less');
181+
tree.delete(`${sourceRoot}/styles.less`);
180182

181-
tree.create('src/styles.styl', '');
183+
tree.create(`${sourceRoot}/styles.styl`, '');
182184
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
183185
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
184-
expect(tree.readContent('src/styles.styl')).toBe('');
186+
expect(tree.readContent(`${sourceRoot}/styles.styl`)).toBe('');
185187
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
186188
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
187189
resetJsonConfigs(tree);
188-
tree.delete('src/styles.styl');
190+
tree.delete(`${sourceRoot}/styles.styl`);
189191
});
190192

191193
it('should properly add web animations', () => {
@@ -202,7 +204,7 @@ import 'web-animations-js'; // Run \`npm install --save web-animations-js\`.
202204
* that is built with AngularCLI v7.3 or above. All else are considered below v7.3.
203205
*/
204206
it('should enable es5BrowserSupport on projects with ng cli version >= 7.3', () => {
205-
tree.create('src/polyfills.ts', '');
207+
tree.create(`${sourceRoot}/polyfills.ts`, '');
206208
const newJson: any = JSON.parse(tree.read('/angular.json').toString());
207209
newJson.projects['testProj'].architect.build.options['es5BrowserSupport'] = false;
208210
tree.overwrite('/angular.json', JSON.stringify(newJson));
@@ -226,11 +228,11 @@ import 'web-animations-js'; // Run \`npm install --save web-animations-js\`.
226228
import 'web-animations-js'; // Run \`npm install --save web-animations-js\`.
227229
`;
228230

229-
tree.create('src/polyfills.ts', polyfills);
231+
tree.create(`${sourceRoot}/polyfills.ts`, polyfills);
230232
const newJson: any = JSON.parse(tree.read('/angular.json').toString());
231233
newJson.projects['testProj'].architect.build.options['es5BrowserSupport'] = false;
232234
tree.overwrite('/angular.json', JSON.stringify(newJson));
233235
runner.runSchematic('ng-add', { polyfills: true }, tree);
234-
expect(tree.readContent('src/polyfills.ts').replace(/\r\n/g, '\n')).toEqual(result.replace(/\r\n/g, '\n'));
236+
expect(tree.readContent(`${sourceRoot}/polyfills.ts`).replace(/\r\n/g, '\n')).toEqual(result.replace(/\r\n/g, '\n'));
235237
});
236238
});

projects/igniteui-angular/schematics/ng-add/index.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
22
import { Options } from '../interfaces/options';
33
import { installPackageJsonDependencies } from '../utils/package-handler';
4-
import { logSuccess, addDependencies, overwriteJsonFile, getPropertyFromWorkspace } from '../utils/dependency-handler';
4+
import { logSuccess, addDependencies, overwriteJsonFile,
5+
getPropertyFromWorkspace, getConfigFile } from '../utils/dependency-handler';
56

67
import { addResetCss } from './add-normalize';
7-
import { getWorkspace } from '@schematics/angular/utility/config';
8+
import { getWorkspace, getConfig } from '@schematics/angular/utility/config';
89
import { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
910

1011

@@ -17,7 +18,9 @@ function propertyExistsInWorkspace(targetProp: string, workspace: WorkspaceSchem
1718
}
1819

1920
function enablePolyfills(tree: Tree, context: SchematicContext): string {
20-
const targetFile = 'src/polyfills.ts';
21+
const workspace = getWorkspace(tree);
22+
const project = workspace.projects[workspace.defaultProject];
23+
const targetFile = getConfigFile(project, 'polyfills');
2124
if (!tree.exists(targetFile)) {
2225
context.logger.warn(`${targetFile} not found. You may need to update polyfills.ts manually.`);
2326
return;
@@ -50,7 +53,8 @@ function readInput(options: Options): Rule {
5053
if (options.polyfills) {
5154
const workspace = getWorkspace(tree);
5255
const targetProperty = 'es5BrowserSupport';
53-
const polyfillsFile = 'src/polyfills.ts';
56+
const project = workspace.projects[workspace.defaultProject];
57+
const polyfillsFile = getConfigFile(project, 'polyfills');
5458
const propertyExists = propertyExistsInWorkspace(targetProperty, workspace);
5559
let polyfillsData = tree.read(polyfillsFile).toString();
5660
if (propertyExists) {

projects/igniteui-angular/schematics/utils/dependency-handler.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ function getTargetedProjectOptions(project: WorkspaceProject<ProjectType>, targe
2626
throw new SchematicsException(`Cannot determine the project's configuration for: ${target}`);
2727
}
2828

29-
function getMainFile(project: WorkspaceProject<ProjectType>): string {
29+
export function getConfigFile(project: WorkspaceProject<ProjectType>, option: string): string {
3030
const buildOptions = getTargetedProjectOptions(project, 'build');
31-
if (!buildOptions.main) {
32-
throw new SchematicsException(`Could not find the project main file inside of the ` +
31+
if (!buildOptions[option]) {
32+
throw new SchematicsException(`Could not find the project ${option} file inside of the ` +
3333
`workspace config (${project.sourceRoot})`);
3434
}
3535

36-
return buildOptions.main;
36+
return buildOptions[option];
3737
}
3838

3939
export function overwriteJsonFile(tree: Tree, targetFile: string, data: any) {
@@ -113,7 +113,7 @@ function includeDependencies(pkgJson: any, context: SchematicContext, tree: Tree
113113
const workspace = getWorkspace(tree);
114114
const project = workspace.projects[workspace.defaultProject];
115115
const projectOptions = getTargetedProjectOptions(project, 'build');
116-
const mainTsPath = getMainFile(project);
116+
const mainTsPath = getConfigFile(project, 'main');
117117
const hammerImport = 'import \'hammerjs\';\n';
118118
const mainTsContent = tree.read(mainTsPath).toString();
119119
// if there are no elements in the architect.build.options.scripts array that contain hammerjs

projects/igniteui-angular/src/lib/chips/chips-area.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class IgxChipsAreaComponent implements DoCheck, AfterViewInit, OnDestroy
147147
* }
148148
* ```
149149
*/
150-
@ContentChildren(IgxChipComponent)
150+
@ContentChildren(IgxChipComponent, { descendants: true })
151151
public chipsList: QueryList<IgxChipComponent>;
152152

153153
private modifiedChipsArray: IgxChipComponent[];

projects/igniteui-angular/src/lib/core/styles/components/progress/_progress-component.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@
113113
@extend %circular-text !optional;
114114
}
115115

116-
@include e(text, $m: hidden) {
117-
@extend %circular-text !optional;
118-
}
119-
120116
@include m(indeterminate) {
121117
@extend %circular-display--indeterminate !optional;
122118

123119
@include e(outer) {
124120
@extend %circular-outer--indeterminate !optional;
125121
}
122+
123+
@include e(text) {
124+
@extend %circular-text--hidden !optional;
125+
}
126126
}
127127
}

projects/igniteui-angular/src/lib/core/styles/components/progress/_progress-theme.scss

+4
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@
311311
fill: --var($theme, 'text-color');
312312
}
313313

314+
%circular-text--hidden {
315+
visibility: hidden;
316+
}
317+
314318
@include keyframes('indeterminate-accordion') {
315319
from {
316320
stroke-dashoffset: 578;

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

-4
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
953953

954954
this.emitValueChangeEvent(oldValue, this.value );
955955
this.onSelection.emit(date);
956-
this._onChangeCallback(date);
957956
}
958957

959958
/**
@@ -974,7 +973,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
974973
if (this.calendar) {
975974
this.calendar.deselectDate();
976975
}
977-
this._onChangeCallback(null);
978976
}
979977

980978
/**
@@ -1060,7 +1058,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10601058

10611059
this.emitValueChangeEvent(oldValue, this.value );
10621060
this.calendar.viewDate = date;
1063-
this._onChangeCallback(date);
10641061
this.closeCalendar();
10651062
this.onSelection.emit(date);
10661063
}
@@ -1205,7 +1202,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
12051202

12061203
this.emitValueChangeEvent(oldValue, this.value );
12071204
this.invalidDate = '';
1208-
this._onChangeCallback(newValue);
12091205
} else {
12101206
const args: IDatePickerDisabledDateEventArgs = {
12111207
datePicker: this,

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export class IgxDragLocation {
151151
})
152152
export class IgxDragDirective implements AfterContentInit, OnDestroy {
153153

154+
protected ghostContext: any = null;
155+
154156
/**
155157
* - Save data inside the `igxDrag` directive. This can be set when instancing `igxDrag` on an element.
156158
* ```html
@@ -1099,7 +1101,7 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
10991101

11001102
let dynamicGhostRef;
11011103
if (this.ghostTemplate) {
1102-
dynamicGhostRef = this.viewContainer.createEmbeddedView(this.ghostTemplate);
1104+
dynamicGhostRef = this.viewContainer.createEmbeddedView(this.ghostTemplate, this.ghostContext);
11031105
this.ghostElement = dynamicGhostRef.rootNodes[0];
11041106
} else {
11051107
this.ghostElement = node ? node.cloneNode(true) : this.element.nativeElement.cloneNode(true);

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

+20
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ import { IgxGridToolbarCustomContentDirective } from './toolbar/toolbar.directiv
132132
import { IgxColumnComponent } from './columns/column.component';
133133
import { IgxColumnGroupComponent } from './columns/column-group.component';
134134
import { IGridSortingStrategy } from '../data-operations/sorting-strategy';
135+
import { IgxRowDragGhostDirective } from './row-drag.directive';
135136

136137
const MINIMUM_COLUMN_WIDTH = 136;
137138
const FILTER_ROW_HEIGHT = 50;
@@ -1912,6 +1913,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
19121913
@ContentChildren(IgxRowSelectorDirective, { read: IgxRowSelectorDirective, descendants: false })
19131914
public rowSelectorsTemplates: QueryList<IgxRowSelectorDirective>;
19141915

1916+
/**
1917+
* @hidden
1918+
* @internal
1919+
*/
1920+
@ContentChildren(IgxRowDragGhostDirective, { read: TemplateRef, descendants: false })
1921+
public dragGhostCustomTemplates: QueryList<TemplateRef<any>>;
1922+
19151923
/**
19161924
* @hidden
19171925
*/
@@ -3167,6 +3175,18 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
31673175
}
31683176
}
31693177

3178+
/**
3179+
* @hidden
3180+
* @internal
3181+
*/
3182+
public getDragGhostCustomTemplate() {
3183+
if (this.dragGhostCustomTemplates && this.dragGhostCustomTemplates.first) {
3184+
return this.dragGhostCustomTemplates.first;
3185+
}
3186+
3187+
return null;
3188+
}
3189+
31703190
/**
31713191
* @hidden
31723192
*/

projects/igniteui-angular/src/lib/grids/grid/grid-row.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="igx-grid__row-indentation igx-grid__row-indentation--level-{{grid.groupingExpressions.length}}"></div>
33
</ng-container>
44
<ng-container *ngIf="rowDraggable">
5-
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()">
5+
<div [class]="resolveDragIndicatorClasses" [igxRowDrag]="this" (click)="$event.stopPropagation()" [ghostTemplate]="this.grid.getDragGhostCustomTemplate()">
66
<ng-container *ngTemplateOutlet="this.grid.dragIndicatorIconTemplate ? this.grid.dragIndicatorIconTemplate : this.grid.dragIndicatorIconBase"></ng-container>
77
</div>
88
</ng-container>

0 commit comments

Comments
 (0)