added support for all FieldTypes

This commit is contained in:
David Baldwynn 2015-06-30 07:21:53 -07:00
parent e185f59bb1
commit f3f7d852fc
5 changed files with 28 additions and 22 deletions

View file

@ -10,9 +10,8 @@ var mongoose = require('mongoose'),
_ = require('lodash'), _ = require('lodash'),
config = require('../../config/config'), config = require('../../config/config'),
path = require('path'), path = require('path'),
fs = require('fs-extra'); fs = require('fs-extra'),
Field = mongoose.model('Field', FieldSchema);
var Field = mongoose.model('Field', FieldSchema);
/** /**
@ -117,8 +116,13 @@ FormSchema.pre('save', function (next) {
if(this.isGenerated && this.pdf){ if(this.isGenerated && this.pdf){
var _typeConvMap = { var _typeConvMap = {
'Multiline': 'textarea',
'Text': 'textfield', 'Text': 'textfield',
'Button': 'checkbox' 'Button': 'checkbox',
'Choice': 'radio',
'Password': 'password',
'FileSelect': 'filefield',
'Radio': 'radio'
}; };
var that = this; var that = this;
@ -136,8 +140,8 @@ FormSchema.pre('save', function (next) {
field.fieldType = _typeConvMap[ field.fieldType+'' ]; field.fieldType = _typeConvMap[ field.fieldType+'' ];
} }
// field.created = Date.now();
field.fieldValue = ''; field.fieldValue = '';
// field.created = Date.now();
// field.required = true; // field.required = true;
//field.disabled = false; //field.disabled = false;

View file

@ -10,18 +10,23 @@ var mongoose = require('mongoose'),
function validateFormFieldType(value) { function validateFormFieldType(value) {
if (!value || typeof myVar !== 'string' ) { return false; } if (!value || typeof myVar !== 'string' ) { return false; }
var validTypes = [ var validHTMLTypes = [
'textfield', 'textfield',
'email',
'url',
'textarea', 'textarea',
'statement'
'email',
'legal',
'url',
'number',
'filefield',
'radio',
'checkbox', 'checkbox',
'date', 'date',
'dropdown', 'dropdown',
'hidden', 'hidden',
'password', 'password',
'radio'
]; ];
if (validTypes.indexOf(value) > -1) { if (validTypes.indexOf(value) > -1) {
return true; return true;
} }

1
config/env/all.js vendored
View file

@ -59,6 +59,7 @@ module.exports = {
], ],
js: [ js: [
'public/lib/angular/angular.js', 'public/lib/angular/angular.js',
'public/lib/angular-permission/dist/angular-permission.js',
'public/lib/angular-resource/angular-resource.js', 'public/lib/angular-resource/angular-resource.js',
'public/lib/angular-animate/angular-animate.js', 'public/lib/angular-animate/angular-animate.js',
'public/lib/angular-ui-router/release/angular-ui-router.js', 'public/lib/angular-ui-router/release/angular-ui-router.js',

View file

@ -1,8 +1,8 @@
// 'use strict'; // 'use strict';
// Config HTTP Error Handling // Config HTTP Error Handling
angular.module('users').config(['$httpProvider','$q', '$location', 'Principal', angular.module('users').config(['$httpProvider',
function($httpProvider, $q, $location, Principal) { function($httpProvider) {
// Set the httpProvider "not authorized" interceptor // Set the httpProvider "not authorized" interceptor
$httpProvider.interceptors.push(['$q', '$location', 'Principal', $httpProvider.interceptors.push(['$q', '$location', 'Principal',
function($q, $location, Principal) { function($q, $location, Principal) {
@ -27,8 +27,7 @@ angular.module('users').config(['$httpProvider','$q', '$location', 'Principal',
} }
]); ]);
} }
]).config(['Permission', 'Principal', ]).run(function(Permission, Principal) {
function($Permission, Principal) {
var User = Principal.identity(); var User = Principal.identity();
Permission.defineRole('anonymous', function (stateParams) { Permission.defineRole('anonymous', function (stateParams) {
// If the returned value is *truthy* then the user has the role, otherwise they don't // If the returned value is *truthy* then the user has the role, otherwise they don't
@ -37,17 +36,14 @@ angular.module('users').config(['$httpProvider','$q', '$location', 'Principal',
} }
return false; return false;
}).defineRole('admin', function (stateParams) { }).defineRole('admin', function (stateParams) {
// If the returned value is *truthy* then the user has the role, otherwise they don't
if (Principal.isInRole('admin')) { if (Principal.isInRole('admin')) {
return true; // Is anonymous return true; // Is admin
} }
return false; return false;
}).defineRole('admin', function (stateParams) { }).defineRole('user', function (stateParams) {
// If the returned value is *truthy* then the user has the role, otherwise they don't
if (Principal.isInRole('user') && !Principal.isInRole('admin') ) { if (Principal.isInRole('user') && !Principal.isInRole('admin') ) {
return true; // Is anonymous return true; // Is user
} }
return false; return false;
}); });
} });
]);

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeout', '$state', angular.module('users').factory('Principal', ['$window', '$http', '$q', '$timeout',
function($window, $http, $q, $timeout, $state) { function($window, $http, $q, $timeout) {
var service = { var service = {
_currentUser: null, _currentUser: null,