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',
|
2017-07-25 22:08:25 +00:00
|
|
|
myForm: function (Forms, $q, $state, $stateParams) {
|
|
|
|
var deferred = $q.defer();
|
2017-10-02 10:18:47 +00:00
|
|
|
|
2017-09-21 06:08:45 +00:00
|
|
|
Forms.get({formId: $stateParams.formId}).$promise.then(function(data) {
|
|
|
|
deferred.resolve(data);
|
2017-10-02 10:18:47 +00:00
|
|
|
}, function(reason) {
|
2017-07-25 22:08:25 +00:00
|
|
|
$state.go('unauthorizedFormAccess');
|
2017-09-21 06:08:45 +00:00
|
|
|
deferred.reject({redirectTo: 'unauthorizedFormAccess'});
|
2017-07-25 22:08:25 +00:00
|
|
|
});
|
2017-10-02 10:18:47 +00:00
|
|
|
return deferred.promise;
|
2016-06-09 03:32:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
controller: 'SubmitFormController',
|
|
|
|
controllerAs: 'ctrl'
|
2017-07-25 22:08:25 +00:00
|
|
|
}).
|
|
|
|
state('unauthorizedFormAccess', {
|
|
|
|
url: '/forms/unauthorized',
|
|
|
|
templateUrl: '/static/form_modules/forms/base/views/form-unauthorized.client.view.html',
|
|
|
|
});
|
|
|
|
}
|
2016-06-09 03:32:33 +00:00
|
|
|
]);
|