tellform/public/modules/forms/config/forms.client.config.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-06-29 22:51:29 +00:00
'use strict';
// Configuring the Forms drop-down menus
2015-06-29 22:51:29 +00:00
angular.module('forms').run(['Menus',
function(Menus) {
// Set top bar menu items
2015-07-07 01:21:43 +00:00
Menus.addMenuItem('topbar', 'My Forms', 'forms', '', '/forms', false);
2015-06-29 22:51:29 +00:00
}
2016-06-17 21:33:33 +00:00
]).filter('secondsToDateTime', [function() {
return function(seconds) {
return new Date(1970, 0, 1).setSeconds(seconds);
};
}]).filter('formValidity', [function(){
2015-06-29 22:51:29 +00:00
return function(formObj){
2015-07-27 18:11:43 +00:00
if(formObj && formObj.form_fields && formObj.visible_form_fields){
2016-04-28 01:40:51 +00:00
2015-07-27 18:11:43 +00:00
//get keys
var formKeys = Object.keys(formObj);
2015-07-02 23:34:00 +00:00
2015-07-27 18:11:43 +00:00
//we only care about things that don't start with $
var fieldKeys = formKeys.filter(function(key){
return key[0] !== '$';
});
2015-06-29 22:51:29 +00:00
2015-07-27 18:11:43 +00:00
var fields = formObj.form_fields;
2015-06-29 22:51:29 +00:00
2015-07-27 18:11:43 +00:00
var valid_count = fields.filter(function(field){
2016-04-20 17:32:18 +00:00
if(typeof field === 'object' && field.fieldType !== 'statement' && field.fieldType !== 'rating'){
2015-07-27 18:11:43 +00:00
return !!(field.fieldValue);
} else if(field.fieldType === 'rating'){
return true;
2015-07-27 18:11:43 +00:00
}
2015-11-12 22:40:08 +00:00
2015-07-27 18:11:43 +00:00
}).length;
return valid_count - (formObj.form_fields.length - formObj.visible_form_fields.length);
}
return 0;
2015-06-29 22:51:29 +00:00
};
}]).filter('trustSrc', ['$sce', function($sce){
return function(formUrl){
2017-09-21 01:36:42 +00:00
(' $sce.trustAsResourceUrl(formUrl): '+ $sce.trustAsResourceUrl(formUrl));
return $sce.trustAsResourceUrl(formUrl);
};
}]).config(['$provide', function ($provide){
2016-04-28 01:40:51 +00:00
$provide.decorator('accordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
2016-04-20 17:32:18 +00:00
}]);