diff --git a/packages/experiments-realm/Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7.json b/packages/experiments-realm/Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7.json index 78917998eb..30d6e08f7e 100644 --- a/packages/experiments-realm/Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7.json +++ b/packages/experiments-realm/Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7.json @@ -46,7 +46,7 @@ }, "primaryContact": { "links": { - "self": "../Customer/dddaeabf-1e95-480c-b158-0873e31fc66c" + "self": "../Lead/4e70a791-dd4e-4b39-99a1-bb8070392437" } }, "contacts": { diff --git a/packages/experiments-realm/CRMTask/0b1acd22-9ff8-4ea0-b6c3-1c00243057b2.json b/packages/experiments-realm/CRMTask/0b1acd22-9ff8-4ea0-b6c3-1c00243057b2.json new file mode 100644 index 0000000000..805ade71a6 --- /dev/null +++ b/packages/experiments-realm/CRMTask/0b1acd22-9ff8-4ea0-b6c3-1c00243057b2.json @@ -0,0 +1,68 @@ +{ + "data": { + "type": "card", + "attributes": { + "status": { + "index": 1, + "label": "In Progress", + "color": "#FFB74D", + "completed": false + }, + "dateRange": { + "start": null, + "end": null + }, + "priority": { + "index": null, + "label": null + }, + "name": "Call on discussion about next step", + "details": null, + "description": null, + "thumbnailURL": null + }, + "relationships": { + "crmApp": { + "links": { + "self": null + } + }, + "subtasks": { + "links": { + "self": null + } + }, + "assignee": { + "links": { + "self": null + } + }, + "contact": { + "links": { + "self": null + } + }, + "account": { + "links": { + "self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53" + } + }, + "deal": { + "links": { + "self": null + } + }, + "tags": { + "links": { + "self": null + } + } + }, + "meta": { + "adoptsFrom": { + "module": "../crm/task", + "name": "CRMTask" + } + } + } +} \ No newline at end of file diff --git a/packages/experiments-realm/CRMTask/27c5519e-4b58-4e1f-a158-27074d46c782.json b/packages/experiments-realm/CRMTask/27c5519e-4b58-4e1f-a158-27074d46c782.json index 8779cf92c6..2823d823b9 100644 --- a/packages/experiments-realm/CRMTask/27c5519e-4b58-4e1f-a158-27074d46c782.json +++ b/packages/experiments-realm/CRMTask/27c5519e-4b58-4e1f-a158-27074d46c782.json @@ -3,14 +3,14 @@ "type": "card", "attributes": { "status": { - "index": 0, - "label": "Not Started", - "color": null, - "completed": false + "index": 2, + "label": "Done", + "color": "#66BB6A", + "completed": true }, "dateRange": { - "start": null, - "end": null + "start": "2025-01-22", + "end": "2025-02-04" }, "priority": { "index": 2, @@ -44,7 +44,7 @@ }, "account": { "links": { - "self": null + "self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53" } }, "deal": { diff --git a/packages/experiments-realm/CRMTask/4139bf52-03bf-41a9-a424-f5598d4feb27.json b/packages/experiments-realm/CRMTask/4139bf52-03bf-41a9-a424-f5598d4feb27.json index f1583c5fe6..a0c1824d26 100644 --- a/packages/experiments-realm/CRMTask/4139bf52-03bf-41a9-a424-f5598d4feb27.json +++ b/packages/experiments-realm/CRMTask/4139bf52-03bf-41a9-a424-f5598d4feb27.json @@ -44,7 +44,7 @@ }, "account": { "links": { - "self": null + "self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53" } }, "deal": { @@ -52,9 +52,9 @@ "self": null } }, - "tags": { + "tags.0": { "links": { - "self": null + "self": "../Tag/8a14f671-4daf-4195-aca5-85dc143d15b8" } } }, diff --git a/packages/experiments-realm/CRMTask/bfefcf0b-3b24-4bfc-818a-54317e6673e1.json b/packages/experiments-realm/CRMTask/bfefcf0b-3b24-4bfc-818a-54317e6673e1.json index aa0d810e38..2d9c24201a 100644 --- a/packages/experiments-realm/CRMTask/bfefcf0b-3b24-4bfc-818a-54317e6673e1.json +++ b/packages/experiments-realm/CRMTask/bfefcf0b-3b24-4bfc-818a-54317e6673e1.json @@ -3,9 +3,9 @@ "type": "card", "attributes": { "status": { - "index": 1, - "label": "In Progress", - "color": null, + "index": 0, + "label": "Not Started", + "color": "#B0BEC5", "completed": false }, "dateRange": { @@ -44,7 +44,7 @@ }, "account": { "links": { - "self": null + "self": "../Account/77976251-6bc8-4a8c-972f-f9d588e8434d" } }, "deal": { diff --git a/packages/experiments-realm/Contact/461ab2c9-6787-4719-b7bb-d6fdd40414a8.json b/packages/experiments-realm/Contact/461ab2c9-6787-4719-b7bb-d6fdd40414a8.json deleted file mode 100644 index 4f14f19a35..0000000000 --- a/packages/experiments-realm/Contact/461ab2c9-6787-4719-b7bb-d6fdd40414a8.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "data": { - "type": "card", - "attributes": { - "firstName": "Andy", - "lastName": null, - "position": "Sales Manager", - "department": "Sales", - "primaryEmail": null, - "secondaryEmail": null, - "phoneMobile": { - "phoneNumber": { - "number": null, - "countryCode": null - }, - "type": { - "index": null, - "label": null, - "color": null, - "colorScheme": { - "foregroundColor": null, - "backgroundColor": null - } - } - }, - "phoneOffice": { - "phoneNumber": { - "number": null, - "countryCode": null - }, - "type": { - "index": null, - "label": null, - "color": null, - "colorScheme": { - "foregroundColor": null, - "backgroundColor": null - } - } - }, - "socialLinks": [], - "statusTag": { - "lightColor": null, - "darkColor": null, - "index": null, - "label": null, - "color": null, - "colorScheme": { - "foregroundColor": null, - "backgroundColor": null - } - }, - "description": null, - "thumbnailURL": null - }, - "relationships": { - "company": { - "links": { - "self": null - } - } - }, - "meta": { - "adoptsFrom": { - "module": "../crm/contact", - "name": "Contact" - } - } - } -} \ No newline at end of file diff --git a/packages/experiments-realm/Lead/1dbcc3e8-fe3c-4c4a-ba66-ff7d637a7358.json b/packages/experiments-realm/Lead/1dbcc3e8-fe3c-4c4a-ba66-ff7d637a7358.json index e52ca290ce..f8ece2ce3c 100644 --- a/packages/experiments-realm/Lead/1dbcc3e8-fe3c-4c4a-ba66-ff7d637a7358.json +++ b/packages/experiments-realm/Lead/1dbcc3e8-fe3c-4c4a-ba66-ff7d637a7358.json @@ -9,16 +9,34 @@ "primaryEmail": "ethan@gmail.com", "secondaryEmail": "ethanSmith@gmail.com", "phoneMobile": { - "type": "mobile", - "country": 1, - "area": 510, - "number": 123456 + "phoneNumber": { + "number": "2065553411", + "countryCode": "1" + }, + "type": { + "index": 0, + "label": "Mobile", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } + } }, "phoneOffice": { - "type": "office", - "country": 1, - "area": 510, - "number": 2442322 + "phoneNumber": { + "number": "2065551123", + "countryCode": null + }, + "type": { + "index": 2, + "label": "Work", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } + } }, "socialLinks": [ { @@ -47,4 +65,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/experiments-realm/Lead/4e70a791-dd4e-4b39-99a1-bb8070392437.json b/packages/experiments-realm/Lead/4e70a791-dd4e-4b39-99a1-bb8070392437.json index e908433be9..d51f8bd864 100644 --- a/packages/experiments-realm/Lead/4e70a791-dd4e-4b39-99a1-bb8070392437.json +++ b/packages/experiments-realm/Lead/4e70a791-dd4e-4b39-99a1-bb8070392437.json @@ -10,22 +10,32 @@ "secondaryEmail": null, "phoneMobile": { "phoneNumber": { - "number": "2065551111", + "number": "2065521411", "countryCode": "1" }, "type": { "index": 0, - "label": "Mobile" + "label": "Mobile", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } } }, "phoneOffice": { "phoneNumber": { - "number": null, + "number": "2062851123", "countryCode": null }, "type": { - "index": null, - "label": null + "index": 2, + "label": "Work", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } } }, "socialLinks": [ @@ -38,17 +48,6 @@ "value": "@johnsmith" } ], - "statusTag": { - "lightColor": "#93C5FD", - "darkColor": "#3B82F6", - "index": null, - "label": "Lead", - "color": null, - "colorScheme": { - "foregroundColor": null, - "backgroundColor": null - } - }, "description": "Showed interest through website contact form", "thumbnailURL": "https://images.pexels.com/photos/2379004/pexels-photo-2379004.jpeg" }, @@ -66,4 +65,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/experiments-realm/Lead/9d7b2f20-c7da-4ddc-8e77-b75d88c97b48.json b/packages/experiments-realm/Lead/9d7b2f20-c7da-4ddc-8e77-b75d88c97b48.json index be6cc6b157..8c9ad9f916 100644 --- a/packages/experiments-realm/Lead/9d7b2f20-c7da-4ddc-8e77-b75d88c97b48.json +++ b/packages/experiments-realm/Lead/9d7b2f20-c7da-4ddc-8e77-b75d88c97b48.json @@ -9,16 +9,34 @@ "primaryEmail": "liam@gmail.com", "secondaryEmail": "liamOConnor@gmail.com", "phoneMobile": { - "type": "mobile", - "country": 1, - "area": 510, - "number": 2323423 + "phoneNumber": { + "number": "2165582411", + "countryCode": "1" + }, + "type": { + "index": 0, + "label": "Mobile", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } + } }, "phoneOffice": { - "type": "office", - "country": 1, - "area": 510, - "number": 1231232 + "phoneNumber": { + "number": "2165551123", + "countryCode": null + }, + "type": { + "index": 2, + "label": "Work", + "color": null, + "colorScheme": { + "foregroundColor": null, + "backgroundColor": null + } + } }, "socialLinks": [ { diff --git a/packages/experiments-realm/components/avatar-group.gts b/packages/experiments-realm/components/avatar-group.gts index fdd3deee5e..6fa7f9ff70 100644 --- a/packages/experiments-realm/components/avatar-group.gts +++ b/packages/experiments-realm/components/avatar-group.gts @@ -58,7 +58,7 @@ export default class AvatarGroup extends GlimmerComponent text-overflow: ellipsis; overflow: hidden; margin: 0; - font-size: var(--boxel-font-size-med); + font-size: var(--boxel-font-size); font-weight: 600; letter-spacing: var(--boxel-lsp-sm); } diff --git a/packages/experiments-realm/crm/account.gts b/packages/experiments-realm/crm/account.gts index b13dcdad7d..2feaf29641 100644 --- a/packages/experiments-realm/crm/account.gts +++ b/packages/experiments-realm/crm/account.gts @@ -4,7 +4,7 @@ import { contains, realmURL, } from 'https://cardstack.com/base/card-api'; -import { Component } from 'https://cardstack.com/base/card-api'; +import { Component, BaseDef } from 'https://cardstack.com/base/card-api'; import GlimmerComponent from '@glimmer/component'; import { field, @@ -38,6 +38,15 @@ import { Pill } from '@cardstack/boxel-ui/components'; import { Query } from '@cardstack/runtime-common/query'; import { getCards } from '@cardstack/runtime-common'; import { Deal } from './deal'; +import type { LooseSingleCardDocument } from '@cardstack/runtime-common'; +import { restartableTask } from 'ember-concurrency'; +import { on } from '@ember/modifier'; +import { not } from '@cardstack/boxel-ui/helpers'; + +const taskSource = { + module: new URL('./task', import.meta.url).href, + name: 'CRMTask', +}; export const urgencyTagValues = [ { @@ -139,6 +148,10 @@ class IsolatedTemplate extends Component { return [this.realmURL?.href]; } + get accountId() { + return this.args.model.id; + } + // Query All Active Deal that linked to current Account get dealQuery(): Query { return { @@ -155,10 +168,93 @@ class IsolatedTemplate extends Component { }; } + get activeTasksQuery(): Query { + let everyArr = []; + if (this.accountId) { + everyArr.push({ + eq: { + 'account.id': this.accountId, + }, + }); + } + return { + filter: { + on: taskSource, + every: everyArr, + }, + }; + } + deals = getCards(this.dealQuery, this.realmHrefs, { isLive: true, }); + activeTasks = getCards(this.activeTasksQuery, this.realmHrefs, { + isLive: true, + }); + + private _createNewTask = restartableTask(async () => { + let doc: LooseSingleCardDocument = { + data: { + type: 'card', + attributes: { + name: null, + details: null, + status: { + index: 1, + label: 'In Progress', + }, + priority: { + index: null, + label: null, + }, + description: null, + thumbnailURL: null, + }, + relationships: { + assignee: { + links: { + self: null, + }, + }, + account: { + links: { + self: this.accountId ?? null, + }, + }, + }, + meta: { + adoptsFrom: taskSource, + }, + }, + }; + + await this.args.context?.actions?.createCard?.( + taskSource, + new URL(taskSource.module), + { + realmURL: this.realmURL, + doc, + }, + ); + }); + + createNewTask = () => { + this._createNewTask.perform(); + }; + + get activeTasksCount() { + const tasks = this.activeTasks; + if (!tasks || tasks.isLoading) { + return 0; + } + return tasks.instances?.length ?? 0; + } + + get hasActiveTasks() { + return this.activeTasksCount > 0; + } + get activeDealsCount() { const deals = this.deals; if (!deals || deals.isLoading) { @@ -445,6 +541,57 @@ class IsolatedTemplate extends Component { + + <:tasks> + + <:title> +

Upcoming Tasks

+ + <:icon> + + {{#if (not this._createNewTask.isRunning)}} + + {{/if}} + + + {{#if (not this._createNewTask.isRunning)}} + + {{/if}} + New Task + + + <:content> + {{#if this.activeTasks.isLoading}} +
Loading...
+ {{else}} + {{#if this.hasActiveTasks}} + {{#each this.activeTasks.instances as |task|}} + {{#let (getComponent task) as |Component|}} + + {{/let}} + {{/each}} + {{else}} +

No Upcoming Tasks

+ {{/if}} + {{/if}} + +
+ } + +function getComponent(cardOrField: BaseDef) { + return cardOrField.constructor.getComponent(cardOrField); +} diff --git a/packages/experiments-realm/crm/contact.gts b/packages/experiments-realm/crm/contact.gts index 2a009c4f06..b03022a39b 100644 --- a/packages/experiments-realm/crm/contact.gts +++ b/packages/experiments-realm/crm/contact.gts @@ -57,6 +57,7 @@ class EmbeddedTemplate extends Component { @userId={{@model.id}} @name={{@model.name}} @thumbnailURL={{@model.thumbnailURL}} + class='avatar-group-container' > <:content> <@fields.company @format='atom' @displayContainer={{false}} /> @@ -83,9 +84,14 @@ class EmbeddedTemplate extends Component { @@ -135,18 +169,10 @@ class FittedTemplate extends Component {
-
- <@fields.primaryEmail @format='atom' /> -
-
- <@fields.secondaryEmail @format='atom' /> -
-
- <@fields.phoneMobile @format='atom' /> -
-
- <@fields.phoneOffice @format='atom' /> -
+ <@fields.primaryEmail @format='atom' /> + <@fields.secondaryEmail @format='atom' /> + <@fields.phoneMobile @format='atom' /> + <@fields.phoneOffice @format='atom' />
{{#if this.hasSocialLinks}} @@ -162,21 +188,25 @@ class FittedTemplate extends Component { + +} + export class CRMTaskStatusField extends TaskStatusField { static values = [ { index: 0, label: 'Not Started', color: '#B0BEC5', completed: false }, @@ -405,4 +562,5 @@ export class CRMTask extends Task { }); static isolated = TaskIsolated; + static embedded = TaskEmbedded; } diff --git a/packages/experiments-realm/phone-number.gts b/packages/experiments-realm/phone-number.gts index e186326d94..9652b5be6e 100644 --- a/packages/experiments-realm/phone-number.gts +++ b/packages/experiments-realm/phone-number.gts @@ -130,32 +130,56 @@ export class ContactPhoneNumber extends FieldDef { @field type = contains(PhoneNumberType); static atom = class Atom extends Component { + get hasPhoneNumber() { + return Boolean(this.args.model?.phoneNumber?.number); + } + + get hasCountryCode() { + return Boolean(this.args.model?.phoneNumber?.countryCode); + } + + get hasTypeLabel() { + return Boolean(this.args.model?.type?.label?.length); + } + + get hasCountryCodeAndPhoneNumber() { + return ( + this.args.model && + this.hasCountryCode && + this.hasPhoneNumber && + this.hasTypeLabel + ); + } +