Skip to content

Commit 44608fc

Browse files
committed
Toggle column based on allow update setting
1 parent d6a3445 commit 44608fc

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/Umbraco.Forms.Integrations.Crm.Hubspot/App_Plugins/UmbracoForms.Integrations/Crm/Hubspot/hubspot-field-mapper-template.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
</div>
2121

2222
<div class="umb-forms-mappings mt2" ng-show="vm.mappings.length > 0 && vm.hubspotFields.length > 0">
23-
2423
<div class="umb-forms-mapping-header">
2524
<div class="umb-forms-mapping-field -no-margin-left">Form Field</div>
2625
<div class="umb-forms-mapping-field">Hubspot Field</div>
27-
<div class="umb-forms-mapping-field text-center">Append when updating values</div>
26+
<div ng-if="vm.allowContactUpdate" class="umb-forms-mapping-field text-center">Append when updating values</div>
2827
<div class="umb-forms-mapping-remove -no-margin-right"></div>
2928
</div>
3029

@@ -47,7 +46,7 @@
4746
</select>
4847
</div>
4948

50-
<div class="umb-forms-mapping-field flex justify-center">
49+
<div ng-if="vm.allowContactUpdate" class="umb-forms-mapping-field flex justify-center">
5150
<umb-checkbox name="chkAppend"
5251
value="mapping.appendValue"
5352
model="mapping.appendValue"

src/Umbraco.Forms.Integrations.Crm.Hubspot/App_Plugins/UmbracoForms.Integrations/Crm/Hubspot/hubspotfields.component.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ function HubSpotFieldsController($scope, $routeParams, umbracoFormsIntegrationsC
5353

5454
vm.$onInit = function () {
5555

56+
vm.allowContactUpdate = Umbraco.Sys.ServerVariables.umbracoPlugins.umbracoFormsIntegrationsCrmHubspotAllowContactUpdate;
57+
5658
if (!vm.setting.value) {
5759
vm.mappings = [];
5860
} else {
59-
vm.getParsedMappings();
61+
vm.mappings = parseMappings(vm.setting.value);
6062
}
6163

6264
umbracoFormsIntegrationsCrmHubspotResource.isAuthorizationConfigured().then(function (response) {
@@ -192,9 +194,9 @@ function HubSpotFieldsController($scope, $routeParams, umbracoFormsIntegrationsC
192194
vm.setting.value = JSON.stringify(vm.mappings);
193195
};
194196

195-
vm.getParsedMappings = function () {
196-
var mappings = JSON.parse(vm.setting.value);
197-
vm.mappings = mappings.map(mappingObj => {
197+
function parseMappings(settingValue) {
198+
var mappings = JSON.parse(settingValue);
199+
return mappings.map(mappingObj => {
198200
if (mappingObj.appendValue === undefined) {
199201
mappingObj.appendValue = false;
200202
}

src/Umbraco.Forms.Integrations.Crm.Hubspot/HubspotServerVariablesParsingHandler.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Routing;
3-
3+
using Microsoft.Extensions.Options;
44
using System;
55
using System.Collections.Generic;
66

77
using Umbraco.Cms.Core.Events;
88
using Umbraco.Cms.Core.Notifications;
99
using Umbraco.Extensions;
10+
using Umbraco.Forms.Integrations.Crm.Hubspot.Configuration;
1011
using Umbraco.Forms.Integrations.Crm.Hubspot.Controllers;
1112

1213
namespace Umbraco.Forms.Integrations.Crm.Hubspot
@@ -15,12 +16,15 @@ public class HubspotServerVariablesParsingHandler : INotificationHandler<ServerV
1516
{
1617
private readonly IHttpContextAccessor _httpContextAccessor;
1718
private readonly LinkGenerator _linkGenerator;
19+
private readonly HubspotSettings _settings;
1820

19-
public HubspotServerVariablesParsingHandler(IHttpContextAccessor httpContextAccessor, LinkGenerator linkGenerator)
21+
public HubspotServerVariablesParsingHandler(IHttpContextAccessor httpContextAccessor, LinkGenerator linkGenerator, IOptions<HubspotSettings> options)
2022
{
2123
_httpContextAccessor = httpContextAccessor;
2224

23-
_linkGenerator = linkGenerator;
25+
_linkGenerator = linkGenerator;
26+
27+
_settings = options.Value;
2428
}
2529

2630
public void Handle(ServerVariablesParsingNotification notification)
@@ -51,6 +55,12 @@ public void Handle(ServerVariablesParsingNotification notification)
5155
umbracoUrls["umbracoFormsIntegrationsCrmHubspotBaseUrl"] =
5256
_linkGenerator.GetUmbracoApiServiceBaseUrl<HubspotController>(controller => controller.GetAllProperties());
5357

58+
if (serverVars.ContainsKey("umbracoPlugins"))
59+
{
60+
var umbracoPlugins = (Dictionary<string, object>)serverVars["umbracoPlugins"];
61+
umbracoPlugins.Add("umbracoFormsIntegrationsCrmHubspotAllowContactUpdate", _settings.AllowContactUpdate);
62+
}
63+
5464
}
5565
}
5666
}

0 commit comments

Comments
 (0)