Skip to content

Commit 0e711c6

Browse files
authored
Update Action Item & Category Resolvers (#2508)
* Add allotedHours in ActionItems & Add search/sort filters for action items & categories * add tests * update resolver * add test for getSort
1 parent 95597d7 commit 0e711c6

Some content is hidden

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

45 files changed

+379
-668
lines changed

schema.graphql

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ directive @role(requires: UserType) on FIELD_DEFINITION
55
type ActionItem {
66
_id: ID!
77
actionItemCategory: ActionItemCategory
8+
allotedHours: Float
89
assignee: User
910
assigner: User
1011
assignmentDate: Date!
@@ -29,16 +30,24 @@ type ActionItemCategory {
2930
updatedAt: Date!
3031
}
3132

33+
input ActionItemCategoryWhereInput {
34+
is_disabled: Boolean
35+
name_contains: String
36+
}
37+
3238
input ActionItemWhereInput {
3339
actionItemCategory_id: ID
40+
assigneeName: String
41+
categoryName: String
3442
event_id: ID
35-
is_active: Boolean
3643
is_completed: Boolean
3744
}
3845

3946
enum ActionItemsOrderByInput {
4047
createdAt_ASC
4148
createdAt_DESC
49+
dueDate_ASC
50+
dueDate_DESC
4251
}
4352

4453
type Address {
@@ -269,6 +278,7 @@ interface ConnectionPageInfo {
269278
scalar CountryCode
270279

271280
input CreateActionItemInput {
281+
allotedHours: Float
272282
assigneeId: ID!
273283
dueDate: Date
274284
eventId: ID
@@ -1080,7 +1090,7 @@ type Mutation {
10801090
checkIn(data: CheckInCheckOutInput!): CheckIn!
10811091
checkOut(data: CheckInCheckOutInput!): CheckOut!
10821092
createActionItem(actionItemCategoryId: ID!, data: CreateActionItemInput!): ActionItem!
1083-
createActionItemCategory(name: String!, organizationId: ID!): ActionItemCategory!
1093+
createActionItemCategory(isDisabled: Boolean!, name: String!, organizationId: ID!): ActionItemCategory!
10841094
createAdmin(data: UserAndOrganizationInput!): CreateAdminPayload!
10851095
createAdvertisement(input: CreateAdvertisementInput!): CreateAdvertisementPayload
10861096
createAgendaCategory(input: CreateAgendaCategoryInput!): AgendaCategory!
@@ -1476,9 +1486,9 @@ type PostsConnection {
14761486
}
14771487

14781488
type Query {
1479-
actionItemCategoriesByOrganization(organizationId: ID!): [ActionItemCategory]
1489+
actionItemCategoriesByOrganization(orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemCategoryWhereInput): [ActionItemCategory]
14801490
actionItemsByEvent(eventId: ID!): [ActionItem]
1481-
actionItemsByOrganization(orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemWhereInput): [ActionItem]
1491+
actionItemsByOrganization(eventId: ID, orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemWhereInput): [ActionItem]
14821492
adminPlugin(orgId: ID!): [Plugin]
14831493
advertisementsConnection(after: String, before: String, first: PositiveInt, last: PositiveInt): AdvertisementsConnection
14841494
agendaCategory(id: ID!): AgendaCategory!
@@ -1661,6 +1671,7 @@ input UpdateActionItemCategoryInput {
16611671
}
16621672

16631673
input UpdateActionItemInput {
1674+
allotedHours: Float
16641675
assigneeId: ID
16651676
completionDate: Date
16661677
dueDate: Date

src/models/ActionItem.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,63 @@ import type { InterfaceUser } from "./User";
44
import type { InterfaceEvent } from "./Event";
55
import type { InterfaceActionItemCategory } from "./ActionItemCategory";
66
import { MILLISECONDS_IN_A_WEEK } from "../constants";
7+
import type { InterfaceOrganization } from "./Organization";
78

89
/**
910
* Interface representing a database document for ActionItem in MongoDB.
1011
*/
1112
export interface InterfaceActionItem {
1213
_id: Types.ObjectId;
13-
assigneeId: PopulatedDoc<InterfaceUser & Document>;
14-
assignerId: PopulatedDoc<InterfaceUser & Document>;
15-
actionItemCategoryId: PopulatedDoc<InterfaceActionItemCategory & Document>;
14+
assignee: PopulatedDoc<InterfaceUser & Document>;
15+
assigner: PopulatedDoc<InterfaceUser & Document>;
16+
actionItemCategory: PopulatedDoc<
17+
InterfaceActionItemCategory & Document
18+
> | null;
1619
preCompletionNotes: string;
1720
postCompletionNotes: string;
1821
assignmentDate: Date;
1922
dueDate: Date;
2023
completionDate: Date;
2124
isCompleted: boolean;
22-
eventId: PopulatedDoc<InterfaceEvent & Document>;
23-
creatorId: PopulatedDoc<InterfaceUser & Document>;
25+
allotedHours: number | null;
26+
organization: PopulatedDoc<InterfaceOrganization & Document>;
27+
event: PopulatedDoc<InterfaceEvent & Document>;
28+
creator: PopulatedDoc<InterfaceUser & Document>;
2429
createdAt: Date;
2530
updatedAt: Date;
2631
}
2732

2833
/**
2934
* Defines the schema for the ActionItem document.
30-
* @param assigneeId - User to whom the ActionItem is assigned.
31-
* @param assignerId - User who assigned the ActionItem.
32-
* @param actionItemCategoryId - ActionItemCategory to which the ActionItem belongs.
35+
* @param assignee - User to whom the ActionItem is assigned.
36+
* @param assigner - User who assigned the ActionItem.
37+
* @param actionItemCategory - ActionItemCategory to which the ActionItem belongs.
3338
* @param preCompletionNotes - Notes recorded before completion.
3439
* @param postCompletionNotes - Notes recorded after completion.
3540
* @param assignmentDate - Date when the ActionItem was assigned.
3641
* @param dueDate - Due date for the ActionItem.
3742
* @param completionDate - Date when the ActionItem was completed.
3843
* @param isCompleted - Flag indicating if the ActionItem is completed.
39-
* @param eventId - Optional: Event to which the ActionItem is related.
40-
* @param creatorId - User who created the ActionItem.
44+
* @param allotedHours - Optional: Number of hours alloted for the ActionItem.
45+
* @param event - Optional: Event to which the ActionItem is related.
46+
* @param organization - Organization to which the ActionItem belongs.
47+
* @param creator - User who created the ActionItem.
4148
* @param createdAt - Timestamp when the ActionItem was created.
4249
* @param updatedAt - Timestamp when the ActionItem was last updated.
4350
*/
4451
const actionItemSchema = new Schema(
4552
{
46-
assigneeId: {
53+
assignee: {
4754
type: Schema.Types.ObjectId,
4855
ref: "User",
4956
required: true,
5057
},
51-
assignerId: {
58+
assigner: {
5259
type: Schema.Types.ObjectId,
5360
ref: "User",
5461
required: true,
5562
},
56-
actionItemCategoryId: {
63+
actionItemCategory: {
5764
type: Schema.Types.ObjectId,
5865
ref: "ActionItemCategory",
5966
required: true,
@@ -84,11 +91,19 @@ const actionItemSchema = new Schema(
8491
required: true,
8592
default: false,
8693
},
87-
eventId: {
94+
allotedHours: {
95+
type: Number,
96+
},
97+
organization: {
98+
type: Schema.Types.ObjectId,
99+
ref: "Organization",
100+
required: true,
101+
},
102+
event: {
88103
type: Schema.Types.ObjectId,
89104
ref: "Event",
90105
},
91-
creatorId: {
106+
creator: {
92107
type: Schema.Types.ObjectId,
93108
ref: "User",
94109
required: true,

src/resolvers/ActionItem/actionItemCategory.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/resolvers/ActionItem/assignee.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/resolvers/ActionItem/assigner.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/resolvers/ActionItem/creator.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/resolvers/ActionItem/event.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/resolvers/ActionItem/index.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { ActionItemCategoryResolvers } from "../../types/generatedGraphQLTypes";
2-
import { organization } from "./organization";
32
import { creator } from "./creator";
43

54
export const ActionItemCategory: ActionItemCategoryResolvers = {
6-
organization,
75
creator,
86
};

src/resolvers/ActionItemCategory/organization.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/resolvers/Mutation/createActionItem.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ export const createActionItem: MutationResolvers["createActionItem"] = async (
217217

218218
// Creates and returns the new action item.
219219
const createActionItem = await ActionItem.create({
220-
assigneeId: args.data.assigneeId,
221-
assignerId: context.userId,
222-
actionItemCategoryId: args.actionItemCategoryId,
220+
assignee: args.data.assigneeId,
221+
assigner: context.userId,
222+
actionItemCategory: args.actionItemCategoryId,
223223
preCompletionNotes: args.data.preCompletionNotes,
224+
allotedHours: args.data.allotedHours,
224225
dueDate: args.data.dueDate,
225-
eventId: args.data.eventId,
226-
creatorId: context.userId,
226+
event: args.data.eventId,
227+
organization: actionItemCategory.organizationId,
228+
creator: context.userId,
227229
});
228230

229231
return createActionItem.toObject();

src/resolvers/Mutation/createActionItemCategory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export const createActionItemCategory: MutationResolvers["createActionItemCatego
111111
// Creates new actionItemCategory.
112112
const createdActionItemCategory = await ActionItemCategory.create({
113113
name: args.name,
114+
isDisabled: args.isDisabled,
114115
organizationId: args.organizationId,
115116
creatorId: context.userId,
116117
});

0 commit comments

Comments
 (0)