Skip to content

Commit

Permalink
add company name field at opportunity form, currently dont have this …
Browse files Browse the repository at this point in the history
…field
  • Loading branch information
lucas committed Jun 28, 2024
1 parent 4623e26 commit 312a9e9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "card",
"attributes": {
"opportunityName": "Opportunity Name",
"companyName": "",
"closeDate": "2024-06-13",
"amount": {
"currency": "RM",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
},
"opportunityForm": {
"opportunityName": null,
"companyName": "Law lawbombom",
"closeDate": null,
"amount": {
"currency": null,
Expand Down
20 changes: 20 additions & 0 deletions packages/drafts-realm/opportunity-form.gts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class AmountField extends FieldDef {

/* Opportunity Form */
class IsolatedSecForOpportunityForm extends Component<typeof OpportunityForm> {
get getCompanyName() {
if (!this.args.model.companyName) return '-';
return this.args.model.companyName;
}

get getFormattedAmount() {
const amount = this.args.model.amount;
const hasAmount = amount && amount.totalAmount;
Expand Down Expand Up @@ -176,6 +181,11 @@ class IsolatedSecForOpportunityForm extends Component<typeof OpportunityForm> {
</div>

<div class='field-input-group'>
<div class='field-input'>
<label>Company Name: </label>

{{this.getCompanyName}}
</div>
<div class='field-input'>
<label>Close Date: </label>
<@fields.closeDate />
Expand Down Expand Up @@ -338,6 +348,10 @@ class EditSecForOpportunityForm extends Component<typeof OpportunityForm> {
<@fields.accountName />
</FieldContainer>

<FieldContainer @tag='label' @label='Company Name' @vertical={{true}}>
<@fields.companyName />
</FieldContainer>

<FieldContainer @tag='label' @label='Close Date' @vertical={{true}}>
<@fields.closeDate />
</FieldContainer>
Expand Down Expand Up @@ -432,6 +446,9 @@ export class OpportunityFormField extends FieldDef {
@field accountName = linksTo(CrmAccount, {
description: `Account Name`,
});
@field companyName = contains(StringField, {
description: `Company Name`,
});
@field closeDate = contains(DateCard, {
description: `Close Date`,
});
Expand Down Expand Up @@ -465,6 +482,9 @@ export class OpportunityForm extends CardDef {
@field accountName = linksTo(CrmAccount, {
description: `Account Name`,
});
@field companyName = contains(StringField, {
description: `Company Name`,
});
@field closeDate = contains(DateCard, {
description: `Close Date`,
});
Expand Down
20 changes: 5 additions & 15 deletions packages/drafts-realm/sale-hub.gts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
@action
handleConvert() {
this.openModal();
this.updateAccountFormAccountName();
this.updateContactFormName();
this.updateOpportunityAccountName();
}

//task-form modal
Expand All @@ -796,10 +799,6 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
@action
openTaskFormModal() {
this.isTaskFormModalVisible = true;

this.updateAccountFormAccountName();
this.updateContactFormName();
this.updateOpportunityAccountName();
}

@action
Expand Down Expand Up @@ -848,43 +847,34 @@ class IsolatedSecForSaleHub extends Component<typeof SaleHub> {
const firstName = this.args.model.leadForm.name.firstName;
const company = this.args.model.leadForm.company;

this.args.model.opportunityForm.opportunityName = `${firstName} ${company}`;
this.args.model.opportunityForm.companyName = `${firstName} ${company}`;
}
}

get accountFormAccountName() {
const { leadForm } = this.args.model;

if (!leadForm || !leadForm.name) return '';

const { salutation, firstName, lastName } = leadForm.name;

if (!salutation || !firstName || !lastName) return '';

return `${salutation} ${firstName} ${lastName}`;
}

get contactFormAccountName() {
const { leadForm } = this.args.model;

if (!leadForm || !leadForm.name) return '';

const { salutation, firstName, lastName } = leadForm.name;

if (!salutation || !firstName || !lastName) return '';

return `${salutation} ${firstName} ${lastName}`;
}

get opportunityFormName() {
const { leadForm } = this.args.model;

if (!leadForm || !leadForm.name || !leadForm.company) return '';

if (!leadForm || !leadForm.company) return '';
const { firstName } = leadForm.name;

if (!firstName) return '';

return `${firstName} ${leadForm.company}`;
}

Expand Down

0 comments on commit 312a9e9

Please sign in to comment.