diff --git a/src/models/application.model.ts b/src/models/application.model.ts index b661a3a71..81604cadf 100644 --- a/src/models/application.model.ts +++ b/src/models/application.model.ts @@ -25,6 +25,7 @@ export interface Application extends Document { modifiedAt: Date; description?: string; sideMenu?: boolean; + topMenu?: boolean; hideMenu?: boolean; status?: any; createdBy?: mongoose.Types.ObjectId; @@ -75,6 +76,7 @@ const applicationSchema = new Schema( settings: mongoose.Schema.Types.Mixed, description: String, sideMenu: Boolean, + topMenu: Boolean, hideMenu: Boolean, permissions: { canSee: [ diff --git a/src/models/page.model.ts b/src/models/page.model.ts index b7236a88d..26f8bfa32 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -31,6 +31,10 @@ export interface Page extends Document { name: string; icon: string; showName?: boolean; + navBar?: { + showName?: boolean; + showIcon?: boolean; + }; createdAt: Date; modifiedAt: Date; type: string; @@ -64,6 +68,16 @@ const pageSchema = new Schema( name: String, icon: String, showName: Boolean, + navBar: { + showName: { + type: Boolean, + default: true, + }, + showIcon: { + type: Boolean, + default: true, + }, + }, type: { type: String, enum: Object.values(contentType), diff --git a/src/models/step.model.ts b/src/models/step.model.ts index 08514b0c4..3baf3e588 100644 --- a/src/models/step.model.ts +++ b/src/models/step.model.ts @@ -12,6 +12,10 @@ export interface Step extends Document { name: string; icon: string; showName?: boolean; + navBar?: { + showName?: boolean; + showIcon?: boolean; + }; createdAt: Date; modifiedAt: Date; type: string; @@ -35,6 +39,16 @@ const stepSchema = new Schema( name: String, icon: String, showName: Boolean, + navBar: { + showName: { + type: Boolean, + default: true, + }, + showIcon: { + type: Boolean, + default: true, + }, + }, type: { type: String, enum: Object.values(contentType), diff --git a/src/schema/inputs/navBarSettings.input.ts b/src/schema/inputs/navBarSettings.input.ts new file mode 100644 index 000000000..88bc7ddf4 --- /dev/null +++ b/src/schema/inputs/navBarSettings.input.ts @@ -0,0 +1,16 @@ +import { + GraphQLBoolean, + GraphQLInputObjectType, + GraphQLNonNull, +} from 'graphql'; + +/** + * Nav Bar settings input type definition + */ +export const NavBarSettingsInputType = new GraphQLInputObjectType({ + name: 'NavBarSettingsInputType', + fields: () => ({ + showName: { type: new GraphQLNonNull(GraphQLBoolean) }, + showIcon: { type: new GraphQLNonNull(GraphQLBoolean) }, + }), +}); diff --git a/src/schema/mutation/duplicateApplication.mutation.ts b/src/schema/mutation/duplicateApplication.mutation.ts index 3203d1418..f62617849 100644 --- a/src/schema/mutation/duplicateApplication.mutation.ts +++ b/src/schema/mutation/duplicateApplication.mutation.ts @@ -88,6 +88,7 @@ export default { name: args.name, description: baseApplication.description, sideMenu: baseApplication.sideMenu, + topMenu: baseApplication.topMenu, hideMenu: baseApplication.hideMenu, status: status.pending, createdBy: user._id, diff --git a/src/schema/mutation/editApplication.mutation.ts b/src/schema/mutation/editApplication.mutation.ts index 7d339ff89..7a0836467 100644 --- a/src/schema/mutation/editApplication.mutation.ts +++ b/src/schema/mutation/editApplication.mutation.ts @@ -25,6 +25,7 @@ type EditApplicationArgs = { id: string | Types.ObjectId; description?: string; sideMenu?: boolean; + topMenu?: boolean; hideMenu?: boolean; name?: string; status?: StatusType; @@ -72,6 +73,7 @@ export default { id: { type: new GraphQLNonNull(GraphQLID) }, description: { type: GraphQLString }, sideMenu: { type: GraphQLBoolean }, + topMenu: { type: GraphQLBoolean }, hideMenu: { type: GraphQLBoolean }, name: { type: GraphQLString }, status: { type: StatusEnumType }, @@ -117,6 +119,7 @@ export default { if (!isNil(args.shortcut) && args.shortcut !== '') { await validateShortcut(args.id, args.shortcut); } + Object.assign( update, args.name && { name: args.name }, @@ -126,9 +129,11 @@ export default { args.settings && { settings: args.settings }, args.permissions && { permissions: args.permissions }, !isNil(args.sideMenu) && { sideMenu: args.sideMenu }, + !isNil(args.topMenu) && { topMenu: args.topMenu }, !isNil(args.hideMenu) && { hideMenu: args.hideMenu }, !isNil(args.shortcut) && { shortcut: args.shortcut } ); + application = await Application.findOneAndUpdate(filters, update, { new: true, }); diff --git a/src/schema/mutation/editPage.mutation.ts b/src/schema/mutation/editPage.mutation.ts index 96e44d114..558442f6d 100644 --- a/src/schema/mutation/editPage.mutation.ts +++ b/src/schema/mutation/editPage.mutation.ts @@ -17,6 +17,7 @@ import GraphQLJSON from 'graphql-type-json'; import { cloneDeep, has, isArray, isEmpty, isNil, omit } from 'lodash'; import { Types } from 'mongoose'; import { PageType } from '../types'; +import { NavBarSettingsInputType } from '@schema/inputs/navBarSettings.input'; /** Simple form permission change type */ type SimplePermissionChange = @@ -38,6 +39,10 @@ export type EditPageArgs = { id: string | Types.ObjectId; name?: string; showName?: boolean; + navBar?: { + showName?: boolean; + showIcon?: boolean; + }; permissions?: any; icon?: string; visible?: boolean; @@ -55,6 +60,7 @@ export default { id: { type: new GraphQLNonNull(GraphQLID) }, name: { type: GraphQLString }, showName: { type: GraphQLBoolean }, + navBar: { type: NavBarSettingsInputType }, icon: { type: GraphQLString }, permissions: { type: GraphQLJSON }, visible: { type: GraphQLBoolean }, @@ -91,8 +97,9 @@ export default { // Create update const update = { ...(args.name && { name: args.name }), - ...(args.icon && { icon: args.icon }), + ...(has(args, 'icon') && { icon: args.icon }), ...(has(args, 'showName') && { showName: args.showName }), + ...(args.navBar && { navBar: args.navBar }), } as any; // Update buttons if (args.buttons) { diff --git a/src/schema/mutation/editStep.mutation.ts b/src/schema/mutation/editStep.mutation.ts index feddb6f33..e2d080465 100644 --- a/src/schema/mutation/editStep.mutation.ts +++ b/src/schema/mutation/editStep.mutation.ts @@ -17,6 +17,7 @@ import GraphQLJSON from 'graphql-type-json'; import { cloneDeep, has, isArray, isEmpty, omit } from 'lodash'; import { Types } from 'mongoose'; import { StepType } from '../types'; +import { NavBarSettingsInputType } from '@schema/inputs/navBarSettings.input'; /** Simple form permission change type */ type SimplePermissionChange = @@ -38,6 +39,10 @@ type EditStepArgs = { id: string | Types.ObjectId; name?: string; showName?: boolean; + navBar?: { + showName?: boolean; + showIcon?: boolean; + }; type?: string; content?: string | Types.ObjectId; permissions?: any; @@ -55,6 +60,7 @@ export default { id: { type: new GraphQLNonNull(GraphQLID) }, name: { type: GraphQLString }, showName: { type: GraphQLBoolean }, + navBar: { type: NavBarSettingsInputType }, icon: { type: GraphQLString }, type: { type: GraphQLString }, content: { type: GraphQLID }, @@ -105,10 +111,11 @@ export default { // Create update const update = { ...(args.name && { name: args.name }), - ...(args.icon && { icon: args.icon }), + ...(has(args, 'icon') && { icon: args.icon }), ...(args.type && { type: args.type }), ...(args.content && { content: args.content }), ...(has(args, 'showName') && { showName: args.showName }), + ...(args.navBar && { navBar: args.navBar }), } as any; // Update buttons if (args.buttons) { diff --git a/src/schema/types/application.type.ts b/src/schema/types/application.type.ts index bb2297185..9d4aa87df 100644 --- a/src/schema/types/application.type.ts +++ b/src/schema/types/application.type.ts @@ -79,6 +79,16 @@ export const ApplicationType = new GraphQLObjectType({ } }, }, + topMenu: { + type: GraphQLBoolean, + resolve(parent) { + if (isNil(parent.topMenu)) { + return false; + } else { + return parent.topMenu; + } + }, + }, hideMenu: { type: GraphQLBoolean, resolve(parent) { diff --git a/src/schema/types/navBarSettings.type.ts b/src/schema/types/navBarSettings.type.ts new file mode 100644 index 000000000..b062c8d0c --- /dev/null +++ b/src/schema/types/navBarSettings.type.ts @@ -0,0 +1,17 @@ +import { GraphQLBoolean, GraphQLObjectType } from 'graphql'; + +/** + * GraphQL nav bar settings type definition + * Used in StepType and PageType + */ +export const NavBarSettingsType = new GraphQLObjectType({ + name: 'NavBarSettings', + fields: () => ({ + showName: { + type: GraphQLBoolean, + }, + showIcon: { + type: GraphQLBoolean, + }, + }), +}); diff --git a/src/schema/types/page.type.ts b/src/schema/types/page.type.ts index a79504b44..13f36d316 100644 --- a/src/schema/types/page.type.ts +++ b/src/schema/types/page.type.ts @@ -13,8 +13,9 @@ import { } from 'graphql'; import { GraphQLDate } from 'graphql-scalars'; import GraphQLJSON from 'graphql-type-json'; -import { isNil } from 'lodash'; +import { get, isNil } from 'lodash'; import { AccessType, ApplicationType } from '.'; +import { NavBarSettingsType } from './navBarSettings.type'; /** GraphQL page type type definition */ export const PageType = new GraphQLObjectType({ @@ -41,6 +42,17 @@ export const PageType = new GraphQLObjectType({ return isNil(parent.showName) ? defaultShowName : parent.showName; }, }, + navBar: { + type: NavBarSettingsType, + resolve(parent) { + if (parent.navBar) { + return { + showName: get(parent, 'navBar.showName') ?? true, + showIcon: get(parent, 'navBar.showIcon') ?? true, + }; + } + }, + }, createdAt: { type: GraphQLString }, modifiedAt: { type: GraphQLString }, type: { type: ContentEnumType }, diff --git a/src/schema/types/step.type.ts b/src/schema/types/step.type.ts index 63786b56a..edf4a7426 100644 --- a/src/schema/types/step.type.ts +++ b/src/schema/types/step.type.ts @@ -12,6 +12,8 @@ import { import GraphQLJSON from 'graphql-type-json'; import isNil from 'lodash/isNil'; import { AccessType, WorkflowType } from '.'; +import { NavBarSettingsType } from './navBarSettings.type'; +import { get } from 'lodash'; /** GraphQL Step type definition */ export const StepType = new GraphQLObjectType({ @@ -32,6 +34,17 @@ export const StepType = new GraphQLObjectType({ return isNil(parent.showName) ? defaultShowName : parent.showName; }, }, + navBar: { + type: NavBarSettingsType, + resolve(parent) { + if (parent.navBar) { + return { + showName: get(parent, 'navBar.showName') ?? true, + showIcon: get(parent, 'navBar.showIcon') ?? true, + }; + } + }, + }, createdAt: { type: GraphQLString }, modifiedAt: { type: GraphQLString }, type: { type: ContentEnumType },