Skip to content

Commit b6c0082

Browse files
feat: Enable menu and account on one line, and icon-only menu items (#2826)
AB#121668 --------- Co-authored-by: Antoine Hurard <antoine@reliefapplications.org>
1 parent 16d4bb2 commit b6c0082

File tree

52 files changed

+669
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+669
-107
lines changed

apps/back-office/src/app/app-preview/app-preview.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[title]="title"
33
[leftSidenav]="showNavigation ? leftSidenav : undefined"
44
[sideMenu]="sideMenu"
5+
[topMenu]="topMenu"
56
[menuOpened]="!hideMenu"
67
></shared-layout>
78
<ng-template #toolbar>
@@ -13,6 +14,7 @@
1314
[nav]="nav"
1415
[navGroups]="navGroups"
1516
[appLayout]="true"
16-
[vertical]="!(!sideMenu && largeDevice)"
17+
[vertical]="topMenu ? false : !(!sideMenu && largeDevice)"
18+
[topMenu]="topMenu"
1719
></shared-navbar>
1820
</ng-template>

apps/back-office/src/app/app-preview/app-preview.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export class AppPreviewComponent
9999
* Use side menu or not.
100100
*/
101101
public sideMenu = false;
102+
/**
103+
* Use header menu or not.
104+
*/
105+
public topMenu = false;
102106
/** Should hide menu by default ( only when vertical ) */
103107
public hideMenu = false;
104108
/** Should show navigation. False if only one or less page visible */
@@ -158,6 +162,8 @@ export class AppPreviewComponent
158162
icon: x.icon || this.getNavIcon(x.type || ''),
159163
fontFamily: x.icon ? 'fa' : 'material',
160164
visible: x.visible ?? false,
165+
showName: x.navBar?.showName !== false,
166+
showIcon: x.navBar?.showIcon !== false,
161167
})) || []
162168
);
163169
}
@@ -282,7 +288,12 @@ export class AppPreviewComponent
282288
}
283289
this.application = application;
284290
this.sideMenu = this.application?.sideMenu ?? true;
291+
this.topMenu = this.application?.topMenu ?? false;
285292
this.hideMenu = this.application?.hideMenu ?? false;
293+
if (this.topMenu) {
294+
this.sideMenu = false;
295+
this.hideMenu = false;
296+
}
286297
} else {
287298
this.navGroups = [];
288299
}

