Skip to content

Commit ddf77d7

Browse files
committed
Bug fixing + save configuration with fields display name
1 parent d76f90a commit ddf77d7

File tree

13 files changed

+62
-56
lines changed

13 files changed

+62
-56
lines changed

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/configuration.controller.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@
1111
vm.selectedEntityType = {};
1212
vm.selectedFieldTypes = [];
1313

14-
vm.showToast = showToast;
15-
1614
if ($scope.model.value == null) {
1715
$scope.model.value = {
1816
entityType: '',
19-
displayFieldTypeIds: []
17+
fieldTypes: []
2018
};
2119
}
2220
$scope.$on('formSubmitting', function (ev) {
2321
if (vm.selectedEntityType == undefined
24-
|| vm.selectedEntityType.value.length == 0
22+
|| vm.selectedEntityType.length == 0
2523
|| vm.selectedFieldTypes.length == 0) {
2624
notificationsService.error("Inriver", "Entity type and display fields are required. Configuration was not saved.");
2725
ev.preventDefault();
2826
return;
2927
} else {
3028
$scope.model.value.entityType = vm.selectedEntityType.value;
31-
$scope.model.value.displayFieldTypeIds = vm.selectedFieldTypes;
29+
$scope.model.value.fieldTypes = vm.selectedFieldTypes;
3230
}
3331
});
3432

@@ -62,8 +60,8 @@
6260
return option;
6361
});
6462

65-
if ($scope.model.value.displayFieldTypeIds != null)
66-
vm.selectedFieldTypes = $scope.model.value.displayFieldTypeIds;
63+
if ($scope.model.value.fieldTypes != null)
64+
vm.selectedFieldTypes = $scope.model.value.fieldTypes;
6765

6866
bindValues();
6967
});
@@ -72,21 +70,21 @@
7270
});
7371

