2015-07-03 23:47:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-10-31 19:32:23 +00:00
|
|
|
angular.module('forms').directive('configureFormDirective', ['$rootScope', '$filter', '$state',
|
|
|
|
function ($rootScope, $filter, $state) {
|
2015-07-03 23:47:14 +00:00
|
|
|
return {
|
2016-05-05 19:12:40 +00:00
|
|
|
templateUrl: 'modules/forms/admin/views/directiveViews/form/configure-form.client.view.html',
|
2015-08-04 21:06:16 +00:00
|
|
|
restrict: 'E',
|
|
|
|
scope: {
|
2017-10-31 17:36:01 +00:00
|
|
|
myform:'='
|
2015-08-04 21:06:16 +00:00
|
|
|
},
|
2015-07-03 23:47:14 +00:00
|
|
|
controller: function($scope){
|
2017-10-31 23:05:50 +00:00
|
|
|
$rootScope.myform = $scope.myform;
|
2015-07-07 02:52:55 +00:00
|
|
|
$scope.languages = $rootScope.languages;
|
2015-07-06 04:29:05 +00:00
|
|
|
$scope.resetForm = $rootScope.resetForm;
|
2015-07-21 23:25:45 +00:00
|
|
|
$scope.update = $rootScope.update;
|
2017-10-31 23:05:50 +00:00
|
|
|
|
2017-10-31 17:36:01 +00:00
|
|
|
$scope.configureTabs = [
|
|
|
|
{
|
|
|
|
heading: $filter('translate')('GENERAL_TAB'),
|
2017-10-31 19:32:23 +00:00
|
|
|
route: 'viewForm.configure.general',
|
|
|
|
active: false
|
2017-10-31 17:36:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
heading: $filter('translate')('SELF_NOTIFICATIONS_TAB'),
|
2017-10-31 19:32:23 +00:00
|
|
|
route: 'viewForm.configure.self_notifications',
|
|
|
|
active: false
|
2017-10-31 17:36:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
heading: $filter('translate')('RESPONDENT_NOTIFICATIONS_TAB'),
|
2017-10-31 19:32:23 +00:00
|
|
|
route: 'viewForm.configure.respondent_notifications',
|
|
|
|
active: false
|
2017-10-31 17:36:01 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2017-11-01 18:06:08 +00:00
|
|
|
$scope.emailFields = $scope.myform.form_fields.filter(function(field){
|
|
|
|
return field.fieldType === 'email';
|
|
|
|
});
|
|
|
|
|
2017-10-31 19:32:23 +00:00
|
|
|
$scope.go = function(tab){
|
|
|
|
tab.active = true;
|
|
|
|
$state.go(tab.route);
|
2017-10-31 17:36:01 +00:00
|
|
|
};
|
2017-10-31 19:32:23 +00:00
|
|
|
|
|
|
|
function setActiveTab() {
|
|
|
|
$scope.configureTabs.forEach(function(tab) {
|
|
|
|
tab.active = ($state.current.name === tab.route);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setActiveTab();
|
|
|
|
|
|
|
|
$scope.$on("$stateChangeSuccess", setActiveTab());
|
2015-07-03 23:47:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2016-04-29 02:48:02 +00:00
|
|
|
]);
|