apps/back-office/src/app/app-preview/pages/dashboard/graphql/queries.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const GET_DASHBOARD_BY_ID = gql`
2828
page {
2929
id
3030
showName
31+
navBar {
32+
showName
33+
showIcon
34+
}
3135
application {
3236
shortcut
3337
id
@@ -38,6 +42,10 @@ export const GET_DASHBOARD_BY_ID = gql`
3842
id
3943
icon
4044
showName
45+
navBar {
46+
showName
47+
showIcon
48+
}
4149
workflow {
4250
id
4351
page {

apps/back-office/src/app/app-preview/pages/workflow/graphql/queries.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const GET_WORKFLOW_BY_ID = gql`
2828
id
2929
icon
3030
showName
31+
navBar {
32+
showName
33+
showIcon
34+
}
3135
name
3236
type
3337
content
@@ -36,6 +40,11 @@ export const GET_WORKFLOW_BY_ID = gql`
3640
page {
3741
id
3842
name
43+
showName
44+
navBar {
45+
showName
46+
showIcon
47+
}
3948
canUpdate
4049
permissions {
4150
canSee {

apps/back-office/src/app/application/application.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[header]="header"
1111
[leftSidenav]="pages"
1212
[sideMenu]="sideMenu"
13+
[topMenu]="topMenu"
1314
[menuOpened]="!hideMenu"
1415
></shared-layout>
1516
<ng-template #header>
@@ -27,7 +28,8 @@
2728
[navGroups]="navGroups"
2829
[appLayout]="true"
2930
[canAddPage]="application?.canUpdate!"
30-
[vertical]="!(!sideMenu && largeDevice)"
31+
[topMenu]="topMenu"
32+
[vertical]="topMenu ? false : !(!sideMenu && largeDevice)"
3133
(reorder)="onReorder($event)"
3234
></shared-navbar>
3335
</ng-template>

apps/back-office/src/app/application/application.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export class ApplicationComponent
4343
public application?: Application;
4444
/** Use side menu or not */
4545
public sideMenu = false;
46+
/** Use header menu or not */
47+
public topMenu = false;
4648
/** Should hide menu by default ( only when vertical ) */
4749
public hideMenu = false;
4850
/** Is large device */
@@ -112,6 +114,8 @@ export class ApplicationComponent
112114
: `./${x.type}/${x.content}`,
113115
icon: x.icon || this.getNavIcon(x.type || ''),
114116
fontFamily: x.icon ? 'fa' : 'material',
117+
showName: x.navBar?.showName !== false,
118+
showIcon: x.navBar?.showIcon !== false,
115119
class: null,
116120
orderable: true,
117121
visible: x.visible ?? true,
@@ -216,7 +220,12 @@ export class ApplicationComponent
216220
}
217221
this.application = application;
218222
this.sideMenu = this.application?.sideMenu ?? true;
223+
this.topMenu = this.application?.topMenu ?? false;
219224
this.hideMenu = this.application?.hideMenu ?? false;
225+
if (this.topMenu) {
226+
this.sideMenu = false;
227+
this.hideMenu = false;
228+
}
220229
} else {
221230
this.title = '';
222231
this.navGroups = [];

apps/back-office/src/app/application/pages/form/form.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ export class FormComponent extends UnsubscribeComponent implements OnInit {
337337
icon: this.isStep ? this.step?.icon : this.page?.icon,
338338
visible: this.page?.visible,
339339
showName: this.isStep ? this.step?.showName : this.page?.showName,
340+
navBar: this.isStep ? this.step?.navBar : this.page?.navBar,
340341
accessData: {
341342
access: this.page
342343
? this.page.permissions

apps/back-office/src/app/application/pages/form/graphql/queries.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const GET_STEP_BY_ID = gql`
99
id
1010
icon
1111
showName
12+
navBar {
13+
showName
14+
showIcon
15+
}
1216
name
1317
createdAt
1418
modifiedAt
@@ -55,6 +59,10 @@ export const GET_PAGE_BY_ID = gql`
5559
id
5660
icon
5761
showName
62+
navBar {
63+
showName
64+
showIcon
65+
}
5866
name
5967
visible
6068
createdAt

apps/back-office/src/app/application/pages/settings/settings.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ <h1 class="!m-0">{{ 'common.general' | translate }}</h1>
8888
>
8989
</ui-textarea>
9090
</div>
91+
<!-- Top menu -->
92+
<div class="mb-6">
93+
<ui-toggle formControlName="topMenu">
94+
<ng-container ngProjectAs="label">
95+
{{
96+
'components.application.update.topMenu' | translate
97+
}}</ng-container
98+
>
99+
</ui-toggle>
100+
</div>
91101
<!-- Side menu -->
92102
<div class="mb-6">
93103
<ui-toggle formControlName="sideMenu">

apps/back-office/src/app/application/pages/settings/settings.component.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,33 @@ export class SettingsComponent extends UnsubscribeComponent implements OnInit {
124124
* @returns form group
125125
*/
126126
private createSettingsForm(application: Application) {
127-
return this.fb.group({
127+
const form = this.fb.group({
128128
id: [{ value: application.id, disabled: true }],
129129
name: [application.name, Validators.required],
130130
shortcut: [application.shortcut, shortcutValidator],
131131
sideMenu: [application.sideMenu],
132+
topMenu: [application.topMenu],
132133
hideMenu: [application.hideMenu],
133134
description: [application.description],
134135
status: [application.status],
135136
});
137+
// Make sure top menu and side menu are mutually exclusive
138+
form.controls.sideMenu.valueChanges
139+
.pipe(takeUntil(this.destroy$))
140+
.subscribe((value) => {
141+
if (value) {
142+
form.controls.topMenu.setValue(false, { emitEvent: false });
143+
}
144+
});
145+
form.controls.topMenu.valueChanges
146+
.pipe(takeUntil(this.destroy$))
147+
.subscribe((value) => {
148+
if (value) {
149+
form.controls.sideMenu.setValue(false, { emitEvent: false });
150+
form.controls.hideMenu.setValue(false, { emitEvent: false });
151+
}
152+
});
153+
return form;
136154
}
137155

138156
/**

0 commit comments

Comments
 (0)