Skip to content

Commit 30345c4

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

12 files changed

+121
-3
lines changed

src/models/application.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface Application extends Document {
2525
modifiedAt: Date;
2626
description?: string;
2727
sideMenu?: boolean;
28+
topMenu?: boolean;
2829
hideMenu?: boolean;
2930
status?: any;
3031
createdBy?: mongoose.Types.ObjectId;
@@ -75,6 +76,7 @@ const applicationSchema = new Schema<Application>(
7576
settings: mongoose.Schema.Types.Mixed,
7677
description: String,
7778
sideMenu: Boolean,
79+
topMenu: Boolean,
7880
hideMenu: Boolean,
7981
permissions: {
8082
canSee: [

src/models/page.model.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export interface Page extends Document {
3131
name: string;
3232
icon: string;
3333
showName?: boolean;
34+
navBar?: {
35+
showName?: boolean;
36+
showIcon?: boolean;
37+
};
3438
createdAt: Date;
3539
modifiedAt: Date;
3640
type: string;
@@ -64,6 +68,16 @@ const pageSchema = new Schema<Page>(
6468
name: String,
6569
icon: String,
6670
showName: Boolean,
71+
navBar: {
72+
showName: {
73+
type: Boolean,
74+
default: true,
75+
},
76+
showIcon: {
77+
type: Boolean,
78+
default: true,
79+
},
80+
},
6781
type: {
6882
type: String,
6983
enum: Object.values(contentType),

src/models/step.model.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export interface Step extends Document {
1212
name: string;
1313
icon: string;
1414
showName?: boolean;
15+
navBar?: {
16+
showName?: boolean;
17+
showIcon?: boolean;
18+
};
1519
createdAt: Date;
1620
modifiedAt: Date;
1721
type: string;
@@ -35,6 +39,16 @@ const stepSchema = new Schema<Step>(
3539
name: String,
3640
icon: String,
3741
showName: Boolean,
42+
navBar: {
43+
showName: {
44+
type: Boolean,
45+
default: true,
46+
},
47+
showIcon: {
48+
type: Boolean,
49+
default: true,
50+
},
51+
},
3852
type: {
3953
type: String,
4054
enum: Object.values(contentType),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
GraphQLBoolean,
3+
GraphQLInputObjectType,
4+
GraphQLNonNull,
5+
} from 'graphql';
6+
7+
/**
8+
* Nav Bar settings input type definition
9+
*/
10+
export const NavBarSettingsInputType = new GraphQLInputObjectType({
11+
name: 'NavBarSettingsInputType',
12+
fields: () => ({
13+
showName: { type: new GraphQLNonNull(GraphQLBoolean) },
14+
showIcon: { type: new GraphQLNonNull(GraphQLBoolean) },
15+
}),
16+
});

src/schema/mutation/duplicateApplication.mutation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default {
8888
name: args.name,
8989
description: baseApplication.description,
9090
sideMenu: baseApplication.sideMenu,
91+
topMenu: baseApplication.topMenu,
9192
hideMenu: baseApplication.hideMenu,
9293
status: status.pending,
9394
createdBy: user._id,

src/schema/mutation/editApplication.mutation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type EditApplicationArgs = {
2525
id: string | Types.ObjectId;
2626
description?: string;
2727
sideMenu?: boolean;
28+
topMenu?: boolean;
2829
hideMenu?: boolean;
2930
name?: string;
3031
status?: StatusType;
@@ -72,6 +73,7 @@ export default {
7273
id: { type: new GraphQLNonNull(GraphQLID) },
7374
description: { type: GraphQLString },
7475
sideMenu: { type: GraphQLBoolean },
76+
topMenu: { type: GraphQLBoolean },
7577
hideMenu: { type: GraphQLBoolean },
7678
name: { type: GraphQLString },
7779
status: { type: StatusEnumType },
@@ -117,6 +119,7 @@ export default {
117119
if (!isNil(args.shortcut) && args.shortcut !== '') {
118120
await validateShortcut(args.id, args.shortcut);
119121
}
122+
120123
Object.assign(
121124
update,
122125
args.name && { name: args.name },
@@ -126,9 +129,11 @@ export default {
126129
args.settings && { settings: args.settings },
127130
args.permissions && { permissions: args.permissions },
128131
!isNil(args.sideMenu) && { sideMenu: args.sideMenu },
132+
!isNil(args.topMenu) && { topMenu: args.topMenu },
129133
!isNil(args.hideMenu) && { hideMenu: args.hideMenu },
130134
!isNil(args.shortcut) && { shortcut: args.shortcut }
131135
);
136+
132137
application = await Application.findOneAndUpdate(filters, update, {
133138
new: true,
134139
});

src/schema/mutation/editPage.mutation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import GraphQLJSON from 'graphql-type-json';
1717
import { cloneDeep, has, isArray, isEmpty, isNil, omit } from 'lodash';
1818
import { Types } from 'mongoose';
1919
import { PageType } from '../types';
20+
import { NavBarSettingsInputType } from '@schema/inputs/navBarSettings.input';
2021

2122
/** Simple form permission change type */
2223
type SimplePermissionChange =
@@ -38,6 +39,10 @@ export type EditPageArgs = {
3839
id: string | Types.ObjectId;
3940
name?: string;
4041
showName?: boolean;
42+
navBar?: {
43+
showName?: boolean;
44+
showIcon?: boolean;
45+
};
4146
permissions?: any;
4247
icon?: string;
4348
visible?: boolean;
@@ -55,6 +60,7 @@ export default {
5560
id: { type: new GraphQLNonNull(GraphQLID) },
5661
name: { type: GraphQLString },
5762
showName: { type: GraphQLBoolean },
63+
navBar: { type: NavBarSettingsInputType },
5864
icon: { type: GraphQLString },
5965
permissions: { type: GraphQLJSON },
6066
visible: { type: GraphQLBoolean },
@@ -91,8 +97,9 @@ export default {
9197
// Create update
9298
const update = {
9399
...(args.name && { name: args.name }),
94-
...(args.icon && { icon: args.icon }),
100+
...(has(args, 'icon') && { icon: args.icon }),
95101
...(has(args, 'showName') && { showName: args.showName }),
102+
...(args.navBar && { navBar: args.navBar }),
96103
} as any;
97104
// Update buttons
98105
if (args.buttons) {

src/schema/mutation/editStep.mutation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import GraphQLJSON from 'graphql-type-json';
1717
import { cloneDeep, has, isArray, isEmpty, omit } from 'lodash';
1818
import { Types } from 'mongoose';
1919
import { StepType } from '../types';
20+
import { NavBarSettingsInputType } from '@schema/inputs/navBarSettings.input';
2021

2122
/** Simple form permission change type */
2223
type SimplePermissionChange =
@@ -38,6 +39,10 @@ type EditStepArgs = {
3839
id: string | Types.ObjectId;
3940
name?: string;
4041
showName?: boolean;
42+
navBar?: {
43+
showName?: boolean;
44+
showIcon?: boolean;
45+
};
4146
type?: string;
4247
content?: string | Types.ObjectId;
4348
permissions?: any;
@@ -55,6 +60,7 @@ export default {
5560
id: { type: new GraphQLNonNull(GraphQLID) },
5661
name: { type: GraphQLString },
5762
showName: { type: GraphQLBoolean },
63+
navBar: { type: NavBarSettingsInputType },
5864
icon: { type: GraphQLString },
5965
type: { type: GraphQLString },
6066
content: { type: GraphQLID },
@@ -105,10 +111,11 @@ export default {
105111
// Create update
106112
const update = {
107113
...(args.name && { name: args.name }),
108-
...(args.icon && { icon: args.icon }),
114+
...(has(args, 'icon') && { icon: args.icon }),
109115
...(args.type && { type: args.type }),
110116
...(args.content && { content: args.content }),
111117
...(has(args, 'showName') && { showName: args.showName }),
118+
...(args.navBar && { navBar: args.navBar }),
112119
} as any;
113120
// Update buttons
114121
if (args.buttons) {

src/schema/types/application.type.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ export const ApplicationType = new GraphQLObjectType({
7979
}
8080
},
8181
},
82+
topMenu: {
83+
type: GraphQLBoolean,
84+
resolve(parent) {
85+
if (isNil(parent.topMenu)) {
86+
return false;
87+
} else {
88+
return parent.topMenu;
89+
}
90+
},
91+
},
8292
hideMenu: {
8393
type: GraphQLBoolean,
8494
resolve(parent) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { GraphQLBoolean, GraphQLObjectType } from 'graphql';
2+
3+
/**
4+
* GraphQL nav bar settings type definition
5+
* Used in StepType and PageType
6+
*/
7+
export const NavBarSettingsType = new GraphQLObjectType({
8+
name: 'NavBarSettings',
9+
fields: () => ({
10+
showName: {
11+
type: GraphQLBoolean,
12+
},
13+
showIcon: {
14+
type: GraphQLBoolean,
15+
},
16+
}),
17+
});

0 commit comments

Comments
 (0)