Skip to content

Commit 49ed00d

Browse files
authored
Cs 7561 account upcoming task embedded format component (#2066)
* create card embedded format with responsive view * update instances for CRMTask * query tasks on CRM Account Isolated * fix lint * adjust icon * fix lint
1 parent e064ab8 commit 49ed00d

6 files changed

+289
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"data": {
3+
"type": "card",
4+
"attributes": {
5+
"status": {
6+
"index": 1,
7+
"label": "In Progress",
8+
"color": "#FFB74D",
9+
"completed": false
10+
},
11+
"dateRange": {
12+
"start": null,
13+
"end": null
14+
},
15+
"priority": {
16+
"index": null,
17+
"label": null
18+
},
19+
"name": "Call on discussion about next step",
20+
"details": null,
21+
"description": null,
22+
"thumbnailURL": null
23+
},
24+
"relationships": {
25+
"crmApp": {
26+
"links": {
27+
"self": null
28+
}
29+
},
30+
"subtasks": {
31+
"links": {
32+
"self": null
33+
}
34+
},
35+
"assignee": {
36+
"links": {
37+
"self": null
38+
}
39+
},
40+
"contact": {
41+
"links": {
42+
"self": null
43+
}
44+
},
45+
"account": {
46+
"links": {
47+
"self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53"
48+
}
49+
},
50+
"deal": {
51+
"links": {
52+
"self": null
53+
}
54+
},
55+
"tags": {
56+
"links": {
57+
"self": null
58+
}
59+
}
60+
},
61+
"meta": {
62+
"adoptsFrom": {
63+
"module": "../crm/task",
64+
"name": "CRMTask"
65+
}
66+
}
67+
}
68+
}

packages/experiments-realm/CRMTask/27c5519e-4b58-4e1f-a158-27074d46c782.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"type": "card",
44
"attributes": {
55
"status": {
6-
"index": 0,
7-
"label": "Not Started",
8-
"color": null,
9-
"completed": false
6+
"index": 2,
7+
"label": "Done",
8+
"color": "#66BB6A",
9+
"completed": true
1010
},
1111
"dateRange": {
12-
"start": null,
13-
"end": null
12+
"start": "2025-01-22",
13+
"end": "2025-02-04"
1414
},
1515
"priority": {
1616
"index": 2,
@@ -44,7 +44,7 @@
4444
},
4545
"account": {
4646
"links": {
47-
"self": null
47+
"self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53"
4848
}
4949
},
5050
"deal": {

packages/experiments-realm/CRMTask/4139bf52-03bf-41a9-a424-f5598d4feb27.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
},
4545
"account": {
4646
"links": {
47-
"self": null
47+
"self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53"
4848
}
4949
},
5050
"deal": {
5151
"links": {
5252
"self": null
5353
}
5454
},
55-
"tags": {
55+
"tags.0": {
5656
"links": {
57-
"self": null
57+
"self": "../Tag/8a14f671-4daf-4195-aca5-85dc143d15b8"
5858
}
5959
}
6060
},

packages/experiments-realm/CRMTask/bfefcf0b-3b24-4bfc-818a-54317e6673e1.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"type": "card",
44
"attributes": {
55
"status": {
6-
"index": 1,
7-
"label": "In Progress",
8-
"color": null,
6+
"index": 0,
7+
"label": "Not Started",
8+
"color": "#B0BEC5",
99
"completed": false
1010
},
1111
"dateRange": {
@@ -44,7 +44,7 @@
4444
},
4545
"account": {
4646
"links": {
47-
"self": null
47+
"self": "../Account/77976251-6bc8-4a8c-972f-f9d588e8434d"
4848
}
4949
},
5050
"deal": {

packages/experiments-realm/crm/account.gts

+44-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
contains,
55
realmURL,
66
} from 'https://cardstack.com/base/card-api';
7-
import { Component } from 'https://cardstack.com/base/card-api';
7+
import { Component, BaseDef } from 'https://cardstack.com/base/card-api';
88
import GlimmerComponent from '@glimmer/component';
99
import {
1010
field,
@@ -243,6 +243,18 @@ class IsolatedTemplate extends Component<typeof Account> {
243243
this._createNewTask.perform();
244244
};
245245

246+
get activeTasksCount() {
247+
const tasks = this.activeTasks;
248+
if (!tasks || tasks.isLoading) {
249+
return 0;
250+
}
251+
return tasks.instances?.length ?? 0;
252+
}
253+
254+
get hasActiveTasks() {
255+
return this.activeTasksCount > 0;
256+
}
257+
246258
get activeDealsCount() {
247259
const deals = this.deals;
248260
if (!deals || deals.isLoading) {
@@ -564,7 +576,19 @@ class IsolatedTemplate extends Component<typeof Account> {
564576
</BoxelButton>
565577
</:icon>
566578
<:content>
567-
{{! UI for upcoming tasks }}
579+
{{#if this.activeTasks.isLoading}}
580+
<div class='loading-skeleton'>Loading...</div>
581+
{{else}}
582+
{{#if this.hasActiveTasks}}
583+
{{#each this.activeTasks.instances as |task|}}
584+
{{#let (getComponent task) as |Component|}}
585+
<Component @format='embedded' @displayContainer={{false}} />
586+
{{/let}}
587+
{{/each}}
588+
{{else}}
589+
<p class='description'>No Upcoming Tasks</p>
590+
{{/if}}
591+
{{/if}}
568592
</:content>
569593
</SummaryCard>
570594
</:tasks>
@@ -642,9 +666,14 @@ class IsolatedTemplate extends Component<typeof Account> {
642666
.activities-summary-card,
643667
.tasks-summary-card {
644668
--summary-card-padding: var(--boxel-sp-xl) var(--boxel-sp);
669+
--summary-card-gap: var(--boxel-sp-lg);
645670
container-type: inline-size;
646671
container-name: activities-summary-card;
647672
}
673+
.tasks-summary-card :where(.task-card) {
674+
--task-card-padding: var(--boxel-sp) 0;
675+
border-top: 1px solid var(--boxel-200);
676+
}
648677
.activity-title {
649678
font: 600 var(--boxel-font-med);
650679
letter-spacing: var(--boxel-lsp-xxs);
@@ -669,6 +698,15 @@ class IsolatedTemplate extends Component<typeof Account> {
669698
--profile-avatar-icon-border: 0px;
670699
flex-shrink: 0;
671700
}
701+
.loading-skeleton {
702+
height: 60px;
703+
width: 100%;
704+
background-color: var(--boxel-100);
705+
border-radius: var(--boxel-border-radius-sm);
706+
display: flex;
707+
align-items: center;
708+
justify-content: center;
709+
}
672710
673711
@container activities-summary-card (max-width: 447px) {
674712
.activity-button-mobile {
@@ -922,3 +960,7 @@ class AccountPageLayout extends GlimmerComponent<AccountPageLayoutArgs> {
922960
</style>
923961
</template>
924962
}
963+
964+
function getComponent(cardOrField: BaseDef) {
965+
return cardOrField.constructor.getComponent(cardOrField);
966+
}

0 commit comments

Comments
 (0)