Support start node IDs for media picker in infinite editing

This commit is contained in:
Kenn Jacobsen
2019-01-29 20:55:38 +01:00
committed by Sebastiaan Janssen
parent f8fd255239
commit f2e1978ddb

View File

@@ -1,6 +1,6 @@
//this controller simply tells the dialogs service to open a mediaPicker window
//with a specified callback, this callback will receive an object with a selection on it
function mediaPickerController($scope, entityResource, iconHelper, editorService) {
function mediaPickerController($scope, entityResource, iconHelper, editorService, angularHelper) {
function trim(str, chr) {
var rgxtrim = (!chr) ? new RegExp('^\\s+|\\s+$', 'g') : new RegExp('^' + chr + '+|' + chr + '+$', 'g');
@@ -50,10 +50,12 @@ function mediaPickerController($scope, entityResource, iconHelper, editorService
$scope.remove =function(index){
$scope.renderModel.splice(index, 1);
syncModelValue();
};
$scope.clear = function() {
$scope.renderModel = [];
syncModelValue();
};
$scope.add = function (item) {
@@ -76,19 +78,17 @@ function mediaPickerController($scope, entityResource, iconHelper, editorService
});
}
syncModelValue();
};
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
function syncModelValue() {
var currIds = _.map($scope.renderModel, function (i) {
return dialogOptions.idType === "udi" ? i.udi : i.id;
});
$scope.model.value = trim(currIds.join(), ",");
});
//when the scope is destroyed we need to unsubscribe
$scope.$on('$destroy', function () {
unsubscribe();
});
angularHelper.getCurrentForm($scope).$setDirty();
}
//load media data
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];