Browse Source

Rename removeByParams method name to removeByParam

pull/19440/head
Mustafa Daglioglu 2 years ago
parent
commit
27bac2c862
  1. 4
      docs/en/UI/Angular/Modifying-the-Menu.md
  2. 4
      npm/ng-packs/packages/core/src/lib/services/routes.service.ts
  3. 8
      npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts

4
docs/en/UI/Angular/Modifying-the-Menu.md

@ -241,7 +241,7 @@ After adding the `routes` property as described above, the navigation menu looks
## How to Patch or Remove a Navigation Element
The `patch` method of `RoutesService` finds a route by its name and replaces its configuration with the new configuration passed as the second parameter. Similarly, `remove` method finds a route and removes it along with its children. Also you can use `removeByParams` method to delete the routes with given properties.
The `patch` method of `RoutesService` finds a route by its name and replaces its configuration with the new configuration passed as the second parameter. Similarly, `remove` method finds a route and removes it along with its children. Also you can use `removeByParam` method to delete the routes with given properties.
```js
// this.routes is instance of RoutesService
@ -266,7 +266,7 @@ this.routes.patch('::Menu:Home', newHomeRouteConfig);
this.routes.remove(['Your navigation']);
// or
this.routes.removeByParams({ name: 'Your navigation' });
this.routes.removeByParam({ name: 'Your navigation' });
```
- Moved the _Home_ navigation under the _Administration_ dropdown based on given `parentName`.

4
npm/ng-packs/packages/core/src/lib/services/routes.service.ts

@ -152,7 +152,7 @@ export abstract class AbstractTreeService<T extends { [key: string | number | sy
return this.publish(flatItems);
}
removeByParams(params: Partial<T>): T[] | null {
removeByParam(params: Partial<T>): T[] | null {
if (!params) {
return null;
}
@ -168,7 +168,7 @@ export abstract class AbstractTreeService<T extends { [key: string | number | sy
}
for (const item of excludedList) {
this.removeByParams({ [this.parentId]: item[this.id] } as Partial<T>);
this.removeByParam({ [this.parentId]: item[this.id] } as Partial<T>);
}
const flatItems = this.flat.filter(item => !excludedList.includes(item));

8
npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts

@ -300,11 +300,11 @@ describe('Routes Service', () => {
});
});
describe('#removeByParams', () => {
describe('#removeByParam', () => {
it('should remove route based on given route', () => {
service.add(routes);
service.removeByParams({
service.removeByParam({
name: 'bar',
parentName: 'foo',
});
@ -333,7 +333,7 @@ describe('Routes Service', () => {
},
]);
service.removeByParams({
service.removeByParam({
path: '/foo/bar',
name: 'bar',
parentName: 'foo',
@ -360,7 +360,7 @@ describe('Routes Service', () => {
service.add(routes);
const flatLengthBeforeRemove = service.flat.length;
service.removeByParams({
service.removeByParam({
name: 'bar',
parentName: 'baz',
});

Loading…
Cancel
Save