From 893f86d34cbc40539896f65cf50f0ec6fdd237c6 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 5 Mar 2014 12:57:44 +1100 Subject: [PATCH] Fixes installer service so that when forward is called and there are no more views to show the installer will automatically start. This will occur in cases where we are customizing the install but we don't want a starter kit installed since the server has detected that one has already been installed. This also prevents some JS errors and will improve the installer in the future if there might be more views. --- .../src/installer/installer.service.js | 46 +++++++++++++------ .../installer/steps/starterkit.controller.js | 18 ++++---- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/installer/installer.service.js b/src/Umbraco.Web.UI.Client/src/installer/installer.service.js index 7abde9262a..7873c57f65 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/installer.service.js +++ b/src/Umbraco.Web.UI.Client/src/installer/installer.service.js @@ -14,7 +14,7 @@ angular.module("umbraco.install").factory('installerService', function($q, $time } }; - /* + /** Returns the description for the step at a given index based on the order of the serverOrder of steps Since they don't execute on the server in the order that they are displayed in the UI. */ @@ -105,6 +105,10 @@ angular.module("umbraco.install").factory('installerService', function($q, $time service.status.current = step; }, + /** + Finds the next step containing a view. If one is found it stores it as the current step + and retreives the step information and returns it, otherwise returns null . + */ findNextStep : function(){ var step = _.find(service.status.steps, function(s, index){ if(s.view && index >= service.status.index){ @@ -114,20 +118,29 @@ angular.module("umbraco.install").factory('installerService', function($q, $time return false; }); - if(step.view.indexOf(".html") < 0){ - step.view = step.view + ".html"; - } + if (step) { + if (step.view.indexOf(".html") < 0) { + step.view = step.view + ".html"; + } - if(step.view.indexOf("/") < 0){ - step.view = "views/install/" + step.view; - } + if (step.view.indexOf("/") < 0) { + step.view = "views/install/" + step.view; + } - if(!step.model){ - step.model = {}; - } + if (!step.model) { + step.model = {}; + } - service.status.current = step; - service.retrieveCurrentStep(); + service.status.current = step; + service.retrieveCurrentStep(); + + //returns the next found step + return step; + } + else { + //there are no more steps found containing a view so return null + return null; + } }, storeCurrentStep : function(){ @@ -136,14 +149,19 @@ angular.module("umbraco.install").factory('installerService', function($q, $time retrieveCurrentStep : function(){ if(_installerModel.instructions[service.status.current.name]){ - service.status.current.model = _installerModel.instructions[service.status.current.name]; + service.status.current.model = _installerModel.instructions[service.status.current.name]; } }, + /** Moves the installer forward to the next view, if there are not more views than the installation will commence */ forward : function(){ service.storeCurrentStep(); service.status.index++; - service.findNextStep(); + var found = service.findNextStep(); + if (!found) { + //no more steps were found so start the installation process + service.install(); + } }, backwards : function(){ diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/starterkit.controller.js b/src/Umbraco.Web.UI.Client/src/installer/steps/starterkit.controller.js index a70e9cd809..bc1604354c 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/steps/starterkit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/starterkit.controller.js @@ -1,11 +1,11 @@ -angular.module("umbraco.install").controller("Umbraco.Installer.PackagesController", function($scope, installerService){ - - installerService.getPackages().then(function(response){ - $scope.packages = response.data; - }); +angular.module("umbraco.install").controller("Umbraco.Installer.PackagesController", function ($scope, installerService) { + + installerService.getPackages().then(function (response) { + $scope.packages = response.data; + }); + + $scope.setPackageAndContinue = function (pck) { + installerService.forward(); + }; - $scope.setPackageAndContinue = function(package){ - - installerService.install(); - }; }); \ No newline at end of file