Skip to content

Commit b6a94c7

Browse files
committed
feat(app): traverse organization selection
1 parent 17e156a commit b6a94c7

File tree

7 files changed

+117
-94
lines changed

7 files changed

+117
-94
lines changed

packages/core/state/src/lib/+state/management/organization/organization.facade.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class OrganizationFacade {
6060
readonly globalOrganization$ = this.store.select(
6161
organizationSelectors.selectOrganizationSelectedGlobalOrganization
6262
);
63+
64+
readonly globalChildrenOrganizations$ = this.store.select(
65+
organizationSelectors.selectGlobalChildrenOrganizations
66+
);
67+
6368
readonly actionStatus$ = this.store.select(
6469
organizationSelectors.selectActionStatus
6570
);

packages/core/state/src/lib/+state/management/organization/organization.reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const adapter: EntityAdapter<IOrganization> =
1515
export const initialState: IOrganizationState = adapter.getInitialState({
1616
selectedId: null,
1717
selectedGlobalOrganizationId: null,
18+
selectedGlobalOrganizationHistory: ['system'],
1819
selectedParentId: null,
1920
parentIds: [],
2021
parentEntities: {},

packages/core/state/src/lib/+state/management/organization/organization.selectors.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,15 @@ export const selectError = createSelector(
143143
selectOrganization,
144144
(state: IOrganizationState) => state.error
145145
);
146+
147+
export const selectGlobalChildrenOrganizations = createSelector(
148+
selectOrganizationAll,
149+
selectOrganizationSelectedGlobalOrganizationId,
150+
(organizations, currentParentId) => {
151+
const filteredOrganization = organizations.filter(
152+
(org) => org.parentId === currentParentId
153+
) as IOrganization[];
154+
155+
return filteredOrganization;
156+
}
157+
);

packages/core/types/src/lib/interfaces/state/organization.state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface IOrganizationState
99
IBaseStore {
1010
selectedId: string | null;
1111
selectedGlobalOrganizationId: string | null;
12+
selectedGlobalOrganizationHistory: string[];
1213
selectedParentId: string | null;
1314
parentIds: string[];
1415
parentEntities: Dictionary<IOrganization>;

packages/modules/management/src/lib/components/iam/forms/user-creation-form/user-creation-form.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
>
6565
</vcl-form-control-group>
6666

67-
<vcl-form-control-group *ngIf="!schema.get('invite')?.value && !options.user">
67+
@if (!schema.get('invite')?.value && !options.user) {
68+
<vcl-form-control-group>
6869
<vcl-label>Password</vcl-label>
6970
<vcl-password-input>
7071
<input
@@ -75,6 +76,7 @@
7576
</vcl-password-input>
7677
<vcl-hint-error error="required">Password is required.</vcl-hint-error>
7778
</vcl-form-control-group>
79+
}
7880

7981
<!-- Locale -->
8082
<vcl-form-control-group>
Lines changed: 94 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
1-
<ng-container *ngIf="vm$ | async as vm">
2-
<div>
3-
<span
4-
#popoverOrganizationTarget
5-
class="inline-block"
1+
@if (vm$ | async; as vm) {
2+
<div>
3+
<span
4+
#popoverOrganizationTarget
5+
class="inline-block"
6+
>
7+
<button
8+
vcl-button
9+
[selectable]="true"
10+
(click)="
11+
templatePopoverOrganization.toggle();
12+
onClickGlobalOrganizationSelector()
13+
"
14+
class="half-transparent organization"
615
>
7-
<button
8-
vcl-button
9-
[selectable]="true"
10-
(click)="
11-
templatePopoverOrganization.toggle();
12-
onClickGlobalOrganizationSelector()
13-
"
14-
class="half-transparent organization"
15-
>
16-
<vcl-icogram>
17-
<vcl-icon icon="mdi:home-outline" />
18-
{{ vm.globalOrganization?.name }}
19-
<vcl-icon icon="mdi:chevron-down" />
20-
</vcl-icogram>
21-
</button>
22-
</span>
16+
<!-- This is the parent: starting with the topmost parent -->
17+
<vcl-icogram>
18+
<vcl-icon icon="mdi:home-outline" />
19+
{{ vm.globalOrganization?.name }}
20+
<vcl-icon icon="mdi:chevron-down" />
21+
</vcl-icogram>
22+
</button>
23+
</span>
2324

24-
<span
25-
#popoverAccountTarget
26-
class="inline-block"
25+
<span
26+
#popoverAccountTarget
27+
class="inline-block"
28+
>
29+
<button
30+
vcl-button
31+
[selectable]="true"
32+
(click)="templatePopoverAccount.toggle()"
33+
class="half-transparent account"
2734
>
28-
<button
29-
vcl-button
30-
[selectable]="true"
31-
(click)="templatePopoverAccount.toggle()"
32-
class="half-transparent account"
33-
>
34-
<vcl-icogram>
35-
<vcl-icon icon="mdi:account-outline" />
36-
{{ vm.user?.fullName }}
37-
<vcl-icon icon="mdi:chevron-down" />
38-
</vcl-icogram>
39-
</button>
40-
</span>
41-
</div>
35+
<vcl-icogram>
36+
<vcl-icon icon="mdi:account-outline" />
37+
{{ vm.user?.fullName }}
38+
<vcl-icon icon="mdi:chevron-down" />
39+
</vcl-icogram>
40+
</button>
41+
</span>
42+
</div>
4243

43-
<ng-template
44-
vclPopover
45-
#templatePopoverOrganization="vclPopover"
46-
[target]="popoverOrganizationTarget"
47-
[closeOnOffClick]="true"
48-
[positions]="rightOrientedPositions"
44+
<ng-template
45+
vclPopover
46+
#templatePopoverOrganization="vclPopover"
47+
[target]="popoverOrganizationTarget"
48+
[closeOnOffClick]="true"
49+
[positions]="rightOrientedPositions"
50+
>
51+
<!-- This are children -->
52+
<vcl-select-list
53+
(valueChange)="
54+
onSelectGlobalOrganization($event, vm.globalOrganization?.id ?? '');
55+
templatePopoverOrganization.close()
56+
"
4957
>
50-
<vcl-select-list
51-
(valueChange)="
52-
onSelectGlobalOrganization($event, vm.globalOrganization?.id ?? '');
53-
templatePopoverOrganization.close()
54-
"
58+
<vcl-select-list-item
59+
[value]="o?.id"
60+
*ngFor="let o of vm.organizations"
5561
>
56-
<vcl-select-list-item
57-
[value]="o?.id"
58-
*ngFor="let o of vm.organizations"
59-
>
60-
{{ o?.name }}
61-
</vcl-select-list-item>
62-
</vcl-select-list>
63-
</ng-template>
62+
{{ o?.name }}
63+
</vcl-select-list-item>
64+
</vcl-select-list>
65+
</ng-template>
6466

65-
<ng-template
66-
vclPopover
67-
#templatePopoverAccount="vclPopover"
68-
[target]="popoverAccountTarget"
69-
[closeOnOffClick]="true"
70-
[positions]="rightOrientedPositions"
67+
<ng-template
68+
vclPopover
69+
#templatePopoverAccount="vclPopover"
70+
[target]="popoverAccountTarget"
71+
[closeOnOffClick]="true"
72+
[positions]="rightOrientedPositions"
73+
>
74+
<vcl-select-list
75+
(valueChange)="
76+
onAccountItemSelected($event); templatePopoverAccount.close()
77+
"
7178
>
72-
<vcl-select-list
73-
(valueChange)="
74-
onAccountItemSelected($event); templatePopoverAccount.close()
75-
"
76-
>
77-
<vcl-select-list-item value="profile">
78-
<vcl-icon
79-
vclPrepend
80-
icon="mdi:account-cog-outline"
81-
></vcl-icon>
82-
Profile
83-
</vcl-select-list-item>
84-
<vcl-select-list-item value="preferences">
85-
<vcl-icon
86-
vclPrepend
87-
icon="mdi:cog-outline"
88-
></vcl-icon>
89-
Preferences
90-
</vcl-select-list-item>
91-
<vcl-select-list-item value="sign-out">
92-
<vcl-icon
93-
vclPrepend
94-
icon="mdi:logout"
95-
></vcl-icon>
96-
Sign Out
97-
</vcl-select-list-item>
98-
</vcl-select-list>
99-
</ng-template>
100-
</ng-container>
79+
<vcl-select-list-item value="profile">
80+
<vcl-icon
81+
vclPrepend
82+
icon="mdi:account-cog-outline"
83+
></vcl-icon>
84+
Profile
85+
</vcl-select-list-item>
86+
<vcl-select-list-item value="preferences">
87+
<vcl-icon
88+
vclPrepend
89+
icon="mdi:cog-outline"
90+
></vcl-icon>
91+
Preferences
92+
</vcl-select-list-item>
93+
<vcl-select-list-item value="sign-out">
94+
<vcl-icon
95+
vclPrepend
96+
icon="mdi:logout"
97+
></vcl-icon>
98+
Sign Out
99+
</vcl-select-list-item>
100+
</vcl-select-list>
101+
</ng-template>
102+
}

packages/modules/ui/src/lib/components/organisms/header/header-toolbar.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class RcHeaderToolbarComponent implements OnInit {
3434

3535
readonly vm$ = combineLatest({
3636
user: this.accountFacade.user$,
37-
organizations: this.organizationFacade.parentsAll$,
37+
organizations: this.organizationFacade.globalChildrenOrganizations$,
3838
globalOrganization: this.organizationFacade.globalOrganization$,
3939
});
4040

0 commit comments

Comments
 (0)