2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-21 23:25:45 +00:00
|
|
|
// 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
|
|
|
}
|
|
|
|
]).filter('formValidity',
|
|
|
|
function(){
|
|
|
|
return function(formObj){
|
2015-07-27 18:11:43 +00:00
|
|
|
if(formObj && formObj.form_fields && formObj.visible_form_fields){
|
|
|
|
|
|
|
|
//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){
|
|
|
|
if(typeof field === 'object'){
|
2015-11-12 22:40:08 +00:00
|
|
|
if(field.fieldType === 'rating' || field.fieldType === 'statement'){
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-27 18:11:43 +00:00
|
|
|
return !!(field.fieldValue);
|
|
|
|
}
|
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
|
|
|
};
|
2015-07-21 23:25:45 +00:00
|
|
|
}).config(['$provide', function ($provide){
|
|
|
|
$provide.decorator('accordionDirective', function($delegate) {
|
|
|
|
var directive = $delegate[0];
|
|
|
|
directive.replace = true;
|
|
|
|
return $delegate;
|
|
|
|
});
|
|
|
|
}]);
|