Skip to content

Commit d01be0d

Browse files
author
lucas
committed
implement modal on click task by taskId
1 parent f563905 commit d01be0d

File tree

3 files changed

+169
-44
lines changed

3 files changed

+169
-44
lines changed

packages/drafts-realm/SaleHub/236608d5-d07a-4006-bb3a-bad875503f4f.json

+46-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,37 @@
33
"type": "card",
44
"attributes": {
55
"targetPage": "Lead Form",
6-
"scheduledTask": [],
7-
"convertedStatus": "Qualified",
8-
"isLeadFormConverted": true,
6+
"scheduledTask": [
7+
{
8+
"taskForm": {
9+
"taskId": "0",
10+
"subject": "task a",
11+
"dueDate": "2024-07-06",
12+
"comments": null,
13+
"isCompleted": false
14+
}
15+
},
16+
{
17+
"taskForm": {
18+
"taskId": "1",
19+
"subject": "task b",
20+
"dueDate": "2024-07-05",
21+
"comments": null,
22+
"isCompleted": false
23+
}
24+
},
25+
{
26+
"taskForm": {
27+
"taskId": "2",
28+
"subject": "task c",
29+
"dueDate": "2024-06-06",
30+
"comments": "testing",
31+
"isCompleted": false
32+
}
33+
}
34+
],
35+
"convertedStatus": "",
36+
"isLeadFormConverted": false,
937
"title": null,
1038
"description": null,
1139
"thumbnailURL": null
@@ -31,6 +59,21 @@
3159
"self": "../OpportunityForm/187ec912-522a-44dc-b17c-4fe19ac3066d"
3260
}
3361
},
62+
"scheduledTask.0.taskForm.relatedTo": {
63+
"links": {
64+
"self": "http://localhost:4201/drafts/CardDef/7298c9c6-2964-41a0-87f7-42127a16e12b"
65+
}
66+
},
67+
"scheduledTask.1.taskForm.relatedTo": {
68+
"links": {
69+
"self": "http://localhost:4201/drafts/CrmAccount/4802eeed-bec6-4d7a-8f05-6370866edd40"
70+
}
71+
},
72+
"scheduledTask.2.taskForm.relatedTo": {
73+
"links": {
74+
"self": null
75+
}
76+
},
3477
"recordOwner": {
3578
"links": {
3679
"self": "../MatrixUser/485ca453-b328-4e85-a761-b2fe7d145430"

packages/drafts-realm/sale-hub.gts

+116-41
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,14 @@ interface CategorySignature {
7777
name: string;
7878
}
7979

80-
// interface TaskSignature {
81-
// taskId: string | null;
82-
// subject: string | null;
83-
// dueDate: Date | any;
84-
// comments: string | null;
85-
// isCompleted: boolean;
86-
// }
87-
8880
interface GroupedTasksSignature {
89-
month: any;
81+
month: string | null;
9082
taskId: string | null;
9183
subject: string | null;
9284
dueDate: Date | any;
9385
comments: string | null;
9486
isCompleted: boolean;
87+
relatedTo: any;
9588
}
9689

9790
//*task-form
@@ -387,6 +380,23 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
387380
this.isTaskFormModalVisible = false;
388381
}
389382

383+
//task-form modal by Id
384+
@tracked selectedTask: GroupedTasksSignature | null = null;
385+
@tracked isTaskFormModalByIdVisible = false;
386+
387+
@action
388+
openTaskFormModaById(id: string) {
389+
this.isTaskFormModalByIdVisible = true;
390+
const filteredTask = this.tasks.find((task) => task.taskId == id);
391+
if (!filteredTask) return;
392+
this.selectedTask = filteredTask;
393+
}
394+
395+
@action
396+
closeTaskFormModalById() {
397+
this.isTaskFormModalByIdVisible = false;
398+
}
399+
390400
//auto bind form
391401
@action
392402
updateAccountForm() {
@@ -566,34 +576,43 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
566576

567577
//upcoming task list
568578
get tasks() {
569-
if (!this.args.model.scheduledTask) return [];
579+
const { scheduledTask } = this.args.model;
570580

571-
const mapTasks = this.args.model.scheduledTask.map((task) => {
581+
if (!scheduledTask) return [];
582+
583+
return scheduledTask.map((task) => {
584+
const { taskForm } = task;
572585
return {
573-
month: task.taskForm.dueDate
574-
? this.formatDueDate(task.taskForm.dueDate)
575-
: null,
576-
taskId: task.taskForm.taskId,
577-
subject: task.taskForm.subject,
578-
dueDate: task.taskForm.dueDate,
579-
comments: task.taskForm.comments,
580-
isCompleted: task.taskForm.isCompleted,
586+
month: taskForm.dueDate ? this.formatDueDate(taskForm.dueDate) : null,
587+
taskId: taskForm.taskId,
588+
subject: taskForm.subject,
589+
dueDate: taskForm.dueDate,
590+
comments: taskForm.comments,
591+
isCompleted: taskForm.isCompleted,
592+
relatedTo: taskForm.relatedTo,
581593
};
582594
});
583-
return mapTasks;
584595
}
585596

586597
get groupedTasks() {
587598
if (!this.tasks) return;
588599

589600
const groupedTasks: { [key: string]: GroupedTasksSignature[] } =
590-
this.tasks.reduce((acc: any, task: GroupedTasksSignature) => {
591-
if (!acc[task.month]) {
592-
acc[task.month] = [];
593-
}
594-
acc[task.month].push(task);
595-
return acc;
596-
}, {});
601+
this.tasks.reduce(
602+
(
603+
acc: { [key: string]: GroupedTasksSignature[] },
604+
task: GroupedTasksSignature,
605+
) => {
606+
if (!!task.month) {
607+
if (!acc[task.month]) {
608+
acc[task.month] = [];
609+
}
610+
acc[task.month].push(task);
611+
}
612+
return acc;
613+
},
614+
{},
615+
);
597616

598617
const sortedMonths = Object.keys(groupedTasks).sort((a, b) => {
599618
if (a === 'Upcoming') return -1;
@@ -811,6 +830,50 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
811830
</div>
812831
</CardContainer>
813832
</Modal>
833+
<Modal
834+
@size={{'large'}}
835+
@isOpen={{this.isTaskFormModalByIdVisible}}
836+
@onClose={{this.closeTaskFormModalById}}
837+
class='dialog'
838+
>
839+
<CardContainer class='container'>
840+
<IconButton
841+
@icon={{IconX}}
842+
@width='12'
843+
@height='12'
844+
{{on 'click' this.closeTaskFormModalById}}
845+
class='dialog-box__close'
846+
aria-label='close modal'
847+
/>
848+
<div class='dialog-box'>
849+
<CardContainer @displayBoundaries={{false}}>
850+
<FieldContainer @tag='label' @label='Task Id' @vertical={{false}}>
851+
{{this.selectedTask.taskId}}
852+
</FieldContainer>
853+
854+
<FieldContainer @tag='label' @label='Subject' @vertical={{false}}>
855+
{{this.selectedTask.subject}}
856+
</FieldContainer>
857+
858+
<FieldContainer @tag='label' @label='Comments' @vertical={{false}}>
859+
{{this.selectedTask.comments}}
860+
</FieldContainer>
861+
862+
<FieldContainer @tag='label' @label='Due Date' @vertical={{false}}>
863+
{{this.selectedTask.dueDate}}
864+
</FieldContainer>
865+
866+
<FieldContainer
867+
@tag='label'
868+
@label='Related To'
869+
@vertical={{false}}
870+
>
871+
{{this.selectedTask.relatedTo.accountName}}
872+
</FieldContainer>
873+
</CardContainer>
874+
</div>
875+
</CardContainer>
876+
</Modal>
814877

815878
<div class='sale-hub'>
816879
<section>
@@ -892,9 +955,6 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
892955

893956
<section class='activity-panel'>
894957
<div class='activity-button-group'>
895-
<button class='button'>
896-
New Event
897-
</button>
898958
<button class='button' {{on 'click' this.openTaskFormModal}}>
899959
New Task
900960
</button>
@@ -912,19 +972,29 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
912972
<div>
913973
{{#each tasks as |task|}}
914974
<div class='checkbox-card'>
915-
<label class='checkbox-label'>
916-
<input
917-
type='checkbox'
918-
checked={{task.isCompleted}}
975+
<div>
976+
<label>
977+
<input
978+
type='checkbox'
979+
checked={{task.isCompleted}}
980+
{{on
981+
'change'
982+
(fn this.toggleOnCheckTask task.taskId)
983+
}}
984+
/>
985+
<span
986+
class={{if task.isCompleted 'line-through'}}
987+
>You had an event/a task -
988+
</span>
989+
</label>
990+
<span
991+
class='highlight-link'
919992
{{on
920-
'change'
921-
(fn this.toggleOnCheckTask task.taskId)
993+
'click'
994+
(fn this.openTaskFormModaById task.taskId)
922995
}}
923-
/>
924-
<span class={{if task.isCompleted 'line-through'}}>You
925-
had an event/a task -
926-
{{task.subject}}</span>
927-
</label>
996+
>{{task.subject}}</span>
997+
</div>
928998

929999
<span class='dueDate'>{{this.formatDay
9301000
task.dueDate
@@ -1142,6 +1212,11 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
11421212
justify-content: end;
11431213
gap: var(--boxel-sp-xs);
11441214
}
1215+
.highlight-link {
1216+
text-decoration: underline;
1217+
font-weight: bold;
1218+
cursor: pointer;
1219+
}
11451220
</style>
11461221
</template>
11471222
}

packages/drafts-realm/task-form.gts

+7
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ class EditSecForTaskForm extends Component<typeof TaskForm> {
153153

154154
<template>
155155
<CardContainer @displayBoundaries={{false}} class='container'>
156+
<FieldContainer @tag='label' @label='Task Id' @vertical={{true}}>
157+
<@fields.taskId />
158+
</FieldContainer>
159+
156160
<FieldContainer @tag='label' @label='Subject' @vertical={{true}}>
157161
<BoxelSelect
158162
@searchEnabled={{true}}
@@ -196,6 +200,9 @@ class EditSecForTaskForm extends Component<typeof TaskForm> {
196200

197201
export class TaskForm extends CardDef {
198202
static displayName = 'Task Form';
203+
@field taskId = contains(StringField, {
204+
description: `Task Id`,
205+
});
199206
@field subject = contains(StringField, {
200207
description: `Subject`,
201208
});

0 commit comments

Comments
 (0)