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 7762 create and implement subclass in activity edit and embedded mode #2032

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
@@ -0,0 +1,90 @@
{
"data": {
"type": "card",
"attributes": {
"subject": "Potential Collaboration 2025",
"activity": {
"type": "Meeting",
"call": {
"phoneNumber": {
"number": null,
"countryCode": null
},
"callTime": null,
"callDuration": null
},
"email": {
"emailAddress": null,
"emailContent": null,
"sentTime": null
},
"meeting": {
"location": {
"addressLine1": "123 Main Street",
"addressLine2": "Suite 400",
"city": "New York",
"state": "NY",
"postalCode": "10001",
"country": {
"name": "Albania",
"code": "AL"
},
"poBoxNumber": ""
},
"startTime": "2025-01-15T04:30:00.000Z",
"endTime": "2025-01-15T05:30:00.000Z"
}
},
"status": {
"index": 0,
"label": "Pending",
"color": null,
"colorScheme": {
"foregroundColor": "#000000",
"backgroundColor": "#FFF3E0"
}
},
"dueDate": "2025-01-30T08:40:00.000Z",
"description": null,
"thumbnailURL": null
},
"relationships": {
"contact.0": {
"links": {
"self": "../Customer/0e5aec99-798b-4417-9426-a338432e0ee5"
}
},
"contact.1": {
"links": {
"self": "../Lead/9d7b2f20-c7da-4ddc-8e77-b75d88c97b48"
}
},
"contact.2": {
"links": {
"self": "../Contact/a01fc5c9-d70d-4b9c-aae4-384cf2b79b25"
}
},
"deal": {
"links": {
"self": null
}
},
"account": {
"links": {
"self": "../Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7"
}
},
"rep": {
"links": {
"self": "../Representative/e0b16307-04bd-4e48-bdf8-517bb35b8119"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/activity",
"name": "Activity"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"data": {
"type": "card",
"attributes": {
"subject": "Discuss Q3 Product RoadMap",
"activity": {
"type": "Customer Call",
"call": {
"phoneNumber": {
"number": "108920123",
"countryCode": "60"
},
"callTime": "2025-01-13T04:30:00.000Z",
"callDuration": "1 hour"
},
"email": {
"emailAddress": null,
"emailContent": null,
"sentTime": null
},
"meeting": {
"location": {
"addressLine1": null,
"addressLine2": null,
"city": null,
"state": null,
"postalCode": null,
"country": {
"name": null,
"code": null
},
"poBoxNumber": null
},
"startTime": null,
"endTime": null
}
},
"status": {
"index": 0,
"label": "Pending",
"color": null,
"colorScheme": {
"foregroundColor": "#000000",
"backgroundColor": "#FFF3E0"
}
},
"dueDate": "2025-01-31T04:11:00.000Z",
"description": null,
"thumbnailURL": null
},
"relationships": {
"contact.0": {
"links": {
"self": "../Contact/a01fc5c9-d70d-4b9c-aae4-384cf2b79b25"
}
},
"deal": {
"links": {
"self": "../Deal/4fdd3053-14f1-4800-827f-d3e2a5c44ae8"
}
},
"account": {
"links": {
"self": "../Account/bf437dc3-1f96-45e5-a057-3487c6a5c2f7"
}
},
"rep": {
"links": {
"self": "../Representative/e0b16307-04bd-4e48-bdf8-517bb35b8119"
}
}
},
"meta": {
"adoptsFrom": {
"module": "../crm/activity",
"name": "Activity"
}
}
}
}
22 changes: 22 additions & 0 deletions packages/experiments-realm/crm/activity-type/call.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { FieldDef } from 'https://cardstack.com/base/card-api';
import { contains, field } from 'https://cardstack.com/base/card-api';
import { StringField } from 'https://cardstack.com/base/card-api';
import { PhoneField } from '../../phone-number';
import DatetimeField from 'https://cardstack.com/base/datetime';

export class Call extends FieldDef {
static displayName = 'Call Activity';
@field phoneNumber = contains(PhoneField);
@field callTime = contains(DatetimeField);
@field callDuration = contains(StringField);
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the date-range field here?


@field title = contains(StringField, {
computeVia: function (this: Call) {
const phoneStr =
`${this.phoneNumber.countryCode}-${this.phoneNumber.number}` ?? '';
const timeStr = this.callTime?.toLocaleString() ?? '';
const durationStr = this.callDuration ?? '';
return `${phoneStr} - ${timeStr} - ${durationStr}`;
},
});
Comment on lines +13 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we let the user decide on the title for each of the activity types? The empty strings or nulls look strange.

}
20 changes: 20 additions & 0 deletions packages/experiments-realm/crm/activity-type/email.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FieldDef } from 'https://cardstack.com/base/card-api';
import { contains, field } from 'https://cardstack.com/base/card-api';
import { StringField } from 'https://cardstack.com/base/card-api';
import { EmailField } from '../../email';
import DatetimeField from 'https://cardstack.com/base/datetime';

export class Email extends FieldDef {
static displayName = 'Email Activity';
@field emailAddress = contains(EmailField);
@field emailContent = contains(StringField);
@field sentTime = contains(DatetimeField);
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't sentTime be the timestamp? If it's meant to be for scheduling, maybe a clearer field name would be better. Is this the actual content of the email? If it is necessary, maybe it should be a markdown field.


@field title = contains(StringField, {
computeVia: function (this: Email) {
const emailStr = this.emailAddress?.toString() ?? '';
const timeStr = this.sentTime?.toLocaleString() ?? '';
return `${emailStr} - ${timeStr}`;
},
});
}
20 changes: 20 additions & 0 deletions packages/experiments-realm/crm/activity-type/meeting.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FieldDef } from 'https://cardstack.com/base/card-api';
import { contains, field } from 'https://cardstack.com/base/card-api';
import { Address as AddressField } from '../../address';
import { StringField } from 'https://cardstack.com/base/card-api';
import DatetimeField from 'https://cardstack.com/base/datetime';

export class Meeting extends FieldDef {
static displayName = 'Meeting Activity';
@field location = contains(AddressField);
@field startTime = contains(DatetimeField);
@field endTime = contains(DatetimeField);
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the date range field here?


@field title = contains(StringField, {
computeVia: function (this: Meeting) {
const startTimeStr = this.startTime?.toLocaleString() ?? '';
const endTimeStr = this.endTime?.toLocaleString() ?? '';
return `${startTimeStr} to ${endTimeStr}`;
},
});
}
Loading
Loading