Skip to content

Commit 2b530e7

Browse files
committed
Inriver integration draft
1 parent abe03a1 commit 2b530e7

30 files changed

+837
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.inriver-container {
2+
margin: 20px;
3+
/*position: absolute;
4+
left: 50%;
5+
top: 50%;
6+
transform: translate(-50%, -50%);*/
7+
}
8+
9+
#editorDialog {
10+
display: none;
11+
left: 50%;
12+
top: 50%;
13+
position: absolute;
14+
transform: translate(-70%,-70%);
15+
z-index: 1;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function configurationController($scope, umbracoCmsIntegrationsPimInriverResource) {
2+
var vm = this;
3+
4+
vm.configuration = {};
5+
6+
if ($scope.model.value == null) {
7+
$scope.model.value = {
8+
entityType: '',
9+
allowChange: false
10+
};
11+
}
12+
13+
$scope.$on('formSubmitting', function () {
14+
var selEntityTypes = document.getElementById("selEntityTypes");
15+
var chkAllowChange = document.getElementById("chkAllowChange");
16+
17+
$scope.model.value.entityType = selEntityTypes.value;
18+
$scope.model.value.allowChange = chkAllowChange.checked;
19+
});
20+
21+
umbracoCmsIntegrationsPimInriverResource.checkApiAccess().then(function (response) {
22+
vm.configuration.icon = response.success ? 'unlock' : 'lock';
23+
vm.configuration.tag = response.success ? 'positive' : 'danger';
24+
vm.configuration.status = response;
25+
26+
if (response.success) {
27+
umbracoCmsIntegrationsPimInriverResource.getEntityTypes().then(function (entityTypesResponse) {
28+
var entityTypes = entityTypesResponse.data.map(obj => {
29+
var option = {
30+
name: obj.name,
31+
value: obj.id
32+
};
33+
if ($scope.model.value !== null && $scope.model.value.EntityType == obj.id) {
34+
option.selected = true;
35+
}
36+
return option;
37+
});
38+
bindValues(entityTypes);
39+
});
40+
41+
}
42+
});
43+
44+
function bindValues(entityTypes) {
45+
var selEntityTypes = document.getElementById("selEntityTypes");
46+
selEntityTypes.options = entityTypes;
47+
48+
var chkAllowChange = document.getElementById("chkAllowChange");
49+
chkAllowChange.checked = $scope.model.value.AllowChange;
50+
}
51+
}
52+
53+
angular.module("umbraco")
54+
.controller("Umbraco.Cms.Integrations.PIM.Inriver.ConfigurationController", configurationController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
function entityPickerController($scope, editorService, notificationsService, umbracoCmsIntegrationsPimInriverResource) {
2+
3+
var vm = this;
4+
vm.error = '';
5+
6+
const dialog = document.getElementById('editorDialog');
7+
dialog.style.display = "block";
8+
9+
// add event listeners
10+
var btnCancel = dialog.querySelector('#btnCancel');
11+
btnCancel.addEventListener('click', closeEditor);
12+
13+
14+
umbracoCmsIntegrationsPimInriverResource.checkApiAccess().then(function (response) {
15+
if (response.failure)
16+
vm.error = response.data;
17+
});
18+
19+
vm.openInriverEntityPickerOverlay = function () {
20+
var options = {
21+
title: "Inriver Entities",
22+
subtitle: "Select entity",
23+
configuration: {
24+
entityType: $scope.model.config.configuration.EntityType,
25+
allowChange: $scope.model.config.configuration.AllowChange
26+
},
27+
view: "/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/views/entitypickereditor.html",
28+
size: "medium",
29+
select: function (entity) {
30+
//vm.saveForm(form);
31+
32+
//editorService.close();
33+
},
34+
close: function () {
35+
editorService.close();
36+
}
37+
};
38+
39+
editorService.open(options);
40+
};
41+
42+
function closeEditor() {
43+
const dialog = document.getElementById('editorDialog');
44+
dialog.style.display = "none";
45+
}
46+
47+
//vm.saveForm = function (formId) {
48+
// $scope.model.value = formId;
49+
50+
// getFormDetails(formId);
51+
//}
52+
53+
//vm.removeForm = function () {
54+
// $scope.model.value = null;
55+
// vm.selectedForm = {};
56+
//}
57+
58+
}
59+
60+
angular.module("umbraco")
61+
.controller("Umbraco.Cms.Integrations.PIM.Inriver.EntityPickerController", entityPickerController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function entityPickerEditorController($scope, editorService, notificationsService, umbracoCmsIntegrationsPimInriverResource) {
2+
3+
var vm = this;
4+
5+
umbracoCmsIntegrationsPimInriverResource.getEntityTypes().then(function (entityTypesResponse) {
6+
var entityTypes = entityTypesResponse.data.map(obj => {
7+
var option = {
8+
name: obj.name,
9+
value: obj.id
10+
};
11+
if ($scope.model.configuration.entityType == obj.id) {
12+
option.selected = true;
13+
}
14+
return option;
15+
});
16+
bindValues(entityTypes);
17+
});
18+
19+
function bindValues(entityTypes) {
20+
var selEntityTypes = document.getElementById("selEntityTypes");
21+
selEntityTypes.options = entityTypes;
22+
23+
var selectedEntityType = entityTypes.find(obj => obj.selected);
24+
query(selectedEntityType.value);
25+
}
26+
27+
function query(entityTypeId) {
28+
umbracoCmsIntegrationsPimInriverResource.query(entityTypeId).then(function (response) {
29+
if (response.success) {
30+
vm.entities = [];
31+
for (var i = 0; i < response.data.entityIds.length; i++) {
32+
umbracoCmsIntegrationsPimInriverResource.getEntitySummary(response.data.entityIds[i]).then(function (summaryResponse) {
33+
vm.entities.push(summaryResponse.data);
34+
});
35+
}
36+
}
37+
});
38+
}
39+
}
40+
41+
angular.module("umbraco")
42+
.controller("Umbraco.Cms.Integrations.PIM.Inriver.EntityPickerEditorController", entityPickerEditorController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
angular.module('umbraco.resources')
2+
.factory('umbracoCmsIntegrationsPimInriverResource',
3+
function ($http, umbRequestHelper) {
4+
5+
const apiEndpoint = "backoffice/UmbracoCmsIntegrationsPimInriver/Entity";
6+
7+
return {
8+
checkApiAccess: function () {
9+
return umbRequestHelper.resourcePromise(
10+
$http.get(`${apiEndpoint}/CheckApiAccess`), "Failed to access resource");
11+
},
12+
getEntityTypes: function () {
13+
return umbRequestHelper.resourcePromise(
14+
$http.get(`${apiEndpoint}/GetEntityTypes`), "Failed to access resource.")
15+
},
16+
getEntitySummary: function (id) {
17+
return umbRequestHelper.resourcePromise(
18+
$http.get(`${apiEndpoint}/GetEntitySummary?id=${id}`), "Failed to access resource.")
19+
},
20+
query: function (entityTypeId) {
21+
return umbRequestHelper.resourcePromise(
22+
$http.post(`${apiEndpoint}/Query`, {
23+
entityTypeId: entityTypeId
24+
}), "Failed to access resource.")
25+
}
26+
};
27+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "Umbraco.Cms.Integrations.PIM.Inriver",
3+
"version": "1.0.0",
4+
"allowPackageTelemetry": true,
5+
"javascript": [
6+
"~/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/configuration.controller.js",
7+
"~/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/entitypicker.controller.js",
8+
"~/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/entitypickereditor.controller.js",
9+
"~/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/inriver.resource.js"
10+
],
11+
"css": [
12+
"~/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/css/inriver.css"
13+
]
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div ng-controller="Umbraco.Cms.Integrations.PIM.Inriver.ConfigurationController as vm">
2+
<uui-icon-registry-essential>
3+
<uui-card-content-node name="Inriver API" style="max-width: 800px;">
4+
<uui-icon slot="icon" name="{{vm.configuration.icon}}"></uui-icon>
5+
<uui-tag size="s" slot="tag" color="{{vm.configuration.tag}}">
6+
{{vm.configuration.status.success ? vm.configuration.status.data : vm.configuration.status.error}}
7+
</uui-tag>
8+
<div style="width:60%">
9+
<uui-form>
10+
<uui-form-layout-item>
11+
<span style="font-weight:700;font-size:15px;">Entity Type:</span>
12+
<uui-select id="selEntityTypes" label="Entity Types" placeholder="Please select an entity type"></uui-select>
13+
</uui-form-layout-item>
14+
<uui-form-layout-item>
15+
<uui-checkbox id="chkAllowChange" label="Allow editor to change entity type">
16+
<span style="font-weight:700;font-size:15px;">Allow editor to change entity type</span>
17+
</uui-checkbox>
18+
</uui-form-layout-item>
19+
</uui-form>
20+
</div>
21+
</uui-card-content-node>
22+
</uui-icon-registry-essential>
23+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div ng-controller="Umbraco.Cms.Integrations.PIM.Inriver.EntityPickerController as vm">
2+
<a class="umb-node-preview-add"
3+
ng-click="vm.openInriverEntityPickerOverlay()"
4+
prevent-default>
5+
<localize key="general_add">Add</localize>
6+
</a>
7+
<div ng-if="vm.error" class="alert alert-warning mt2" style="max-width: 800px;">
8+
{{ vm.error }}
9+
</div>
10+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div ng-controller="Umbraco.Cms.Integrations.PIM.Inriver.EntityPickerEditorController as vm">
2+
<uui-box headline="{{model.title}}" class="inriver-container">
3+
<div style="width:60%">
4+
<uui-form>
5+
<uui-form-layout-item>
6+
<span style="font-weight:700;font-size:15px;">Entity Type:</span>
7+
<uui-select id="selEntityTypes" label="Entity Types" placeholder="Please select an entity type"></uui-select>
8+
</uui-form-layout-item>
9+
<uui-form-layout-item>
10+
<uui-table aria-label="Entities table">
11+
<uui-table-row selectable ng-repeat="item in vm.entities">
12+
<uui-table-cell ng-repeat="(value, key) in item">{{key}}</uui-table-cell>
13+
</uui-table-row>
14+
</uui-table>
15+
</uui-form-layout-item>
16+
</uui-form>
17+
</div>
18+
</uui-box>
19+
<umb-editor-footer>
20+
<umb-editor-footer-content-right>
21+
<umb-button type="button"
22+
button-style="link"
23+
label-key="general_close"
24+
shortcut="esc"
25+
action="model.close()">
26+
</umb-button>
27+
</umb-editor-footer-content-right>
28+
</umb-editor-footer>
29+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Umbraco.Cms.Integrations.PIM.Inriver.Configuration
4+
{
5+
public class EditorSettings
6+
{
7+
[JsonPropertyName("entityType")]
8+
public string EntityType { get; set; } = string.Empty;
9+
10+
[JsonPropertyName("allowChange")]
11+
public bool AllowChange { get; set; }
12+
}
13+
}

0 commit comments

Comments
 (0)