From 8d83dc462d131a285f151a702df68949209b519e Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 10 Sep 2013 17:58:59 +1000 Subject: [PATCH] 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. --- .../lib/umbraco/LegacyUmbClientMgr.js | 29 +++++++------- .../src/common/services/dialog.service.js | 38 +++++-------------- .../MarkdownEditor/package.manifest | 2 +- src/Umbraco.Web.UI/config/trees.config | 2 +- 4 files changed, 28 insertions(+), 43 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index f3f58c7446..55633ca86a 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -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); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js index 3cac289133..067ec19cf9 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js @@ -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(); }, /** diff --git a/src/Umbraco.Web.UI/App_Plugins/MarkdownEditor/package.manifest b/src/Umbraco.Web.UI/App_Plugins/MarkdownEditor/package.manifest index dc3c7bb77b..fa7be19e47 100644 --- a/src/Umbraco.Web.UI/App_Plugins/MarkdownEditor/package.manifest +++ b/src/Umbraco.Web.UI/App_Plugins/MarkdownEditor/package.manifest @@ -6,7 +6,7 @@ editor: { view: "~/App_Plugins/MarkDownEditor/markdowneditor.html" }, - preValueEditor: { + prevalues: { fields: [ { label: "Preview", diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config index c3f973faac..31c14e00ad 100644 --- a/src/Umbraco.Web.UI/config/trees.config +++ b/src/Umbraco.Web.UI/config/trees.config @@ -38,5 +38,5 @@ + iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="10" />--> \ No newline at end of file