Make sure media picker items are sortable (#6037)
(cherry picked from commit 6da0caa902)
This commit is contained in:
committed by
Sebastiaan Janssen
parent
3294137006
commit
089e450e09
@@ -149,14 +149,6 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
|
||||
$scope.allowAddMedia = hasAccessToMedia;
|
||||
|
||||
setupViewModel();
|
||||
|
||||
//When the model value changes sync the view model
|
||||
$scope.$watch("model.value",
|
||||
function (newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
setupViewModel();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -241,25 +233,25 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.sortableOptions = {
|
||||
containment: 'parent',
|
||||
cursor: 'move',
|
||||
tolerance: 'pointer',
|
||||
disabled: !multiPicker,
|
||||
items: "li:not(.add-wrapper)",
|
||||
cancel: ".unsortable",
|
||||
update: function (e, ui) {
|
||||
setDirty();
|
||||
var r = [];
|
||||
// TODO: Instead of doing this with a half second delay would be better to use a watch like we do in the
|
||||
// content picker. Then we don't have to worry about setting ids, render models, models, we just set one and let the
|
||||
// watch do all the rest.
|
||||
$timeout(function () {
|
||||
angular.forEach($scope.mediaItems, function (value, key) {
|
||||
r.push($scope.model.config.idType === "udi" ? value.udi : value.id);
|
||||
});
|
||||
$scope.ids = r;
|
||||
$timeout(function() {
|
||||
// TODO: Instead of doing this with a timeout would be better to use a watch like we do in the
|
||||
// content picker. Then we don't have to worry about setting ids, render models, models, we just set one and let the
|
||||
// watch do all the rest.
|
||||
$scope.ids = _.map($scope.mediaItems,
|
||||
function (item) {
|
||||
return $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
});
|
||||
sync();
|
||||
}, 500, false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user