Skip to content

Commit bcbcd6c

Browse files
authored
Merge branch '8.2.x' into vslavov/progress-bar-styles-8.2.x
2 parents fefd288 + dffe35c commit bcbcd6c

File tree

18 files changed

+341
-53
lines changed

18 files changed

+341
-53
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Ignite UI for Angular Change Log
22

33
All notable changes for each version of this project will be documented in this file.
4+
## 8.2.8
5+
### New Features
6+
- `IgxRowDragGhost` directive is added. It allows providing a custom template for the drag ghost when dragging a row.
7+
```html
8+
<igx-grid #grid1 [data]="remote | async" primaryKey="ProductID"
9+
[rowDraggable]="true">
10+
<igx-column field="ProductName"></igx-column>
11+
<igx-column field="ProductID"></igx-column>
12+
<igx-column field="UnitsInStock"></igx-column>
13+
<ng-template let-data igxRowDragGhost>
14+
<div>
15+
Moving {{data.ProductName}}!
16+
</div>
17+
</ng-template>
18+
</igx-grid>
19+
```
20+
421
## 8.2.6
522
### New Features
623
- `IgxSelectItem`

projects/igniteui-angular/migrations/update-8_2_6/index.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ describe('Update 8.2.6', () => {
6767
it('should update igx-grid-paginator-theme', done => {
6868
appTree.create(
6969
'/testSrc/appPrefix/component/test.component.scss',
70-
`$dark-grid-paginator: igx-grid-paginator-theme($color: black);
70+
`@import '~igniteui-angular/lib/core/styles/components/grid-paginator/grid-paginator-component';
71+
@import '~igniteui-angular/lib/core/styles/components/grid-paginator/grid-paginator-theme';
72+
$dark-grid-paginator: igx-grid-paginator-theme($color: black);
7173
@include igx-grid-paginator($dark-grid-paginator);
7274
.igx-grid-paginator__pager {
7375
@include igx-button($dark-button);
@@ -77,7 +79,9 @@ describe('Update 8.2.6', () => {
7779
const tree = schematicRunner.runSchematic('migration-12', {}, appTree);
7880
expect(tree.readContent('/testSrc/appPrefix/component/test.component.scss'))
7981
.toEqual(
80-
`$dark-grid-paginator: igx-paginator-theme($color: black);
82+
`@import '~igniteui-angular/lib/core/styles/components/paginator/paginator-component';
83+
@import '~igniteui-angular/lib/core/styles/components/paginator/paginator-theme';
84+
$dark-grid-paginator: igx-paginator-theme($color: black);
8185
@include igx-paginator($dark-grid-paginator);
8286
.igx-grid-paginator__pager {
8387
@include igx-button($dark-button);

projects/igniteui-angular/migrations/update-8_2_6/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ export default function(): Rule {
2929
'$_square-shape-pagination'];
3030

3131
let globalStyleExt: string;
32+
const gridPaginatorComponentImport = '~igniteui-angular/lib/core/styles/components/grid-paginator/grid-paginator-component';
33+
const gridPaginatorThemeImport = '~igniteui-angular/lib/core/styles/components/grid-paginator/grid-paginator-theme';
34+
const paginatorComponentImport = '~igniteui-angular/lib/core/styles/components/paginator/paginator-component';
35+
const paginatorThemeImport = '~igniteui-angular/lib/core/styles/components/paginator/paginator-theme';
3236
const config = getWorkspace(host);
3337
const projects = getProjects(config);
3438

3539
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
3640

41+
const update = new UpdateChanges(__dirname, host, context);
42+
3743
if (config.schematics && config.schematics['@schematics/angular:component']) {
3844
// updated projects have global prefix rather than per-project:
3945
globalStyleExt = config.schematics['@schematics/angular:component'].styleext;
@@ -56,12 +62,19 @@ export default function(): Rule {
5662
content = content.split(n).join(newThemes[i]);
5763
}
5864
});
65+
if (content.indexOf(gridPaginatorComponentImport) !== -1) {
66+
content = content.replace(gridPaginatorComponentImport, paginatorComponentImport);
67+
host.overwrite(path, content);
68+
}
69+
if (content.indexOf(gridPaginatorThemeImport) !== -1) {
70+
content = content.replace(gridPaginatorThemeImport, paginatorThemeImport);
71+
host.overwrite(path, content);
72+
}
5973
host.overwrite(path, content);
6074
}
6175
});
6276
}
6377

64-
const update = new UpdateChanges(__dirname, host, context);
6578
update.applyChanges();
6679
};
6780
}

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

Lines changed: 28 additions & 26 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ function getTargetedProjectOptions(project: WorkspaceProject<ProjectType>, targe
2424
throw new SchematicsException(`Cannot determine the project's configuration for: ${target}`);
2525
}
2626

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

34-
return buildOptions.main;
34+
return buildOptions[option];
3535
}
3636

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

projects/igniteui-angular/src/lib/core/styles/components/switch/_switch-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
), map-get($theme, variant));
174174

