Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS-7926 link crm cards to crm app #2141

Merged
merged 8 commits into from
Feb 17, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"thumbnailURL": null
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/141f3e15-cfd5-4b61-bd4c-37ea31dbeeab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"thumbnailURL": "https://picsum.photos/id/416/200/300"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/9203c173-3420-44b3-863d-90defd7c57c8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"thumbnailURL": null
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/eb6a7c2d-6c94-4e42-aa01-c5823fb5af9a"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"thumbnailURL": null
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/e1856419-27b0-4ce3-98fe-759d21c7144f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"description": "Family-owned bakery specializing in custom cakes and artisanal pastries. Looking to expand online ordering and social media presence.",
"thumbnailURL": "https://example.com/sweet-tooth-logo.png"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/company",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"description": "Modern fitness center with 3 locations. Needs help with membership campaigns and class scheduling system.",
"thumbnailURL": "https://example.com/fitness-first-logo.png"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/company",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"description": "Garden center and nursery wanting to launch seasonal marketing campaigns and e-commerce platform.",
"thumbnailURL": "https://example.com/green-thumb-logo.png"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/company",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"description": "Veterinary clinic seeking to improve online appointment booking and pet owner communication systems.",
"thumbnailURL": "https://example.com/paws-clinic-logo.png"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/company",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"description": "Early-stage startup developing productivity tools for remote teams. Looking to improve their market presence and lead generation through digital marketing.",
"thumbnailURL": "https://example.com/techflow-logo.png"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/company",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"thumbnailURL": "https://images.pexels.com/photos/4571943/pexels-photo-4571943.jpeg?auto=compress&cs=tinysrgb&w=300&h=300&dpr=1"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/141f3e15-cfd5-4b61-bd4c-37ea31dbeeab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"thumbnailURL": "https://images.pexels.com/photos/774909/pexels-photo-774909.jpeg"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/e1856419-27b0-4ce3-98fe-759d21c7144f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"thumbnailURL": "https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/141f3e15-cfd5-4b61-bd4c-37ea31dbeeab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"thumbnailURL": "https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/9203c173-3420-44b3-863d-90defd7c57c8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"thumbnailURL": "https://picsum.photos/id/3/200/300"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"account": {
"links": {
"self": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"thumbnailURL": "https://picsum.photos/id/169/200/300"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"account": {
"links": {
"self": "../Account/c78762d3-9ab5-4f62-9370-d0b6a0261b08"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"thumbnailURL": "https://picsum.photos/id/416/200/300"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"account": {
"links": {
"self": "../Account/be0192c4-e566-40ee-8a57-f88f7ab37e53"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"thumbnailURL": "https://images.pexels.com/photos/1681010/pexels-photo-1681010.jpeg?auto=compress&cs=tinysrgb&w=300&h=300&dpr=2"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/e1856419-27b0-4ce3-98fe-759d21c7144f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
"thumbnailURL": "https://images.pexels.com/photos/2379004/pexels-photo-2379004.jpeg"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/eb6a7c2d-6c94-4e42-aa01-c5823fb5af9a"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"thumbnailURL": "https://images.pexels.com/photos/3785079/pexels-photo-3785079.jpeg?auto=compress&cs=tinysrgb&w=300&h=300&dpr=2"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": "../Company/e1856419-27b0-4ce3-98fe-759d21c7144f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"countryCode": "1"
},
"type": {
"index": 0,
"label": "Mobile"
"index": 2,
"label": "Work"
}
},
"phoneOffice": {
Expand All @@ -38,6 +38,11 @@
"thumbnailURL": "https://images.pexels.com/photos/2379005/pexels-photo-2379005.jpeg"
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"thumbnailURL": null
},
"relationships": {
"crmApp": {
"links": {
"self": "../CrmApp/4e73712d-2a31-4ffe-9c22-d3de277257a6"
}
},
"company": {
"links": {
"self": null
Expand Down
58 changes: 37 additions & 21 deletions packages/experiments-realm/crm-app.gts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
CardError,
SupportedMimeType,
Filter,
getCards,
} from '@cardstack/runtime-common';
import ContactIcon from '@cardstack/boxel-icons/contact';
import HeartHandshakeIcon from '@cardstack/boxel-icons/heart-handshake';
Expand All @@ -46,9 +45,9 @@ import ListDetails from '@cardstack/boxel-icons/list-details';
import { taskStatusValues } from './crm/shared';
import { URGENCY_TAG_VALUES } from './crm/urgency-tag';
import { DEAL_STATUS_VALUES } from './crm/deal-status';
import type { Deal } from './crm/deal';
import DealSummary from './crm/deal-summary';
import { CRMTaskPlanner } from './crm/task-planner';
import type { LooseSingleCardDocument } from '@cardstack/runtime-common';

import type { TemplateOnlyComponent } from '@ember/component/template-only';
import {
Expand Down Expand Up @@ -248,18 +247,6 @@ class CrmAppTemplate extends Component<typeof CrmApp> {
}
});

get deals() {
return this.dealSearch.instances as Deal[];
}

dealSearch = getCards(
() => this.query,
() => this.realmHrefs,
{
isLive: true,
},
);

get filters() {
return this.filterMap.get(this.activeTabId!)!;
}
Expand Down Expand Up @@ -305,8 +292,24 @@ class CrmAppTemplate extends Component<typeof CrmApp> {
return;
}
let currentRealm = this.realms[0];
let doc: LooseSingleCardDocument = {
data: {
type: 'card',
relationships: {
crmApp: {
links: {
self: this.args.model.id ?? null,
},
},
},
meta: {
adoptsFrom: ref,
},
},
};
await this.args.context?.actions?.createCard?.(ref, currentRealm, {
realmURL: currentRealm,
doc,
});
});

Expand All @@ -323,9 +326,17 @@ class CrmAppTemplate extends Component<typeof CrmApp> {

if (!loadAllFilters.isIdle || !activeFilter?.query) return;

const defaultFilter = {
type: activeFilter.cardRef,
};
const defaultFilter = [
{
type: activeFilter.cardRef,
},
{
on: activeFilter.cardRef,
eq: {
'crmApp.id': this.args.model.id,
},
},
];

// filter field value by CRM Account
const accountFilter =
Expand Down Expand Up @@ -357,7 +368,7 @@ class CrmAppTemplate extends Component<typeof CrmApp> {
filter: {
on: activeFilter.cardRef,
every: [
defaultFilter,
...defaultFilter,
...accountFilter,
...dealFilter,
...this.searchFilter,
Expand Down Expand Up @@ -496,9 +507,14 @@ class CrmAppTemplate extends Component<typeof CrmApp> {
</BoxelButton>
{{/if}}
{{#if (eq this.activeTabId 'Deal')}}
<div class='content-header-deal-summary'>
<DealSummary @deals={{this.deals}} />
</div>
{{#if this.query}}
<div class='content-header-deal-summary'>
<DealSummary
@query={{this.query}}
@realmHrefs={{this.realmHrefs}}
/>
</div>
{{/if}}
{{/if}}
<div class='search-bar content-header-row-2'>
<SearchInput
Expand Down
Loading