Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/models/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,6 +76,7 @@ const applicationSchema = new Schema<Application>(
settings: mongoose.Schema.Types.Mixed,
description: String,
sideMenu: Boolean,
topMenu: Boolean,
hideMenu: Boolean,
permissions: {
canSee: [
Expand Down
14 changes: 14 additions & 0 deletions src/models/page.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,6 +68,16 @@ const pageSchema = new Schema<Page>(
name: String,
icon: String,
showName: Boolean,
navBar: {
showName: {
type: Boolean,
default: true,
},
showIcon: {
type: Boolean,
default: true,
},
},
type: {
type: String,
enum: Object.values(contentType),
Expand Down
14 changes: 14 additions & 0 deletions src/models/step.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +39,16 @@ const stepSchema = new Schema<Step>(
name: String,
icon: String,
showName: Boolean,
navBar: {
showName: {
type: Boolean,
default: true,
},
showIcon: {
type: Boolean,
default: true,
},
},
type: {
type: String,
enum: Object.values(contentType),
Expand Down
16 changes: 16 additions & 0 deletions src/schema/inputs/navBarSettings.input.ts
Original file line number Diff line number Diff line change
@@ -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) },
}),
});
1 change: 1 addition & 0 deletions src/schema/mutation/duplicateApplication.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/schema/mutation/editApplication.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type EditApplicationArgs = {
id: string | Types.ObjectId;
description?: string;
sideMenu?: boolean;
topMenu?: boolean;
hideMenu?: boolean;
name?: string;
status?: StatusType;
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand All @@ -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,
});
Expand Down
9 changes: 8 additions & 1 deletion src/schema/mutation/editPage.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand All @@ -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 },
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion src/schema/mutation/editStep.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand All @@ -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 },
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions src/schema/types/application.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 17 additions & 0 deletions src/schema/types/navBarSettings.type.ts
Original file line number Diff line number Diff line change
@@ -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,
},
}),
});
14 changes: 13 additions & 1 deletion src/schema/types/page.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 },
Expand Down
13 changes: 13 additions & 0 deletions src/schema/types/step.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 },
Expand Down