175175
$switch-off-offset: map-get((
176-
material: 1px,
176+
material: -1px,
177177
fluent: $switch-thumb-width / 3
178178
), map-get($theme, variant));
179179

@@ -279,7 +279,7 @@
279279
}
280280

281281
@include if-rtl() {
282-
transform: translateX(-#{rem($switch-off-offset)});
282+
transform: translateX(#{rem(-1 * $switch-off-offset)});
283283
}
284284

285285
&:hover {

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

Lines changed: 3 additions & 1 deletion
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/directives/for-of/for_of.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
746746
const diffs = [];
747747
let totalDiff = 0;
748748
const l = this._embeddedViews.length;
749+
this._embeddedViews.filter(view => !view.destroyed).forEach(view => view.detectChanges());
749750
const rNodes = this._embeddedViews.map(view => view.rootNodes.find(node => node.nodeType === Node.ELEMENT_NODE));
750751
for (let i = 0; i < l; i++) {
751752
const rNode = rNodes[i];

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import { DeprecateProperty } from '../core/deprecateDecorators';
103103
import { IFilteringStrategy } from '../data-operations/filtering-strategy';
104104
import { IgxRowExpandedIndicatorDirective, IgxRowCollapsedIndicatorDirective,
105105
IgxHeaderExpandIndicatorDirective, IgxHeaderCollapseIndicatorDirective } from './grid/grid.directives';
106+
import { IgxRowDragGhostDirective } from './row-drag.directive';
106107
import { GridKeydownTargetType, GridSelectionMode, GridSummaryPosition, GridSummaryCalculationMode, FilterMode } from './common/enums';
107108

108109
const MINIMUM_COLUMN_WIDTH = 136;
@@ -1937,6 +1938,13 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
19371938
@ContentChildren(IgxRowSelectorDirective, { read: IgxRowSelectorDirective, descendants: false })
19381939
public rowSelectorsTemplates: QueryList<IgxRowSelectorDirective>;
19391940

1941+
/**
1942+
* @hidden
1943+
* @internal
1944+
*/
1945+
@ContentChildren(IgxRowDragGhostDirective, { read: TemplateRef, descendants: false })
1946+
public dragGhostCustomTemplates: QueryList<TemplateRef<any>>;
1947+
19401948
/**
19411949
* @hidden
19421950
*/
@@ -3183,6 +3191,18 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
31833191
}
31843192
}
31853193

3194+
/**
3195+
* @hidden
3196+
* @internal
3197+
*/
3198+
public getDragGhostCustomTemplate() {
3199+
if (this.dragGhostCustomTemplates && this.dragGhostCustomTemplates.first) {
3200+
return this.dragGhostCustomTemplates.first;
3201+
}
3202+
3203+
return null;
3204+
}
3205+
31863206
/**
31873207
* @hidden
31883208
*/

0 commit comments

Comments
 (0)