Fixes: U4-2777 Get legacy tree pickers working - calls the close callback by inside of the umb client mgr instead of having to modify the dialogservice, this works well for legacy pickers.

This commit is contained in:
Shannon
2013-09-10 17:58:59 +10:00
parent 404062b4d0
commit 8d83dc462d
4 changed files with 28 additions and 43 deletions

View File

@@ -179,9 +179,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
//get our angular navigation service
var injector = getRootInjector();
var dialogService = injector.get("dialogService");
var self = this;
//TODO: need to get the closeTriggers working for compatibility too somehow.
var dialog = dialogService.open({
@@ -189,17 +187,12 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
width: width,
height: height,
iframe: true,
show: true,
callback: function (result) {
if (typeof onCloseCallback == "function") {
onCloseCallback.apply(self, [result]);
}
dialog.hide();
}
show: true
});
//add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked.
dialog.data("modalCb", onCloseCallback);
this._modal.push(dialog);
return dialog;
@@ -213,7 +206,17 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
// all legacy calls to closeModalWindow are expecting to just close the last opened one so we'll ensure
// that this is still the case.
if (this._modal != null && this._modal.length > 0) {
dialogService.close(this._modal.pop(), { outVal: rVal });
var lastModal = this._modal.pop();
//if we've stored a callback on this modal call it before we close.
var self = this;
var onCloseCallback = lastModal.data("modalCb");
if (typeof onCloseCallback == "function") {
onCloseCallback.apply(self, [{ outVal: rVal }]);
}
dialogService.close(lastModal);
}
else {
dialogService.closeAll(rVal);

View File

@@ -34,26 +34,16 @@ angular.module('umbraco.services')
var dialogs = [];
/** Internal method that removes all dialogs */
function removeAllDialogs(args) {
function removeAllDialogs() {
for (var i = 0; i < dialogs.length; i++) {
var dialog = dialogs[i];
removeDialog(dialog, args);
removeDialog(dialog);
dialogs.splice(i, 1);
}
}
/** Internal method that handles closing a specific dialog */
function removeDialog(dialog, args) {
//if there's arguments passed in then check if there's a callback registered in the current modal then call it.
//this occurs when the "closeDialogs" event is triggered with arguments.
/* PP: I've commented this out again, because I dont believe a modal should
submit data on exit, only on submit
if (args && dialog.data("modalCb") != null && angular.isFunction(dialog.data("modalCb"))) {
var cb = dialog.data("modalCb");
cb.apply(dialog, [args]);
}*/
function removeDialog(dialog) {
dialog.modal("hide");
@@ -123,10 +113,7 @@ angular.module('umbraco.services')
if (options.show) {
$modal.modal('show');
}
//store the callback in the modal jquery data
$modal.data("modalCb", callback);
return $modal;
}
else {
@@ -144,10 +131,7 @@ angular.module('umbraco.services')
//append to body or other container element
container.append($modal);
//store the callback in the modal jquery data
$modal.data("modalCb", callback);
// Compile modal content
$timeout(function() {
$compile($modal)(scope);
@@ -223,7 +207,7 @@ angular.module('umbraco.services')
/** Handles the closeDialogs event */
$rootScope.$on("closeDialogs", function (evt, args) {
removeAllDialogs(args);
removeAllDialogs();
});
return {
@@ -260,10 +244,9 @@ angular.module('umbraco.services')
* @description
* Closes a specific dialog
* @param {Object} dialog the dialog object to close
* @param {Object} args if specified this object will be sent to any callbacks registered on the dialogs.
*/
close: function (dialog, args) {
removeDialog(dialog, args);
close: function (dialog) {
removeDialog(dialog);
},
/**
@@ -273,10 +256,9 @@ angular.module('umbraco.services')
*
* @description
* Closes all dialogs
* @param {Object} args if specified this object will be sent to any callbacks registered on the dialogs.
*/
closeAll: function(args) {
removeAllDialogs(args);
closeAll: function() {
removeAllDialogs();
},
/**