Skip to content

Commit 47ac26f

Browse files
authored
Merge pull request #68 from umbraco/feature/inriver-integration
Feature/inriver integration
2 parents 3aacc11 + ff13377 commit 47ac26f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1444
-1
lines changed

src/Umbraco.Cms.Integrations.Crm.Dynamics/Controllers/FormsController.cs

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public async Task<string> GetAccessToken([FromBody] OAuthRequestDto authRequestD
119119
return "Error: " + identity.Error.Message;
120120

121121
return result;
122+
}
122123

123124
var errorResult = await response.Content.ReadAsStringAsync();
124125
var errorDto = JsonConvert.DeserializeObject<ErrorDto>(errorResult);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Integrations.PIM.Inriver.Models.ViewModels.InriverEntityViewModel>
2+
3+
<div>
4+
<img src="@Model.ResourceUrl" alt="@Model.ResourceUrl" width="100" />
5+
<h1>@Model.DisplayName</h1>
6+
<p>@Model.DisplayDescription</p>
7+
@if (Model.Fields.Any())
8+
{
9+
<ul>
10+
@foreach (var field in Model.Fields)
11+
{
12+
<li>
13+
<div>
14+
<b>@field.FieldTypeId</b>: @field.Value
15+
<p>
16+
@field.Display
17+
</p>
18+
</div>
19+
</li>
20+
}
21+
</ul>
22+
}
23+
@if (Model.Outbound != null)
24+
{
25+
<h3>Linked Types</h3>
26+
@foreach (var outboundItem in Model.Outbound)
27+
{
28+
<p><b>@outboundItem.Summary.DisplayName</b></p>
29+
<ul>
30+
@foreach (var field in outboundItem.Fields)
31+
{
32+
<li>
33+
<div>
34+
<b>@field.FieldTypeId</b>: @field.Value
35+
<p>
36+
@field.Display
37+
</p>
38+
</div>
39+
</li>
40+
}
41+
</ul>
42+
43+
}
44+
}
45+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.inriver-container {
2+
margin: 20px;
3+
}
4+
5+
.inriver-toast {
6+
top: 0;
7+
left: 0;
8+
right: 0;
9+
height: 100vh;
10+
padding: var(--uui-size-layout-4);
11+
}
12+
13+
#editorDialog {
14+
display: none;
15+
left: 50%;
16+
top: 50%;
17+
position: absolute;
18+
transform: translate(-70%,-70%);
19+
z-index: 1;
20+
}
21+
22+
.inriver-center {
23+
display: block;
24+
margin: auto;
25+
width: 50%;
26+
padding: 10px;
27+
}
28+
29+
.inriver-search {
30+
width:70%;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
function configurationController($scope, notificationsService, umbracoCmsIntegrationsPimInriverService, umbracoCmsIntegrationsPimInriverResource) {
2+
var vm = this;
3+
4+
const selEntityTypes = document.getElementById("selEntityTypes");
5+
6+
vm.configuration = {};
7+
8+
// object for populating configuration data
9+
vm.data = {
10+
entityTypes: [],
11+
fieldTypes: [],
12+
linkedTypes: []
13+
};
14+
15+
// object for selected data
16+
vm.selectedData = {
17+
entityType: {},
18+
fieldTypes: [],
19+
linkedTypes: []
20+
};
21+
22+
if ($scope.model.value == null) {
23+
$scope.model.value = {
24+
entityType: '',
25+
fieldTypes: [],
26+
linkedTypes: []
27+
};
28+
}
29+
$scope.$on('formSubmitting', function (ev) {
30+
if (vm.selectedData.entityType == undefined
31+
|| vm.selectedData.entityType.length == 0
32+
|| vm.selectedData.fieldTypes.length == 0) {
33+
notificationsService.error("Inriver", "Entity type and display fields are required. Configuration was not saved.");
34+
ev.preventDefault();
35+
return;
36+
} else {
37+
$scope.model.value = {
38+
entityType: vm.selectedData.entityType.value,
39+
fieldTypes: vm.selectedData.fieldTypes,
40+
linkedTypes: vm.selectedData.linkedTypes
41+
};
42+
}
43+
});
44+
45+
vm.entityTypeChange = function () {
46+
vm.selectedData.entityType = vm.entityTypes.find(obj => obj.value == selEntityTypes.value);;
47+
48+
vm.data.fieldTypes = vm.selectedData.entityType.fieldTypes;
49+
vm.data.linkedTypes = vm.selectedData.entityType.linkedTypes;
50+
51+
vm.selectedData.fieldTypes = [];
52+
}
53+
54+
umbracoCmsIntegrationsPimInriverResource.checkApiAccess().then(function (response) {
55+
vm.configuration.icon = response.success ? 'unlock' : 'lock';
56+
vm.configuration.tag = response.success ? 'positive' : 'danger';
57+
vm.configuration.status = response;
58+
59+
if (response.success) {
60+
umbracoCmsIntegrationsPimInriverResource.getEntityTypes().then(function (entityTypesResponse) {
61+
vm.entityTypes = entityTypesResponse.data.map(obj => {
62+
var option = {
63+
value: obj.id,
64+
name: obj.name,
65+
fieldTypes: obj.fieldTypes,
66+
linkedTypes: obj.outboundLinkTypes
67+
};
68+
if ($scope.model.value !== null && $scope.model.value.entityType == obj.id) {
69+
option.selected = true;
70+
71+
vm.selectedData.entityType = option;
72+
}
73+
return option;
74+
});
75+
76+
if ($scope.model.value.fieldTypes != null)
77+
vm.selectedData.fieldTypes = $scope.model.value.fieldTypes;
78+
79+
if ($scope.model.value.linkedTypes != null)
80+
vm.selectedData.linkedTypes = $scope.model.value.linkedTypes;
81+
82+
bindValues();
83+
});
84+
85+
}
86+
});
87+
88+
// table rows selection
89+
vm.selectFieldType = function (fieldType) {
90+
vm.selectedData.fieldTypes.push(fieldType);
91+
}
92+
93+
vm.unselectFieldType = function (fieldTypeId) {
94+
vm.selectedData.fieldTypes = vm.selectedData.fieldTypes.filter(obj => obj.fieldTypeId != fieldTypeId);
95+
}
96+
97+
vm.toggleLinkedType = function (linkedType) {
98+
const chkEl = document.getElementById("chk" + linkedType);
99+
100+
if (chkEl.checked)
101+
vm.selectedData.linkedTypes.push(linkedType);
102+
else
103+
vm.selectedData.linkedTypes = vm.selectedData.linkedTypes.filter(obj => obj != linkedType);
104+
}
105+
106+
function bindValues() {
107+
selEntityTypes.options = vm.entityTypes;
108+
vm.data.fieldTypes = vm.selectedData.entityType.fieldTypes;
109+
vm.data.linkedTypes = vm.selectedData.entityType.linkedTypes;
110+
111+
// select field types
112+
if ($scope.model.value.fieldTypes != null) {
113+
$scope.model.value.fieldTypes.forEach(obj => {
114+
umbracoCmsIntegrationsPimInriverService.waitForElement("#tr" + obj.fieldTypeId)
115+
.then(element => element.setAttribute("selected", ""));
116+
});
117+
}
118+
119+
// select linked types
120+
if ($scope.model.value.linkedTypes != null) {
121+
$scope.model.value.linkedTypes.forEach(obj => {
122+
umbracoCmsIntegrationsPimInriverService.waitForElement("#chk" + obj)
123+
.then(element => element.setAttribute("checked", ""));
124+
});
125+
}
126+
}
127+
}
128+
129+
angular.module("umbraco")
130+
.controller("Umbraco.Cms.Integrations.PIM.Inriver.ConfigurationController", configurationController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
function entityPickerController($scope, editorService, umbracoCmsIntegrationsPimInriverResource) {
2+
3+
var vm = this;
4+
5+
vm.selectedEntity = null;
6+
vm.error = "";
7+
vm.configuration = $scope.model.config.configuration;
8+
9+
umbracoCmsIntegrationsPimInriverResource.checkApiAccess().then(function (response) {
10+
if (response.failure)
11+
vm.error = response.data;
12+
});
13+
14+
if (vm.configuration.entityType == undefined
15+
|| vm.configuration.entityType.length == 0
16+
|| vm.configuration.fieldTypes == null
17+
|| vm.configuration.fieldTypes.length == 0) {
18+
vm.error = "Invalid Inriver configuration";
19+
return;
20+
}
21+
22+
if ($scope.model.value) {
23+
getEntityData($scope.model.value.entityId);
24+
}
25+
26+
vm.openInriverEntityPickerOverlay = function () {
27+
var options = {
28+
title: "Inriver " + $scope.model.config.configuration.entityType,
29+
subtitle: "Select a " + $scope.model.config.configuration.entityType,
30+
configuration: $scope.model.config.configuration,
31+
view: "/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/views/entitypickereditor.html",
32+
size: "medium",
33+
save: function (entityId) {
34+
vm.saveEntity(entityId);
35+
editorService.close();
36+
},
37+
close: function () {
38+
editorService.close();
39+
}
40+
};
41+
42+
editorService.open(options);
43+
};
44+
45+
vm.saveEntity = function (entityId) {
46+
$scope.model.value = JSON.stringify({
47+
entityId: entityId,
48+
displayFields: $scope.model.config.configuration.fieldTypes,
49+
linkedTypes: $scope.model.config.configuration.linkedTypes
50+
});
51+
52+
getEntityData(entityId);
53+
}
54+
55+
vm.removeEntity = function () {
56+
$scope.model.value = null;
57+
vm.selectedEntity = null;
58+
}
59+
60+
function getEntityData(entityId) {
61+
umbracoCmsIntegrationsPimInriverResource.fetchEntityData(entityId).then(function (response) {
62+
if (response.success) {
63+
vm.selectedEntity = response.data[0];
64+
vm.selectedEntity.detail = $scope.model.config.configuration.fieldTypes
65+
.map(obj => obj.fieldTypeDisplayName).join(",");
66+
} else
67+
vm.error = response.error;
68+
});
69+
}
70+
71+
}
72+
73+
angular.module("umbraco")
74+
.controller("Umbraco.Cms.Integrations.PIM.Inriver.EntityPickerController", entityPickerController);

0 commit comments

Comments
 (0)