Skip to content

Commit 3e8c892

Browse files
committed
Update hubspot-mapping.property-editor.ts
- Update UI
1 parent 10b067c commit 3e8c892

File tree

1 file changed

+119
-7
lines changed

1 file changed

+119
-7
lines changed

src/Umbraco.Forms.Integrations.Crm.Hubspot/Client/src/property-editor/hubspot-mapping.property-editor.ts

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,131 @@
1-
import { html, customElement, property, css, when } from '@umbraco-cms/backoffice/external/lit';
1+
import { html, customElement, property, css, when, state, map } from '@umbraco-cms/backoffice/external/lit';
22
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
33
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
4+
import { HUBSPOT_CONTEXT_TOKEN } from '@umbraco-integrations/hubspot/context';
5+
import { Property } from '@umbraco-integrations/hubspot/generated';
46

57
const elementName = "hubspot-mapping-property-editor";
68

79
@customElement(elementName)
810
export class HubspotMappingPropertyUiElement extends UmbLitElement implements UmbPropertyEditorUiElement {
9-
render() {
10-
return html`
11-
<div>
12-
<uui-select></uui-select>
13-
</div>
14-
`;
11+
#hubspotContext!: typeof HUBSPOT_CONTEXT_TOKEN.TYPE;
12+
13+
@property({ type: String })
14+
public value = "";
15+
16+
@state()
17+
public hubspotMappingArray : Array<string> = [];
18+
19+
@state()
20+
private selectedContactField: string = "";
21+
22+
@state()
23+
private selectedFormField: string = "";
24+
25+
@state()
26+
private hubspotFields: Array<Property> | undefined = [];
27+
28+
@state()
29+
private formdFields: Array<string> | undefined = [];
30+
31+
constructor() {
32+
super();
33+
this.consumeContext(HUBSPOT_CONTEXT_TOKEN, (context) => {
34+
if (!context) return;
35+
this.#hubspotContext = context;
36+
});
37+
}
38+
39+
async connectedCallback() {
40+
super.connectedCallback();
41+
42+
if(this.value){
43+
this.hubspotMappingArray = JSON.parse(this.value);
1544
}
45+
46+
await this.#getHubspotFields();
47+
//await this.#getFormFields();
48+
}
49+
50+
async #getHubspotFields(){
51+
var result = await this.#hubspotContext.getAll();
52+
if (!result) return;
53+
54+
this.hubspotFields = result.data;
55+
}
56+
57+
// async #getFormFields(){
58+
// var formId = window.location.pathname.split("/")[7]; //Get the formid based on current url.
59+
// var result = await this.#activeCampaignContext.getFormFields(formId);
60+
61+
// if (!result) return;
62+
63+
// this.formdFields = result.data;
64+
// }
65+
66+
#onDeleteClick(idx: number){
67+
68+
}
69+
70+
isDisabled(){
71+
return false;
72+
}
73+
74+
#addButtonClick(){
75+
this.hubspotMappingArray.push("");
76+
}
77+
78+
render() {
79+
return html`
80+
<div>Umbraco forms is configured.</div>
81+
82+
<div>
83+
${this.hubspotMappingArray.length > 0
84+
? html`
85+
<table>
86+
<thead>
87+
<tr>
88+
<th>Form Field</th>
89+
<th>Hubspot Field</th>
90+
<th></th>
91+
</tr>
92+
</thead>
93+
<tbody>
94+
${map(this.hubspotMappingArray, (mapping, idx) => html`
95+
<tr>
96+
<td>
97+
<uui-select></uui-select>
98+
</td>
99+
<td>
100+
<uui-select></uui-select>
101+
</td>
102+
<td>
103+
<uui-button
104+
label=${this.localize.term("formProviderWorkflows_delete")}
105+
look="secondary"
106+
color="default"
107+
@click=${() => this.#onDeleteClick(idx)}>
108+
<uui-icon name="delete"></uui-icon>
109+
</uui-button>
110+
</td>
111+
</tr>
112+
`)}
113+
</tbody>
114+
</table>
115+
`
116+
: html``}
117+
</div>
118+
119+
<div class="activecampaign-wf-button">
120+
<uui-button look="primary" ?disabled=${this.isDisabled()} label="Add mapping" @click=${this.#addButtonClick}></uui-button>
121+
</div>
122+
123+
<div class="activecampaign-wf-button">
124+
<uui-button look="primary" ?disabled=${this.isDisabled()} label="De-authorize from Hubspot" @click=${this.#addButtonClick}></uui-button>
125+
</div>
126+
`;
16127
}
128+
}
17129

18130
export default HubspotMappingPropertyUiElement;
19131

0 commit comments

Comments
 (0)