fix jshint
This commit is contained in:
parent
cc2d6dadf0
commit
2fe9607e43
|
@ -8,7 +8,7 @@
|
||||||
"curly": false, // Require {} for every new block or scope.
|
"curly": false, // Require {} for every new block or scope.
|
||||||
"eqeqeq": true, // Require triple equals i.e. `===`.
|
"eqeqeq": true, // Require triple equals i.e. `===`.
|
||||||
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||||
"latedef": true, // Prohibit variable use before definition.
|
"latedef": false, // Prohibit variable use before definition.
|
||||||
"newcap": false, // Require capitalization of all constructor functions e.g. `new F()`.
|
"newcap": false, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||||
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||||
"quotmark": "single", // Define quotes to string values.
|
"quotmark": "single", // Define quotes to string values.
|
||||||
|
|
|
@ -45,8 +45,8 @@ var newDemoTemplate = {
|
||||||
|
|
||||||
|
|
||||||
// Setter function for form_fields
|
// Setter function for form_fields
|
||||||
function formFieldsSetter(form_fields){
|
function formFieldsSetter(form_fields) {
|
||||||
for(var i=0; i<form_fields.length; i++){
|
for (var i = 0; i < form_fields.length; i++) {
|
||||||
form_fields[i].isSubmission = true;
|
form_fields[i].isSubmission = true;
|
||||||
form_fields[i].submissionId = form_fields[i]._id;
|
form_fields[i].submissionId = form_fields[i]._id;
|
||||||
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
||||||
|
@ -143,9 +143,11 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(this.hasPlugins.oscarhost){
|
if (this.hasPlugins.oscarhost) {
|
||||||
mongoose.model('Form').findById(self.form, function(err, _form){
|
mongoose.model('Form').findById(self.form, function (err, _form) {
|
||||||
var form_ids = _.map(_.pluck(_form.form_fields, '_id'), function(id){ return ''+id;}),
|
var form_ids = _.map(_.pluck(_form.form_fields, '_id'), function (id) {
|
||||||
|
return '' + id;
|
||||||
|
}),
|
||||||
submission_ids = _.pluck(self.form_fields, '_id');
|
submission_ids = _.pluck(self.form_fields, '_id');
|
||||||
|
|
||||||
// console.log('Form form_field ids\n--------');
|
// console.log('Form form_field ids\n--------');
|
||||||
|
@ -153,14 +155,14 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
// console.log('FormSubmission [form_field ids]\n--------');
|
// console.log('FormSubmission [form_field ids]\n--------');
|
||||||
// console.log(submission_ids);
|
// console.log(submission_ids);
|
||||||
|
|
||||||
if(err) return next(err);
|
if (err) return next(err);
|
||||||
// console.log(_form);
|
// console.log(_form);
|
||||||
// console.log('should push to api');
|
// console.log('should push to api');
|
||||||
// console.log( (!this.oscarDemoNum && !!_form.plugins.oscarhost.baseUrl && !!_form.plugins.oscarhost.settings.fieldMap) );
|
// console.log( (!this.oscarDemoNum && !!_form.plugins.oscarhost.baseUrl && !!_form.plugins.oscarhost.settings.fieldMap) );
|
||||||
if(!this.oscarDemoNum && _form.plugins.oscarhost.baseUrl && _form.plugins.oscarhost.settings.fieldMap){
|
if (!this.oscarDemoNum && _form.plugins.oscarhost.baseUrl && _form.plugins.oscarhost.settings.fieldMap) {
|
||||||
console.log('OSCARHOST API HOOK');
|
console.log('OSCARHOST API HOOK');
|
||||||
var url_login = _form.plugins.oscarhost.baseUrl+'/LoginService?wsdl',
|
var url_login = _form.plugins.oscarhost.baseUrl + '/LoginService?wsdl',
|
||||||
url_demo = _form.plugins.oscarhost.baseUrl+'/DemographicService?wsdl';
|
url_demo = _form.plugins.oscarhost.baseUrl + '/DemographicService?wsdl';
|
||||||
|
|
||||||
var args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
var args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
||||||
|
|
||||||
|
@ -173,26 +175,26 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
// console.log(self.form_fields);
|
// console.log(self.form_fields);
|
||||||
|
|
||||||
//Generate demographics from hashmap
|
//Generate demographics from hashmap
|
||||||
var generateDemo = function(formFields, conversionMap, demographicsTemplate){
|
var generateDemo = function (formFields, conversionMap, demographicsTemplate) {
|
||||||
console.log('generating Demo fields');
|
console.log('generating Demo fields');
|
||||||
console.log(conversionMap);
|
console.log(conversionMap);
|
||||||
var _generatedDemo = {}, currField, propertyName;
|
var _generatedDemo = {}, currField, propertyName;
|
||||||
|
|
||||||
for(var y=0; y<formFields.length; y++){
|
for (var y = 0; y < formFields.length; y++) {
|
||||||
currField = formFields[y];
|
currField = formFields[y];
|
||||||
propertyName = conversionMap[currField._id];
|
propertyName = conversionMap[currField._id];
|
||||||
|
|
||||||
if(demographicsTemplate.hasOwnProperty(conversionMap[currField._id])){
|
if (demographicsTemplate.hasOwnProperty(conversionMap[currField._id])) {
|
||||||
_generatedDemo[propertyName] = currField.fieldValue+'';
|
_generatedDemo[propertyName] = currField.fieldValue + '';
|
||||||
}else if(propertyName === 'DOB'){
|
} else if (propertyName === 'DOB') {
|
||||||
var date = new Date(currField.fieldValue);
|
var date = new Date(currField.fieldValue);
|
||||||
_generatedDemo.dateOfBirth = date.getDate()+'';
|
_generatedDemo.dateOfBirth = date.getDate() + '';
|
||||||
_generatedDemo.yearOfBirth = date.getFullYear()+'';
|
_generatedDemo.yearOfBirth = date.getFullYear() + '';
|
||||||
_generatedDemo.monthOfBirth = date.getMonth()+'';
|
_generatedDemo.monthOfBirth = date.getMonth() + '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var currDate = new Date();
|
var currDate = new Date();
|
||||||
var dateString = currDate.toISOString().split('T')[0] + ' ' + currDate.toISOString().split('T')[1].slice(0,8);
|
var dateString = currDate.toISOString().split('T')[0] + ' ' + currDate.toISOString().split('T')[1].slice(0, 8);
|
||||||
_generatedDemo.lastUpdateDate = currDate.toISOString();
|
_generatedDemo.lastUpdateDate = currDate.toISOString();
|
||||||
return _generatedDemo;
|
return _generatedDemo;
|
||||||
};
|
};
|
||||||
|
@ -203,9 +205,9 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (callback) {
|
function (callback) {
|
||||||
//Authenticate with API
|
//Authenticate with API
|
||||||
soap.createClient(url_login, options, function(err, client) {
|
soap.createClient(url_login, options, function (err, client) {
|
||||||
client.login(args_login, function (err, result) {
|
client.login(args_login, function (err, result) {
|
||||||
if(err) return callback(err);
|
if (err) return callback(err);
|
||||||
console.log('SOAP authenticated');
|
console.log('SOAP authenticated');
|
||||||
return callback(null, result.return);
|
return callback(null, result.return);
|
||||||
});
|
});
|
||||||
|
@ -214,46 +216,46 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
|
|
||||||
function (security_obj, callback) {
|
function (security_obj, callback) {
|
||||||
//Force Add Demographic
|
//Force Add Demographic
|
||||||
if(_form.plugins.oscarhost.settings.updateType === 'force_add'){
|
if (_form.plugins.oscarhost.settings.updateType === 'force_add') {
|
||||||
soap.createClient(url_demo, options, function(err, client) {
|
soap.createClient(url_demo, options, function (err, client) {
|
||||||
if(err) return callback(err);
|
if (err) return callback(err);
|
||||||
client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey));
|
||||||
|
|
||||||
client.addDemographic({ arg0: submissionDemographic }, function (err, result) {
|
client.addDemographic({arg0: submissionDemographic}, function (err, result) {
|
||||||
console.log('FORCE ADDING DEMOGRAPHIC \n');
|
console.log('FORCE ADDING DEMOGRAPHIC \n');
|
||||||
// console.log(result.return);
|
// console.log(result.return);
|
||||||
if(err) return callback(err);
|
if (err) return callback(err);
|
||||||
return callback(null, result);
|
return callback(null, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
], function(err, result) {
|
], function (err, result) {
|
||||||
if(err) return next(err);
|
if (err) return next(err);
|
||||||
|
|
||||||
self.oscarDemoNum = parseInt(result.return, 10);
|
self.oscarDemoNum = parseInt(result.return, 10);
|
||||||
console.log('self.oscarDemoNum: '+self.oscarDemoNum);
|
console.log('self.oscarDemoNum: ' + self.oscarDemoNum);
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check for IP Address of submitting person
|
//Check for IP Address of submitting person
|
||||||
FormSubmissionSchema.pre('save', function (next){
|
FormSubmissionSchema.pre('save', function (next) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if(this.ipAddr){
|
if (this.ipAddr) {
|
||||||
if(this.isModified('ipAddr') || !this.geoLocation){
|
if (this.isModified('ipAddr') || !this.geoLocation) {
|
||||||
freegeoip.getLocation(this.ipAddr, function(err, location){
|
freegeoip.getLocation(this.ipAddr, function (err, location) {
|
||||||
if(err) return next(err);
|
if (err) return next(err);
|
||||||
self.geoLocation = location
|
self.geoLocation = location;
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -267,19 +269,19 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
self = this,
|
self = this,
|
||||||
_form = this.form;
|
_form = this.form;
|
||||||
|
|
||||||
if(this.pdf && this.pdf.path){
|
if (this.pdf && this.pdf.path) {
|
||||||
dest_filename = self.title.replace(/ /g,'')+'_submission_'+Date.now()+'.pdf';
|
dest_filename = self.title.replace(/ /g, '') + '_submission_' + Date.now() + '.pdf';
|
||||||
var __path = this.pdf.path.split('/').slice(0,this.pdf.path.split('/').length-1).join('/');
|
var __path = this.pdf.path.split('/').slice(0, this.pdf.path.split('/').length - 1).join('/');
|
||||||
dest_path = path.join(__path, dest_filename);
|
dest_path = path.join(__path, dest_filename);
|
||||||
|
|
||||||
self.pdfFilePath = dest_path;
|
self.pdfFilePath = dest_path;
|
||||||
|
|
||||||
pdfFiller.fillForm(self.pdf.path, dest_path, self.fdfData, function(err){
|
pdfFiller.fillForm(self.pdf.path, dest_path, self.fdfData, function (err) {
|
||||||
if(err) {
|
if (err) {
|
||||||
console.log('\n err.message: '+err.message);
|
console.log('\n err.message: ' + err.message);
|
||||||
return next( new Error(err.message) );
|
return next(new Error(err.message));
|
||||||
}
|
}
|
||||||
console.log('Field data from Form: '+self.title.replace(/ /g,'')+' outputed to new PDF: '+dest_path);
|
console.log('Field data from Form: ' + self.title.replace(/ /g, '') + ' outputed to new PDF: ' + dest_path);
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,19 +7,19 @@ var passport = require('passport'),
|
||||||
LocalStrategy = require('passport-local').Strategy,
|
LocalStrategy = require('passport-local').Strategy,
|
||||||
User = require('mongoose').model('User');
|
User = require('mongoose').model('User');
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function () {
|
||||||
// Use local strategy
|
// Use local strategy
|
||||||
passport.use(new LocalStrategy({
|
passport.use(new LocalStrategy({
|
||||||
usernameField: 'username',
|
usernameField: 'username',
|
||||||
passwordField: 'password'
|
passwordField: 'password'
|
||||||
},
|
},
|
||||||
function(username, password, done) {
|
function (username, password, done) {
|
||||||
User.findOne({
|
User.findOne({
|
||||||
$or: [
|
$or: [
|
||||||
{ "username": username},
|
{'username': username},
|
||||||
{ "email": username}
|
{'email': username}
|
||||||
]
|
]
|
||||||
}, function(err, user) {
|
}, function (err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return done(err);
|
return done(err);
|
||||||
}
|
}
|
||||||
|
|
2
public/dist/form-application.js
vendored
2
public/dist/form-application.js
vendored
|
@ -409,7 +409,7 @@ angular.module('view-form').config(['$stateProvider',
|
||||||
},
|
},
|
||||||
controller: 'SubmitFormController',
|
controller: 'SubmitFormController',
|
||||||
controllerAs: 'ctrl'
|
controllerAs: 'ctrl'
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,6 @@ angular.module('view-form').config(['$stateProvider',
|
||||||
},
|
},
|
||||||
controller: 'SubmitFormController',
|
controller: 'SubmitFormController',
|
||||||
controllerAs: 'ctrl'
|
controllerAs: 'ctrl'
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue