Skip to content

Commit d7dfe81

Browse files
committed
feat(query-builder): migrate fields to entities
1 parent 9059fee commit d7dfe81

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "../../common/schema/binding.schema.json",
3+
"changes": [
4+
{
5+
"name": "fields",
6+
"replaceWith": "entities",
7+
"valueTransform": "fields_to_entities",
8+
"owner": {
9+
"selector": "igx-query-builder",
10+
"type": "component"
11+
}
12+
}
13+
]
14+
}

projects/igniteui-angular/migrations/update-18_2_0/index.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,20 @@ describe(`Update to ${version}`, () => {
135135
);`
136136
);
137137
});
138+
139+
it('should replace QueryBuilder deprecated property `fields` with `entities`', async () => {
140+
appTree.create(`/testSrc/appPrefix/component/test.component.html`,
141+
`
142+
<igx-query-builder [fields]="[{ field: 'ID', dataType: 'number' }, { field: 'Name', dataType: 'string' }]"></igx-query-builder>
143+
`
144+
);
145+
146+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
147+
148+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')).toEqual(
149+
`
150+
<igx-query-builder [entities]="[{ name: '', fields: [{ field: 'ID', dataType: 'number' }, { field: 'Name', dataType: 'string' }]}]"></igx-query-builder>
151+
`
152+
);
153+
});
138154
});

projects/igniteui-angular/migrations/update-18_2_0/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import type {
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
6-
import { UpdateChanges } from '../common/UpdateChanges';
6+
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from '../common/UpdateChanges';
77

88
const version = '18.2.0';
99

1010
export default (): Rule => async (host: Tree, context: SchematicContext) => {
1111
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
1212
const update = new UpdateChanges(__dirname, host, context);
13+
14+
update.addValueTransform('fields_to_entities', (args: BoundPropertyObject): void => {
15+
args.bindingType = InputPropertyType.EVAL;
16+
args.value = `[{ name: '', fields: ${args.value}}]`;
17+
});
18+
1319
update.applyChanges();
1420
};

0 commit comments

Comments
 (0)