diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index f8a8f72a2e..1dc0896433 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -204,17 +204,38 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); //get our angular navigation service var injector = getRootInjector(); + var navService = injector.get("navigationService"); var dialogService = injector.get("dialogService"); var self = this; - var dialog = dialogService.open({ - template: url, - width: width, - height: height, - iframe: true, - show: true - }); + //based on what state the nav ui is in, depends on how we are going to launch a model / dialog. A modal + // will show up on the right hand side and a dialog will show up as if it is in the menu. + // with the legacy API we cannot know what is expected so we can only check if the menu is active, if it is + // we'll launch a dialog, otherwise a modal. + var dialog; + if (navService.ui.currentMode === "menu") { + dialog = navService.showDialog({ + //create a 'fake' action to passin with the specified actionUrl since it needs to load into an iframe + action: { + name: name, + metaData: { + actionUrl: url + } + }, + node: {} + }); + } + else { + dialog = dialogService.open({ + template: url, + width: width, + height: height, + iframe: true, + 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.element.data("modalCb", onCloseCallback); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js index b7e66b21eb..03c2598c79 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js @@ -18,15 +18,32 @@ angular.module('umbraco.services') .factory('navigationService', function ($rootScope, $routeParams, $log, $location, $q, $timeout, dialogService, treeService, notificationsService) { - - - //TODO: would be nicer to set all of the options here first instead of implicitly below! - var ui = {}; + + //Define all sub-properties for the UI object here + var ui = { + showNavigation: false, + showContextMenu: false, + showContextMenuDialog: false, + stickyNavigation: false, + showTray: false, + showSearchResults: false, + currentSection: undefined, + currentPath: undefined, + currentTree: undefined, + currentNode: undefined, + actions: undefined, + currentDialog: undefined, + dialogTitle: undefined, + //a string/name reference for the currently set ui mode + currentMode: "default" + }; + $rootScope.$on("closeDialogs", function(){}); function setMode(mode) { switch (mode) { case 'tree': + ui.currentMode = "tree"; ui.showNavigation = true; ui.showContextMenu = false; ui.showContextMenuDialog = false; @@ -37,18 +54,21 @@ angular.module('umbraco.services') //$("#search-form input").focus(); break; case 'menu': + ui.currentMode = "menu"; ui.showNavigation = true; ui.showContextMenu = true; ui.showContextMenuDialog = false; ui.stickyNavigation = true; break; case 'dialog': + ui.currentMode = "dialog"; ui.stickyNavigation = true; ui.showNavigation = true; ui.showContextMenu = false; ui.showContextMenuDialog = true; break; case 'search': + ui.currentMode = "search"; ui.stickyNavigation = false; ui.showNavigation = true; ui.showContextMenu = false; @@ -61,6 +81,7 @@ angular.module('umbraco.services') break; default: + ui.currentMode = "default"; ui.showNavigation = false; ui.showContextMenu = false; ui.showContextMenuDialog = false; @@ -73,7 +94,6 @@ angular.module('umbraco.services') var service = { active: false, - mode: "default", touchDevice: false, userDialog: undefined, ui: ui, diff --git a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs index af55925055..74fa910cad 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs @@ -153,6 +153,7 @@ namespace Umbraco.Web.Trees //First try to get a URL/title from the legacy action, // if that doesn't work, try to get the legacy confirm view + // if that doesn't work and there's no jsAction in there already then add the legacy js method call Attempt .Try(GetUrlAndTitleFromLegacyAction(currentAction, xmlTreeNode.NodeID, xmlTreeNode.NodeType, xmlTreeNode.Text, currentSection), action => menuItem.LaunchDialogUrl(action.Url, action.DialogTitle)) @@ -160,7 +161,10 @@ namespace Umbraco.Web.Trees view => menuItem.LaunchDialogView( view, ui.GetText("defaultdialogs", "confirmdelete") + " '" + xmlTreeNode.Text + "' ?")) - .OnFailure(() => Attempt.Succeed(true), b => menuItem.LaunchLegacyJs(menuItem.Action.JsFunctionName)); + .OnFailure(() => menuItem.AdditionalData.ContainsKey(MenuItemExtensions.JsActionKey) + ? Attempt.Fail(false) + : Attempt.Succeed(true), + b => menuItem.LaunchLegacyJs(menuItem.Action.JsFunctionName)); numAdded++; }