only sort lists with more than one item
This commit is contained in:
@@ -39,6 +39,9 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
else {
|
||||
$scope.contentPickerForm.maxCount.$setValidity("maxCount", true);
|
||||
}
|
||||
|
||||
setSortingState($scope.renderModel);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,6 +62,14 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
}
|
||||
};
|
||||
|
||||
// sortable options
|
||||
$scope.sortableOptions = {
|
||||
distance: 10,
|
||||
tolerance: "pointer",
|
||||
scroll: true,
|
||||
zIndex: 6000
|
||||
};
|
||||
|
||||
if ($scope.model.config) {
|
||||
//merge the server config on top of the default config, then set the server config to use the result
|
||||
$scope.model.config = angular.extend(defaultConfig, $scope.model.config);
|
||||
@@ -78,7 +89,6 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
$scope.allowOpenButton = entityType === "Document" || entityType === "Media";
|
||||
$scope.allowEditButton = entityType === "Document";
|
||||
$scope.allowRemoveButton = true;
|
||||
$scope.sortable = true;
|
||||
|
||||
//the dialog options for the picker
|
||||
var dialogOptions = {
|
||||
@@ -287,6 +297,15 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
}
|
||||
|
||||
function setSortingState(items) {
|
||||
// disable sorting if the list only consist of one item
|
||||
if(items.length > 1) {
|
||||
$scope.sortableOptions.disabled = false;
|
||||
} else {
|
||||
$scope.sortableOptions.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.ContentPickerController", contentPickerController);
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
<ng-form name="contentPickerForm">
|
||||
|
||||
<div ui-sortable ng-model="renderModel">
|
||||
<div ui-sortable="sortableOptions" ng-model="renderModel">
|
||||
<umb-node-preview
|
||||
ng-repeat="node in renderModel"
|
||||
icon="node.icon"
|
||||
name="node.name"
|
||||
published="node.published"
|
||||
description="node.url"
|
||||
sortable="sortable"
|
||||
sortable="!sortableOptions.disabled"
|
||||
allow-remove="allowRemoveButton"
|
||||
allow-open="model.config.showOpenButton && allowOpenButton && !dialogEditor"
|
||||
on-remove="remove($index)"
|
||||
|
||||
Reference in New Issue
Block a user