Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* The controller that is used for a couple different Property Editors: Multi Node Tree Picker, Content Picker,
* since this is used by MNTP and it supports content, media and members, there is code to deal with all 3 of those types
Expand Down Expand Up @@ -345,17 +344,24 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso

};

$scope.remove = function (index) {
$scope.remove = function (id) {
if (!$scope.allowRemove) return;

var currIds = $scope.model.value ? $scope.model.value.split(',') : [];
if (currIds.length > 0) {
currIds.splice(index, 1);
setDirty();
$scope.model.value = currIds.join();
var currUdis = $scope.model.value ? $scope.model.value.split(',') : [];
if (currUdis.length > 0) {

// Remove the node with the provided UDI.
var index = currUdis.indexOf(id.toString()); // id may be an integer ID or a UDI string, split() always returns strings.
if (index >= 0) {
currUdis.splice(index, 1);
setDirty();

// If no ids left, set value to null to match `clear()` behavior.
$scope.model.value = currUdis.length > 0 ? currUdis.join() : null;
}
}

removeAllEntriesAction.isDisabled = currIds.length === 0;
removeAllEntriesAction.isDisabled = currUdis.length === 0;
};

$scope.showNode = function (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
sortable="!sortableOptions.disabled"
allow-remove="allowRemove"
allow-open="model.config.showOpenButton && allowOpen && !dialogEditor"
on-remove="remove($index)"
on-remove="remove(model.config.idType === 'udi' ? node.udi : node.id)"
on-open="openEditor(node)">
</umb-node-preview>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Content picker controller tests', function () {
});

it("Removing an item should update renderModel, ids and model.value", function(){
scope.remove(1);
scope.remove(1231);
scope.$apply();
expect(scope.renderModel.length).toBe(2);
expect(scope.model.value).toBe("1233,23121");
Expand Down
Loading