From 12e1fd0947c65b3ce685cbafdced08f9e9be0185 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Tue, 31 Oct 2017 12:28:01 -0700 Subject: [PATCH] got static url for admin tabs to work --- app/views/index.server.view.pug | 2 + .../modules/core/config/core.client.routes.js | 4 +- .../admin-form.client.controller.js | 54 +++++++++---- .../admin/views/admin-form.client.view.html | 11 +-- .../respondent-notifications.html | 79 +------------------ .../edit-submissions-form.client.view.html | 2 +- .../form/share-form.client.view.html | 2 +- 7 files changed, 50 insertions(+), 104 deletions(-) diff --git a/app/views/index.server.view.pug b/app/views/index.server.view.pug index 10c29935..c7213641 100644 --- a/app/views/index.server.view.pug +++ b/app/views/index.server.view.pug @@ -42,6 +42,8 @@ block content script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/angular-strap/2.3.8/angular-strap.min.js') + script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js") + //Application JavaScript Files each jsFile in jsFiles script(type='text/javascript', src=jsFile) diff --git a/public/modules/core/config/core.client.routes.js b/public/modules/core/config/core.client.routes.js index 22294347..010d9648 100755 --- a/public/modules/core/config/core.client.routes.js +++ b/public/modules/core/config/core.client.routes.js @@ -19,9 +19,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope' $state.previous = fromState; var statesToIgnore = ['home', 'signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success']; - - console.log(fromState); - console.log(toState); + //Redirect to listForms if user is authenticated if(statesToIgnore.indexOf(toState.name) > 0){ if(Auth.isAuthenticated()){ diff --git a/public/modules/forms/admin/controllers/admin-form.client.controller.js b/public/modules/forms/admin/controllers/admin-form.client.controller.js index 82a0be1a..ec657e2c 100644 --- a/public/modules/forms/admin/controllers/admin-form.client.controller.js +++ b/public/modules/forms/admin/controllers/admin-form.client.controller.js @@ -4,19 +4,12 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$window', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$uibModal', 'myForm', '$filter', '$translate', function($rootScope, $window, $scope, $stateParams, $state, Forms, CurrentForm, $http, $uibModal, myForm, $filter, $translate) { - //Set active tab to Create - $scope.activePill = 0; - - $scope.copied = false; - $scope.onCopySuccess = function (e) { - $scope.copied = true; - }; - $scope = $rootScope; $scope.animationsEnabled = true; $scope.myform = myForm; $rootScope.saveInProgress = false; $scope.oldForm = _.cloneDeep($scope.myform); + $scope.designTabActive = false CurrentForm.setForm($scope.myform); @@ -36,7 +29,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo $scope.actualFormURL = window.location.protocol + '//' + window.location.host + $scope.formURL; } - var refreshFrame = $scope.refreshFrame = function(){ if(document.getElementById('iframe')) { document.getElementById('iframe').contentWindow.location.reload(); @@ -46,31 +38,59 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo $scope.tabData = [ { heading: $filter('translate')('CREATE_TAB'), - route: 'viewForm.create' + route: 'viewForm.create', + active: false }, { heading: $filter('translate')('CONFIGURE_TAB'), - route: 'viewForm.configure.general' + route: 'viewForm.configure.general', + active: false }, { heading: $filter('translate')('ANALYZE_TAB'), - route: 'viewForm.analyze' + route: 'viewForm.analyze', + active: false }, { heading: $filter('translate')('SHARE_TAB'), - route: 'viewForm.share' + route: 'viewForm.share', + active: false }, { heading: $filter('translate')('DESIGN_TAB'), - route: 'viewForm.design' + route: 'viewForm.design', + active: false } ]; - $scope.go = function(route){ - $state.go(route); + $scope.go = function(tab){ + $state.go(tab.route); }; - $scope.designTabActive = false + function setActiveTab() { + var start = new Date().getTime(); + $scope.tabData.forEach(function(tab) { + tab.active = ($state.current.name === tab.route); + + if(tab.active && tab.route === 'viewForm.design'){ + $scope.designTabActive = true; + } else { + $scope.designTabActive = false; + } + }); + + var end = new Date().getTime(); + var time = end - start; + console.log('Execution time: ' + time); + } + + setActiveTab(); + + $scope.$on("$stateChangeSuccess", function() { + + setActiveTab(); + + }); $scope.deactivateDesignTab = function(){ $scope.designTabActive = false diff --git a/public/modules/forms/admin/views/admin-form.client.view.html b/public/modules/forms/admin/views/admin-form.client.view.html index 15677800..ab06ba21 100644 --- a/public/modules/forms/admin/views/admin-form.client.view.html +++ b/public/modules/forms/admin/views/admin-form.client.view.html @@ -57,13 +57,14 @@
-
- - -
+
+ + - +
+
+
diff --git a/public/modules/forms/admin/views/adminTabs/configureTabs/respondent-notifications.html b/public/modules/forms/admin/views/adminTabs/configureTabs/respondent-notifications.html index 161faedb..06c2735e 100644 --- a/public/modules/forms/admin/views/adminTabs/configureTabs/respondent-notifications.html +++ b/public/modules/forms/admin/views/adminTabs/configureTabs/respondent-notifications.html @@ -1,5 +1,5 @@
-
+
{{ 'FORM_NAME' | translate }}
@@ -86,79 +86,4 @@
-
-
-
-
{{ 'GA_TRACKING_CODE' | translate }}
-
- -
- -
-
-
-
-
{{ 'DISPLAY_FOOTER' | translate }}
-
- -
- - - -
-
- -
-
-
{{ 'DISPLAY_START_PAGE' | translate }}
-
- -
- - - - - -
-
- -
-
-
{{ 'DISPLAY_END_PAGE' | translate }}
-
- -
- - - - - -
-
-
-
\ No newline at end of file +
\ No newline at end of file diff --git a/public/modules/forms/admin/views/directiveViews/form/edit-submissions-form.client.view.html b/public/modules/forms/admin/views/directiveViews/form/edit-submissions-form.client.view.html index d33d81d6..5a68b652 100644 --- a/public/modules/forms/admin/views/directiveViews/form/edit-submissions-form.client.view.html +++ b/public/modules/forms/admin/views/directiveViews/form/edit-submissions-form.client.view.html @@ -1,4 +1,4 @@ -
+
diff --git a/public/modules/forms/admin/views/directiveViews/form/share-form.client.view.html b/public/modules/forms/admin/views/directiveViews/form/share-form.client.view.html index 2312b1f8..cc795b54 100644 --- a/public/modules/forms/admin/views/directiveViews/form/share-form.client.view.html +++ b/public/modules/forms/admin/views/directiveViews/form/share-form.client.view.html @@ -1,4 +1,4 @@ -
+