This commit is contained in:
Sam 2016-04-28 00:38:56 +03:00
parent bdf642e9f4
commit 77f1f5dc43
6 changed files with 38 additions and 9 deletions

View file

@ -23,6 +23,8 @@ angular.module(ApplicationConfiguration.applicationModuleName).constant('USER_RO
normal: 'user',
superuser: 'superuser'
});
//form url
angular.module(ApplicationConfiguration.applicationModuleName).constant('FORM_URL', '/forms/:formId');
angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', 'Auth', '$state', '$stateParams',
function($rootScope, Auth, $state, $stateParams) {

View file

@ -0,0 +1,29 @@
'use strict';
// Configuring the Forms drop-down menus
angular.module('forms').filter('formValidity',
function(){
return function(formObj){
if(formObj && formObj.form_fields && formObj.visible_form_fields){
//get keys
var formKeys = Object.keys(formObj);
//we only care about things that don't start with $
var fieldKeys = formKeys.filter(function(key){
return key[0] !== '$';
});
var fields = formObj.form_fields;
var valid_count = fields.filter(function(field){
if(typeof field === 'object' && field.fieldType !== 'statement' && field.fieldType !== 'rating'){
return !!(field.fieldValue);
}
}).length;
return valid_count - (formObj.form_fields.length - formObj.visible_form_fields.length);
}
return 0;
};
});

View file

@ -13,7 +13,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
var getTemplateUrl = function(fieldType) {
var type = fieldType;
var templateUrl = 'modules/forms/views/directiveViews/field/';
var templateUrl = 'modules/forms/base/views/directiveViews/field/';
var supported_fields = [
'textfield',
'textarea',

View file

@ -3,8 +3,7 @@
angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth',
function ($http, TimeCounter, $filter, $rootScope, Auth) {
return {
templateUrl: 'modules/forms/views/directiveViews/form/submit-form.client.view.html',
restrict: 'E',
templateUrl: 'modules/forms/base/views/directiveViews/form/submit-form.client.view.html', restrict: 'E',
scope: {
myform:'='
},

View file

@ -1,9 +1,9 @@
'use strict';
//Forms service used for communicating with the forms REST endpoints
angular.module('forms').factory('Forms', ['$resource',
function($resource) {
return $resource('/forms/:formId', {
angular.module('forms').factory('Forms', ['$resource', 'FORM_URL',
function($resource, FORM_URL) {
return $resource(FORM_URL, {
formId: '@_id'
}, {
'query' : {
@ -25,7 +25,6 @@ angular.module('forms').factory('Forms', ['$resource',
transformResponse: function(data, header) {
var form = angular.fromJson(data);
//console.log(form);
form.visible_form_fields = _.filter(form.form_fields, function(field){
return (field.deletePreserved === false);
});

View file

@ -8,11 +8,11 @@ angular.module('forms').config(['$stateProvider',
$stateProvider.
state('listForms', {
url: '/forms',
templateUrl: 'modules/forms/views/list-forms.client.view.html'
templateUrl: 'modules/forms/admin/views/list-forms.client.view.html'
}).
state('submitForm', {
url: '/forms/:formId',
templateUrl: 'modules/forms/views/submit-form.client.view.html',
templateUrl: 'modules/forms/base/views/submit-form.client.view.html',
data: {
hideNav: true
},