make launch mini editor service return a promise so we can update a node when it is saved

This commit is contained in:
Mads Rasmussen
2017-01-18 14:50:51 +01:00
parent 40ea54007f
commit 1fd98dba30
2 changed files with 21 additions and 2 deletions

View File

@@ -1,12 +1,14 @@
(function () {
'use strict';
function miniEditorHelper(dialogService, editorState, fileManager, contentEditingHelper) {
function miniEditorHelper(dialogService, editorState, fileManager, contentEditingHelper, $q) {
var launched = false;
function launchMiniEditor(node) {
var deferred = $q.defer();
launched = true;
//We need to store the current files selected in the file manager locally because the fileManager
@@ -47,6 +49,9 @@
}
launched = false;
deferred.resolve(data);
},
closeCallback: function () {
//reset the fileManager to what it was
@@ -59,9 +64,14 @@
editorState.set(currEditorState);
launched = false;
deferred.reject();
}
});
return deferred.promise;
}
var service = {

View File

@@ -213,7 +213,16 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
};
$scope.openMiniEditor = function(node) {
miniEditorHelper.launchMiniEditor(node);
miniEditorHelper.launchMiniEditor(node).then(function(updatedNode){
// update the node
node.name = updatedNode.name;
node.published = updatedNode.hasPublishedVersion;
if(entityType !== "Member") {
entityResource.getUrl(updatedNode.id, entityType).then(function(data){
node.url = data;
});
}
});
};
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {