tellform/public/form_modules/forms/config/forms.client.routes.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-09 03:32:33 +00:00
'use strict';
// Setting up route
angular.module('view-form').config(['$stateProvider',
function($stateProvider) {
// Forms state routing
$stateProvider.
state('submitForm', {
url: '/forms/:formId',
templateUrl: '/static/form_modules/forms/base/views/submit-form.client.view.html',
resolve: {
Forms: 'Forms',
myForm: function (Forms, $q, $state, $stateParams) {
var deferred = $q.defer();
2017-09-21 06:08:45 +00:00
Forms.get({formId: $stateParams.formId}).$promise.then(function(data) {
deferred.resolve(data);
}, function(reason) {
$state.go('unauthorizedFormAccess');
2017-09-21 06:08:45 +00:00
deferred.reject({redirectTo: 'unauthorizedFormAccess'});
});
return deferred.promise;
2016-06-09 03:32:33 +00:00
}
},
controller: 'SubmitFormController',
controllerAs: 'ctrl'
}).
state('unauthorizedFormAccess', {
url: '/forms/unauthorized',
2017-10-07 07:27:03 +00:00
templateUrl: '/static/form_modules/forms/base/views/form-unauthorized.client.view.html'
})
.state('formNotFound', {
url: '*path',
templateUrl: '/static/form_modules/forms/base/views/form-not-found.client.view.html'
});
}
2016-06-09 03:32:33 +00:00
]);