Browse Source
Merge pull request #4546 from abpframework/feat/4545
Hid Menu Items When Permission Check For All Children Fail
pull/4552/head
Mehmet Erim
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
16 additions and
1 deletions
-
npm/ng-packs/packages/core/src/lib/services/routes.service.ts
-
npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts
-
npm/ng-packs/packages/theme-basic/src/lib/components/routes/routes.component.ts
|
|
@ -151,6 +151,11 @@ export abstract class AbstractNavTreeService<T extends ABP.Nav> extends Abstract |
|
|
return this.store.selectSnapshot(ConfigState.getGrantedPolicy(requiredPolicy)); |
|
|
return this.store.selectSnapshot(ConfigState.getGrantedPolicy(requiredPolicy)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hasChildren(identifier: string): boolean { |
|
|
|
|
|
const node = this.find(item => item[this.id] === identifier); |
|
|
|
|
|
return Boolean(node?.children?.length); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
hasInvisibleChild(identifier: string): boolean { |
|
|
hasInvisibleChild(identifier: string): boolean { |
|
|
const node = this.find(item => item[this.id] === identifier); |
|
|
const node = this.find(item => item[this.id] === identifier); |
|
|
return node?.children?.some(child => child.invisible); |
|
|
return node?.children?.some(child => child.invisible); |
|
|
|
|
|
@ -68,6 +68,16 @@ describe('Routes Service', () => { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('#hasChildren', () => { |
|
|
|
|
|
it('should return if node has invisible child', () => { |
|
|
|
|
|
service.add(routes); |
|
|
|
|
|
|
|
|
|
|
|
expect(service.hasChildren('foo')).toBe(true); |
|
|
|
|
|
expect(service.hasChildren('bar')).toBe(true); |
|
|
|
|
|
expect(service.hasChildren('baz')).toBe(false); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('#hasInvisibleChild', () => { |
|
|
describe('#hasInvisibleChild', () => { |
|
|
it('should return if node has invisible child', () => { |
|
|
it('should return if node has invisible child', () => { |
|
|
service.add(routes); |
|
|
service.add(routes); |
|
|
|
|
|
@ -13,6 +13,6 @@ export class RoutesComponent { |
|
|
constructor(public readonly routes: RoutesService) {} |
|
|
constructor(public readonly routes: RoutesService) {} |
|
|
|
|
|
|
|
|
isDropdown(node: TreeNode<ABP.Route>) { |
|
|
isDropdown(node: TreeNode<ABP.Route>) { |
|
|
return !node.isLeaf || this.routes.hasInvisibleChild(node.name); |
|
|
return !node.isLeaf || this.routes.hasChildren(node.name); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|