'use strict';

angular.module('confRegistrationWebApp')
  .controller('AdminWizardCtrl', function ($scope, $dialog, conference, Model, GrowlService) {
    Model.subscribe($scope, 'conference', 'conferences/' + conference.id);

    $scope.deletePage = function (pageId, confirmation) {
      if (confirmation) {
        var delPageIndex = _.findIndex($scope.conference.registrationPages, { id: pageId });
        var pageTitle = $scope.conference.registrationPages[delPageIndex].title;
        GrowlService.growl('conferences/' + $scope.conference.id,
          $scope.conference, 'Page "' + pageTitle + '" has been deleted.');
        $scope.deletePageFromConf(pageId);
      } else {
        $scope.deletePageFromConf(pageId);
      }
    };

    $scope.deletePageFromConf = function (pageId) {
      var delPageIndex = _.findIndex($scope.conference.registrationPages, { id: pageId });
      $scope.conference.registrationPages.splice(
        delPageIndex,
        1
      );
    };
  });

@@ -262,28 +262,21 @@
 pageId, 
-confirmation
+growl
 ) %7B%0A    
@@ -285,20 +285,13 @@
 if (
-confirmation
+growl
 ) %7B%0A
@@ -298,36 +298,28 @@
         var 
-delPageIndex
+page
  = _.findInd
@@ -307,37 +307,32 @@
 ar page = _.find
-Index
 ($scope.conferen
@@ -346,33 +346,32 @@
 strationPages, %7B
- 
 id: pageId %7D);%0A 
@@ -356,33 +356,32 @@
 ges, %7Bid: pageId
- 
 %7D);%0A        var 
@@ -384,75 +384,63 @@
 var 
-pageTitle = $scope.conference.registrationPages%5BdelPageIndex%5D.title
+message = 'Page %22' + page.title + '%22 has been deleted.'
 ;%0A  
@@ -506,18 +506,8 @@
 .id,
-%0A         
  $sc
@@ -526,115 +526,26 @@
 ce, 
-'Page %22' + pageTitle + '%22 has been deleted.');%0A        $scope.deletePageFromConf(pageId);%0A      %7D else %7B%0A  
+message);%0A      %7D%0A
     
@@ -581,24 +581,16 @@
 ageId);%0A
-      %7D%0A
     %7D;%0A%0A
@@ -781,25 +781,16 @@
 .splice(
-%0A        
 delPageI
@@ -798,25 +798,10 @@
 dex,
-%0A        1%0A     
  
+1
 );%0A 

Clean up