tellform/public/modules/forms/admin/directives/configure-form.client.directive.js

77 lines
2.7 KiB
JavaScript
Raw Normal View History

2015-07-03 23:47:14 +00:00
'use strict';
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: {
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;
$scope.languages = $rootScope.languages;
2015-07-06 04:29:05 +00:00
$scope.resetForm = $rootScope.resetForm;
$scope.update = $rootScope.update;
2017-11-02 04:15:27 +00:00
$scope.languages = ['en', 'fr', 'es', 'it', 'de'];
$scope.langCodeToWord = {
'en': 'English',
'fr': 'Français',
'es': 'Español',
'it': 'Italiàno',
'de': 'Deutsch'
};
$scope.wordToLangCode = {
'English': 'en',
'Français': 'fr',
'Español': 'es',
'Italiàno': 'it',
'Deutsch': 'de'
};
2017-10-31 23:05:50 +00:00
$scope.configureTabs = [
{
heading: $filter('translate')('GENERAL_TAB'),
route: 'viewForm.configure.general',
active: false
},
{
heading: $filter('translate')('SELF_NOTIFICATIONS_TAB'),
route: 'viewForm.configure.self_notifications',
active: false
},
{
heading: $filter('translate')('RESPONDENT_NOTIFICATIONS_TAB'),
route: 'viewForm.configure.respondent_notifications',
active: false
}
];
$scope.emailFields = $scope.myform.form_fields.filter(function(field){
2017-11-01 18:06:08 +00:00
return field.fieldType === 'email';
});
$scope.formHasEmailField = ($scope.emailFields.length > 0);
$scope.go = function(tab){
tab.active = true;
$state.go(tab.route);
};
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
]);