7472
// table rows selection
75-
vm.selectFieldType = function (fieldTypeId) {
76-
vm.selectedFieldTypes.push(fieldTypeId);
73+
vm.selectFieldType = function (fieldType) {
74+
vm.selectedFieldTypes.push(fieldType);
7775
}
7876

7977
vm.unselectFieldType = function (fieldTypeId) {
80-
vm.selectedFieldTypes = vm.selectedFieldTypes.filter(id => fieldTypeId != id);
78+
vm.selectedFieldTypes = vm.selectedFieldTypes.filter(obj => obj.fieldTypeId != fieldTypeId);
8179
}
8280

8381
function bindValues() {
8482
selEntityTypes.options = vm.entityTypes;
8583
vm.fieldTypes = vm.selectedEntityType.fieldTypes;
8684

87-
if ($scope.model.value.displayFieldTypeIds != null) {
88-
$scope.model.value.displayFieldTypeIds.forEach(fieldTypeId => {
89-
umbracoCmsIntegrationsPimInriverService.waitForElement("#tr" + fieldTypeId)
85+
if ($scope.model.value.fieldTypes != null) {
86+
$scope.model.value.fieldTypes.forEach(obj => {
87+
umbracoCmsIntegrationsPimInriverService.waitForElement("#tr" + obj.fieldTypeId)
9088
.then(element => element.setAttribute("selected", ""));
9189
});
9290
}

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/entitypicker.controller.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
if (vm.configuration.entityType == undefined
1515
|| vm.configuration.entityType.length == 0
16-
|| vm.configuration.displayFieldTypeIds == null
17-
|| vm.configuration.displayFieldTypeIds.length == 0) {
16+
|| vm.configuration.fieldTypes == null
17+
|| vm.configuration.fieldTypes.length == 0) {
1818
vm.error = "Invalid Inriver configuration";
1919
return;
2020
}
@@ -25,11 +25,11 @@
2525

2626
vm.openInriverEntityPickerOverlay = function () {
2727
var options = {
28-
title: "Inriver Entities",
29-
subtitle: "Select entity",
28+
title: "Inriver " + $scope.model.config.configuration.entityType,
29+
subtitle: "Select a " + $scope.model.config.configuration.entityType,
3030
configuration: {
3131
entityType: $scope.model.config.configuration.entityType,
32-
displayFieldTypeIds: $scope.model.config.configuration.displayFieldTypeIds
32+
fieldTypes: $scope.model.config.configuration.fieldTypes
3333
},
3434
view: "/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/views/entitypickereditor.html",
3535
size: "medium",
@@ -48,7 +48,7 @@
4848
vm.saveEntity = function (entityId) {
4949
$scope.model.value = JSON.stringify({
5050
entityId: entityId,
51-
displayFields: $scope.model.config.configuration.displayFieldTypeIds
51+
displayFields: $scope.model.config.configuration.fieldTypes
5252
});
5353

5454
getEntityData(entityId);
@@ -63,7 +63,8 @@
6363
umbracoCmsIntegrationsPimInriverResource.fetchEntityData(entityId).then(function (response) {
6464
if (response.success) {
6565
vm.selectedEntity = response.data[0];
66-
vm.selectedEntity.detail = $scope.model.config.configuration.displayFieldTypeIds.join(",");
66+
vm.selectedEntity.detail = $scope.model.config.configuration.fieldTypes
67+
.map(obj => obj.fieldTypeDisplayName).join(",");
6768
} else
6869
vm.error = response.error;
6970
});

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/entitypickereditor.controller.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
vm.pagination = {
1414
pageNumber: 1,
15-
itemsPerPage: 3,
15+
itemsPerPage: 5,
1616
totalPages: 1
1717
};
1818

1919
query();
2020

21-
vm.search = () => {
21+
vm.search = () => {
2222
if (inSearch.length == 0) return false;
2323

24-
let filteredArr = vm.entities.filter(obj => obj.displayName.includes(inSearch.value));
24+
let filteredArr = vm.entities.filter(obj => obj.summary.displayName.includes(inSearch.value));
2525
vm.filteredEntities = filteredArr
2626
.slice((paginationCtrl.current - 1) * vm.pagination.itemsPerPage, paginationCtrl.current * vm.pagination.itemsPerPage);
2727

@@ -47,26 +47,30 @@
4747
function query() {
4848

4949
var entityTypeId = $scope.model.configuration.entityType;
50-
var fieldTypeIds = $scope.model.configuration.displayFieldTypeIds.join(',');
50+
var fieldTypes = $scope.model.configuration.fieldTypes;
5151

5252
vm.loading = true;
53-
umbracoCmsIntegrationsPimInriverResource.query(entityTypeId, fieldTypeIds).then(function (response) {
54-
53+
umbracoCmsIntegrationsPimInriverResource.query(entityTypeId, fieldTypes).then(function (response) {
5554
if (response.success) {
5655
vm.entities = response.data.map(obj => {
5756
return {
5857
id: obj.entityId,
59-
displayName: obj.summary.displayName,
60-
description: obj.summary.description,
61-
displayFields: obj.fieldValues
62-
};
58+
summary: obj.summary,
59+
fields: obj.fieldValues.map(fieldObj => {
60+
return {
61+
fieldType: fieldTypes.find(fieldTypeObj => fieldTypeObj.fieldTypeId === fieldObj.fieldTypeId).fieldTypeDisplayName,
62+
value: fieldObj.value
63+
}
64+
})
65+
}
6366
});
6467

6568
vm.pagination.totalPages = Math.ceil(vm.entities.length / vm.pagination.itemsPerPage);
6669

6770
vm.filteredEntities = vm.entities.slice(0, vm.pagination.itemsPerPage);
6871

6972
registerListeners();
73+
7074
} else
7175
notificationsService.error("Inriver", response.error);
7276

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/js/inriver.resource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
return umbRequestHelper.resourcePromise(
1414
$http.get(`${apiEndpoint}/GetEntityTypes`), "Failed to access resource.")
1515
},
16-
query: function (entityTypeId, fieldTypeIds) {
16+
query: function (entityTypeId, fieldTypes) {
1717
return umbRequestHelper.resourcePromise(
1818
$http.post(`${apiEndpoint}/Query`, {
1919
entityTypeId: entityTypeId,
20-
fieldTypeIds: fieldTypeIds
20+
fieldTypes: fieldTypes
2121
}), "Failed to access resource.")
2222
},
2323
fetchData: function (request) {

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/views/configuration.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
<uui-table-row id="tr{{fieldType.fieldTypeId}}"
2929
ng-repeat="fieldType in vm.fieldTypes" selectable
30-
ng-on-selected="vm.selectFieldType(fieldType.fieldTypeId)"
30+
ng-on-selected="vm.selectFieldType(fieldType)"
3131
ng-on-unselected="vm.unselectFieldType(fieldType.fieldTypeId)">
3232
<uui-table-cell>{{fieldType.fieldTypeId}}</uui-table-cell>
3333
<uui-table-cell>{{fieldType.fieldTypeDisplayName}}</uui-table-cell>
@@ -38,9 +38,4 @@
3838
</div>
3939
</uui-card-content-node>
4040
</uui-icon-registry-essential>
41-
</div>
42-
43-
44-
<!-- Notifications -->
45-
<uui-toast-notification-container bottom-up="">
46-
</uui-toast-notification-container>
41+
</div>

src/Umbraco.Cms.Integrations.PIM.Inriver/App_Plugins/UmbracoCms.Integrations/PIM/Inriver/views/entitypickereditor.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
<uui-table-head>
2020
<uui-table-head-cell>Name</uui-table-head-cell>
2121
<uui-table-head-cell>Description</uui-table-head-cell>
22-
<uui-table-head-cell ng-repeat="displayField in vm.filteredEntities[0].displayFields">{{displayField.fieldTypeId}}</uui-table-head-cell>
22+
<uui-table-head-cell ng-repeat="field in vm.filteredEntities[0].fields">
23+
{{field.fieldType}}
24+
</uui-table-head-cell>
2325
</uui-table-head>
2426

2527
<uui-table-row ng-repeat="entity in vm.filteredEntities" selectable
2628
ng-on-selected="vm.save(entity.id)">
27-
<uui-table-cell>{{entity.displayName}}</uui-table-cell>
28-
<uui-table-cell>{{entity.description}}</uui-table-cell>
29-
<uui-table-cell ng-repeat="displayField in entity.displayFields">
30-
{{displayField.value | date : "dd.MM.y HH:mm"}}
29+
<uui-table-cell>{{entity.summary.displayName}}</uui-table-cell>
30+
<uui-table-cell>{{entity.summary.displayDescription}}</uui-table-cell>
31+
<uui-table-cell ng-repeat="field in entity.fields">
32+
{{field.value | date : "dd.MM.y HH:mm"}}
3133
</uui-table-cell>
3234
</uui-table-row>
3335
</uui-table>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
using Newtonsoft.Json;
22

3+
using Umbraco.Cms.Integrations.PIM.Inriver.Models;
4+
35
namespace Umbraco.Cms.Integrations.PIM.Inriver.Configuration
46
{
57
public class EditorSettings
68
{
79
[JsonProperty("entityType")]
810
public string EntityType { get; set; } = string.Empty;
911

10-
[JsonProperty("displayFieldTypeIds")]
11-
public string[] DisplayFieldTypeIds { get; set; }
12+
[JsonProperty("fieldTypes")]
13+
public FieldType[] FieldTypes { get; set; }
1214
}
1315
}

src/Umbraco.Cms.Integrations.PIM.Inriver/Controllers/EntityController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task<IActionResult> Query([FromBody] QueryRequest request)
5353
var dataResult = await _inriverService.FetchData(new FetchDataRequest
5454
{
5555
EntityIds = result.Data.EntityIds,
56-
FieldTypeIds = request.FieldTypeIds
56+
FieldTypeIds = string.Join(",", request.FieldTypes.Select(p => p.Id))
5757
});
5858

5959
return new JsonResult(dataResult);

src/Umbraco.Cms.Integrations.PIM.Inriver/Editors/EntityPickerValueConverter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPub
4040
var fetchDataResponse = _inriverService.FetchData(new FetchDataRequest
4141
{
4242
EntityIds = new[] { entityId },
43-
FieldTypeIds = string.Join(",", displayFields.Select(p => p.GetValue<string>()))
43+
FieldTypeIds = string.Join(",", displayFields.Select(p => p["fieldTypeId"].GetValue<string>()))
4444
}).ConfigureAwait(false).GetAwaiter().GetResult();
4545

4646
if (fetchDataResponse.Failure) return null;
@@ -52,7 +52,9 @@ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPub
5252
{
5353
DisplayName = entityData.Summary.DisplayName,
5454
DisplayDescription = entityData.Summary.Description,
55-
Fields = entityData.Fields.ToDictionary(x => x.FieldTypeId, x => x.Value)
55+
Fields = entityData.Fields.ToDictionary(
56+
x => displayFields.First(p => p["fieldTypeId"].GetValue<string>() == x.FieldTypeId)["fieldTypeDisplayName"].GetValue<string>(),
57+
x => x.Value)
5658
};
5759

5860
return vm;

src/Umbraco.Cms.Integrations.PIM.Inriver/Models/EntityType.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Umbraco.Cms.Integrations.PIM.Inriver.Models
54
{

0 commit comments

Comments
 (0)