Merge branch 'master' of github.com:whitef0x0/tellform
This commit is contained in:
commit
c6b22dc2fc
29
.codeclimate.yml
Normal file
29
.codeclimate.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
engines:
|
||||||
|
eslint:
|
||||||
|
enabled: true
|
||||||
|
csslint:
|
||||||
|
enabled: true
|
||||||
|
eslint:
|
||||||
|
enabled: true
|
||||||
|
fixme:
|
||||||
|
enabled: true
|
||||||
|
duplication:
|
||||||
|
enabled: true
|
||||||
|
config:
|
||||||
|
languages:
|
||||||
|
- javascript
|
||||||
|
ratings:
|
||||||
|
paths:
|
||||||
|
- "**.css"
|
||||||
|
- "**.js"
|
||||||
|
- "**.jsx"
|
||||||
|
- "**.module"
|
||||||
|
|
||||||
|
exclude_paths:
|
||||||
|
- public/dist/**
|
||||||
|
- node_modules/**
|
||||||
|
- public/lib/**
|
||||||
|
- uploads/**
|
||||||
|
- docs/**
|
||||||
|
- public/populate_template_cache.js
|
||||||
|
- scripts/**
|
|
@ -33,9 +33,9 @@ exports.uploadPDF = function(req, res, next) {
|
||||||
|
|
||||||
|
|
||||||
if (req.file.size === 0) {
|
if (req.file.size === 0) {
|
||||||
next(new Error('File uploaded is EMPTY'));
|
return next(new Error('File uploaded is EMPTY'));
|
||||||
}else if(req.file.size > 100000000){
|
}else if(req.file.size > 100000000){
|
||||||
next(new Error('File uploaded exceeds MAX SIZE of 100MB'));
|
return next(new Error('File uploaded exceeds MAX SIZE of 100MB'));
|
||||||
}else {
|
}else {
|
||||||
fs.exists(_path, function(exists) {
|
fs.exists(_path, function(exists) {
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ exports.uploadPDF = function(req, res, next) {
|
||||||
|
|
||||||
if (stat && !stat.isDirectory()) {
|
if (stat && !stat.isDirectory()) {
|
||||||
console.log('Directory cannot be created');
|
console.log('Directory cannot be created');
|
||||||
next(new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"'));
|
return next(new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(path.join(newDestination, pdfFile.filename));
|
console.log(path.join(newDestination, pdfFile.filename));
|
||||||
|
|
||||||
fs.move(pdfFile.path, path.join(newDestination, pdfFile.filename), function (err) {
|
fs.move(pdfFile.path, path.join(newDestination, pdfFile.filename), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
next(new Error(err.message));
|
return next(new Error(err.message));
|
||||||
}
|
}
|
||||||
pdfFile.path = path.join(newDestination, pdfFile.filename);
|
pdfFile.path = path.join(newDestination, pdfFile.filename);
|
||||||
console.log(pdfFile.filename + ' uploaded to ' + pdfFile.path);
|
console.log(pdfFile.filename + ' uploaded to ' + pdfFile.path);
|
||||||
|
@ -67,12 +67,12 @@ exports.uploadPDF = function(req, res, next) {
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
next(new Error('Did NOT get your file!'));
|
return next(new Error('Did NOT get your file!'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
next(new Error('Uploaded files were NOT detected'));
|
return next(new Error('Uploaded files were NOT detected'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ exports.formByID = function(req, res, next, id) {
|
||||||
form.provider = undefined;
|
form.provider = undefined;
|
||||||
|
|
||||||
req.form = form;
|
req.form = form;
|
||||||
next();
|
return next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -332,5 +332,5 @@ exports.hasAuthorization = function(req, res, next) {
|
||||||
message: 'User '+req.user.username+' is not authorized to edit Form: '+form.title
|
message: 'User '+req.user.username+' is not authorized to edit Form: '+form.title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
next();
|
return next();
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,11 @@ exports.forgot = function(req, res, next) {
|
||||||
User.findOne({
|
User.findOne({
|
||||||
username: req.body.username
|
username: req.body.username
|
||||||
}, '-salt -password', function(err, user) {
|
}, '-salt -password', function(err, user) {
|
||||||
|
if(err){
|
||||||
|
return res.status(500).send({
|
||||||
|
message: err.message
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(400).send({
|
return res.status(400).send({
|
||||||
message: 'No account with that username has been found'
|
message: 'No account with that username has been found'
|
||||||
|
@ -102,6 +107,11 @@ exports.validateResetToken = function(req, res) {
|
||||||
$gt: Date.now()
|
$gt: Date.now()
|
||||||
}
|
}
|
||||||
}, function(err, user) {
|
}, function(err, user) {
|
||||||
|
if(err){
|
||||||
|
return res.status(500).send({
|
||||||
|
message: err.message
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.redirect('/#!/password/reset/invalid');
|
return res.redirect('/#!/password/reset/invalid');
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,12 +246,12 @@ FormSchema.pre('save', function (next) {
|
||||||
.findOne({_id: that._id}).exec(function (err, original) {
|
.findOne({_id: that._id}).exec(function (err, original) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
cb(err);
|
return cb(err);
|
||||||
} else {
|
} else {
|
||||||
_original = original;
|
_original = original;
|
||||||
//console.log('_original');
|
//console.log('_original');
|
||||||
//console.log(_original);
|
//console.log(_original);
|
||||||
cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, function(cb) {
|
}, function(cb) {
|
||||||
|
@ -260,7 +260,7 @@ FormSchema.pre('save', function (next) {
|
||||||
var validUpdateTypes = mongoose.model('Form').schema.path('plugins.oscarhost.settings.updateType').enumValues;
|
var validUpdateTypes = mongoose.model('Form').schema.path('plugins.oscarhost.settings.updateType').enumValues;
|
||||||
that.plugins.oscarhost.settings.validUpdateTypes = validUpdateTypes;
|
that.plugins.oscarhost.settings.validUpdateTypes = validUpdateTypes;
|
||||||
}
|
}
|
||||||
cb(null);
|
return cb(null);
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
if (that.pdf) {
|
if (that.pdf) {
|
||||||
|
@ -286,16 +286,16 @@ FormSchema.pre('save', function (next) {
|
||||||
fs.move(old_path, path.join(newDestination, new_filename), {clobber: true}, function (err) {
|
fs.move(old_path, path.join(newDestination, new_filename), {clobber: true}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
callback(new Error(err.message), 'task1');
|
return callback(new Error(err.message), 'task1');
|
||||||
} else {
|
} else {
|
||||||
that.pdf.path = path.join(newDestination, new_filename);
|
that.pdf.path = path.join(newDestination, new_filename);
|
||||||
that.pdf.name = new_filename;
|
that.pdf.name = new_filename;
|
||||||
|
|
||||||
callback(null, 'task1');
|
return callback(null, 'task1');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(null, 'task1');
|
return callback(null, 'task1');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (callback) {
|
function (callback) {
|
||||||
|
@ -318,9 +318,9 @@ FormSchema.pre('save', function (next) {
|
||||||
//console.log(that.pdf.path);
|
//console.log(that.pdf.path);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(new Error(err.message), null);
|
return callback(new Error(err.message), null);
|
||||||
} else if (!_form_fields.length || _form_fields === undefined || _form_fields === null) {
|
} else if (!_form_fields.length || _form_fields === undefined || _form_fields === null) {
|
||||||
callback(new Error('Generated formfields is empty'), null);
|
return callback(new Error('Generated formfields is empty'), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('autogenerating form');
|
console.log('autogenerating form');
|
||||||
|
@ -347,34 +347,34 @@ FormSchema.pre('save', function (next) {
|
||||||
that.form_fields = _form_fields;
|
that.form_fields = _form_fields;
|
||||||
|
|
||||||
that.isGenerated = false;
|
that.isGenerated = false;
|
||||||
callback(null, 'task2');
|
return callback(null, 'task2');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(null, 'task2');
|
return callback(null, 'task2');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
], function (err, results) {
|
], function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(new Error({
|
return cb(new Error({
|
||||||
message: err.message
|
message: err.message
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
//console.log('ending form save1');
|
//console.log('ending form save1');
|
||||||
cb();
|
return cb();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (_original) {
|
else if (_original) {
|
||||||
if (_original.hasOwnProperty('pdf')) {
|
if (_original.hasOwnProperty('pdf')) {
|
||||||
fs.remove(_original.pdf.path, function (err) {
|
fs.remove(_original.pdf.path, function (err) {
|
||||||
if (err) cb(err);
|
if (err) return cb(err);
|
||||||
console.log('file at ' + _original.pdf.path + ' successfully deleted');
|
console.log('file at ' + _original.pdf.path + ' successfully deleted');
|
||||||
cb();
|
return cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else cb();
|
else return cb();
|
||||||
}
|
}
|
||||||
else cb();
|
else return cb();
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ FormSchema.pre('save', function (next) {
|
||||||
exec(function(err, submissions){
|
exec(function(err, submissions){
|
||||||
if(err) {
|
if(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
cb_id(err);
|
return cb_id(err);
|
||||||
} else {
|
} else {
|
||||||
//Delete field if there are no submission(s) found
|
//Delete field if there are no submission(s) found
|
||||||
if (submissions.length) {
|
if (submissions.length) {
|
||||||
|
@ -409,14 +409,14 @@ FormSchema.pre('save', function (next) {
|
||||||
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
|
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_id(null);
|
return cb_id(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
if(err){
|
if(err){
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
cb(err);
|
return cb(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Iterate through all submissions with modified form_fields
|
//Iterate through all submissions with modified form_fields
|
||||||
|
@ -450,27 +450,27 @@ FormSchema.pre('save', function (next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
submission.save(function (err) {
|
submission.save(function (err) {
|
||||||
if (err) callback(err);
|
if (err) return callback(err);
|
||||||
else callback(null);
|
else return callback(null);
|
||||||
});
|
});
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
else cb();
|
else return cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else cb(null);
|
else return cb(null);
|
||||||
}
|
}
|
||||||
else cb(null);
|
else return cb(null);
|
||||||
}],
|
}],
|
||||||
function(err, results){
|
function(err, results){
|
||||||
if (err) next(err);
|
if (err) return next(err);
|
||||||
next();
|
return next();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,17 @@ var mongoose = require('mongoose'),
|
||||||
|
|
||||||
var FieldOptionSchema = new Schema({
|
var FieldOptionSchema = new Schema({
|
||||||
option_id: {
|
option_id: {
|
||||||
type: Number,
|
type: Number
|
||||||
},
|
},
|
||||||
|
|
||||||
option_title: {
|
option_title: {
|
||||||
type: String,
|
type: String
|
||||||
},
|
},
|
||||||
|
|
||||||
option_value: {
|
option_value: {
|
||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ var FormFieldSchema = new Schema({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true,
|
||||||
required: 'Field Title cannot be blank',
|
required: 'Field Title cannot be blank'
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -17,7 +17,7 @@ var mongoose = require('mongoose'),
|
||||||
FieldSchema = require('./form_field.server.model.js'),
|
FieldSchema = require('./form_field.server.model.js'),
|
||||||
OscarSecurity = require('../../scripts/oscarhost/OscarSecurity');
|
OscarSecurity = require('../../scripts/oscarhost/OscarSecurity');
|
||||||
|
|
||||||
var newDemoTemplate = {
|
var newDemoTemplate = {
|
||||||
address: '880-9650 Velit. St.',
|
address: '880-9650 Velit. St.',
|
||||||
city: '',
|
city: '',
|
||||||
dateOfBirth: '10',
|
dateOfBirth: '10',
|
||||||
|
@ -38,10 +38,10 @@ var newDemoTemplate = {
|
||||||
sin: '',
|
sin: '',
|
||||||
spokenLanguage: 'English',
|
spokenLanguage: 'English',
|
||||||
title: 'MS.',
|
title: 'MS.',
|
||||||
yearOfBirth: '2015'
|
yearOfBirth: '2015'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form Submission Schema
|
* Form Submission Schema
|
||||||
*/
|
*/
|
||||||
var FormSubmissionSchema = new Schema({
|
var FormSubmissionSchema = new Schema({
|
||||||
|
@ -56,64 +56,64 @@ var FormSubmissionSchema = new Schema({
|
||||||
},
|
},
|
||||||
|
|
||||||
form_fields: {
|
form_fields: {
|
||||||
type: [Schema.Types.Mixed],
|
type: [Schema.Types.Mixed]
|
||||||
},
|
},
|
||||||
|
|
||||||
form: {
|
form: {
|
||||||
type: Schema.Types.ObjectId,
|
type: Schema.Types.ObjectId,
|
||||||
ref: 'Form',
|
ref: 'Form',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
|
||||||
ipAddr: {
|
ipAddr: {
|
||||||
type: String,
|
type: String
|
||||||
},
|
},
|
||||||
geoLocation: {
|
geoLocation: {
|
||||||
Country: {
|
Country: {
|
||||||
type: String,
|
type: String
|
||||||
},
|
},
|
||||||
Region: {
|
Region: {
|
||||||
type: String,
|
type: String
|
||||||
},
|
},
|
||||||
City: {
|
City: {
|
||||||
type: String,
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pdfFilePath: {
|
pdfFilePath: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed
|
||||||
},
|
},
|
||||||
pdf: {
|
pdf: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed
|
||||||
},
|
},
|
||||||
fdfData: {
|
fdfData: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed
|
||||||
},
|
},
|
||||||
|
|
||||||
timeElapsed: {
|
timeElapsed: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
percentageComplete: {
|
percentageComplete: {
|
||||||
type: Number,
|
type: Number
|
||||||
},
|
},
|
||||||
|
|
||||||
//TODO: DAVID: Need to not have this hardcoded
|
//TODO: DAVID: Need to not have this hardcoded
|
||||||
oscarDemoNum: {
|
oscarDemoNum: {
|
||||||
type: Number,
|
type: Number
|
||||||
},
|
},
|
||||||
|
|
||||||
hasPlugins: {
|
hasPlugins: {
|
||||||
oscarhost: {
|
oscarhost: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ FormSubmissionSchema.plugin(mUtilities.timestamp, {
|
||||||
|
|
||||||
//Oscarhost API hook
|
//Oscarhost API hook
|
||||||
FormSubmissionSchema.pre('save', function (next) {
|
FormSubmissionSchema.pre('save', function (next) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(this.hasPlugins.oscarhost){
|
if(this.hasPlugins.oscarhost){
|
||||||
|
@ -140,7 +140,7 @@ 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) 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) );
|
||||||
|
@ -175,7 +175,7 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
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();
|
||||||
|
@ -183,18 +183,18 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
_generatedDemo.lastUpdateDate = currDate.toISOString();
|
_generatedDemo.lastUpdateDate = currDate.toISOString();
|
||||||
return _generatedDemo;
|
return _generatedDemo;
|
||||||
};
|
};
|
||||||
|
|
||||||
var submissionDemographic = generateDemo(self.form_fields, _form.plugins.oscarhost.settings.fieldMap, newDemoTemplate);
|
var submissionDemographic = generateDemo(self.form_fields, _form.plugins.oscarhost.settings.fieldMap, newDemoTemplate);
|
||||||
|
|
||||||
console.log(submissionDemographic);
|
console.log(submissionDemographic);
|
||||||
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) callback(err);
|
if(err) return callback(err);
|
||||||
console.log('SOAP authenticated');
|
console.log('SOAP authenticated');
|
||||||
callback(null, result.return);
|
return callback(null, result.return);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -203,56 +203,57 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
//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);
|
||||||
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) callback(err);
|
if(err) return callback(err);
|
||||||
callback(null, result);
|
return callback(null, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
], function(err, result) {
|
], function(err, result) {
|
||||||
if(err) 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);
|
||||||
next();
|
return next();
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
next();
|
return next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
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) next(err);
|
if(err) return next(err);
|
||||||
//self.geoLocation = JSON.parse(location);
|
//self.geoLocation = JSON.parse(location);
|
||||||
next();
|
return next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next();
|
return next();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Generate autofilled PDF if flags are set
|
//Generate autofilled PDF if flags are set
|
||||||
FormSubmissionSchema.pre('save', function (next) {
|
FormSubmissionSchema.pre('save', function (next) {
|
||||||
var fdfData, dest_filename, dest_path,
|
var fdfData, dest_filename, dest_path,
|
||||||
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';
|
||||||
|
@ -264,13 +265,13 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||||
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);
|
||||||
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);
|
||||||
next();
|
return next();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
next();
|
return next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -106,17 +106,17 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||||
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||||
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||||
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''},
|
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}
|
||||||
],
|
]
|
||||||
plugins: {
|
// plugins: {
|
||||||
oscarhost: {
|
// oscarhost: {
|
||||||
baseUrl: config.oscarhost.baseUrl,
|
// baseUrl: config.oscarhost.baseUrl,
|
||||||
settings: {
|
// settings: {
|
||||||
updateType: 'force_add'
|
// updateType: 'force_add'
|
||||||
},
|
// },
|
||||||
auth: config.oscarhost.auth
|
// auth: config.oscarhost.auth
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
myForm.save(function(err, form){
|
myForm.save(function(err, form){
|
||||||
|
|
|
@ -9,18 +9,18 @@ var multiFact = {
|
||||||
{
|
{
|
||||||
left:"user 4",
|
left:"user 4",
|
||||||
right:"something something user something",
|
right:"something something user something",
|
||||||
logicOp: "AND",
|
logicOp: "AND"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
left:"something something user something",
|
left:"something something user something",
|
||||||
right:"something",
|
right:"something",
|
||||||
logicOp: "OR",
|
logicOp: "OR"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
left:"",
|
left:"",
|
||||||
right:"",
|
right:"",
|
||||||
logicOp:"",
|
logicOp:"",
|
||||||
prevResult: null,
|
prevResult: null
|
||||||
};
|
};
|
||||||
|
|
||||||
var _globalRules = function(){};
|
var _globalRules = function(){};
|
||||||
|
@ -39,7 +39,7 @@ _globalRules.Equal = {
|
||||||
|
|
||||||
if(prevResult !== null){
|
if(prevResult !== null){
|
||||||
if(logicOp === "AND"){
|
if(logicOp === "AND"){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.result = false;
|
this.result = false;
|
||||||
|
@ -59,7 +59,7 @@ _globalRules.NotEqual = {
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
_globalRules.AND = {
|
_globalRules.AND = {
|
||||||
"condition" : function(R) {
|
"condition" : function(R) {
|
||||||
|
@ -74,7 +74,7 @@ _globalRules.AND = {
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
_globalRules.OR = {
|
_globalRules.OR = {
|
||||||
"condition" : function(R) {
|
"condition" : function(R) {
|
||||||
|
@ -83,7 +83,7 @@ _globalRules.OR = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
R.when(!(this.left || this.right));
|
R.when(!(this.left || this.right));
|
||||||
},
|
},
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
|
@ -101,7 +101,7 @@ _stringRules.Contains = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var contains = (this.left.indexOf(this.right) > -1);
|
var contains = (this.left.indexOf(this.right) > -1);
|
||||||
R.when(!contains);
|
R.when(!contains);
|
||||||
},
|
},
|
||||||
|
@ -117,7 +117,7 @@ _stringRules.NotContains = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notContains = !(this.left.indexOf(this.right) > -1);
|
var notContains = !(this.left.indexOf(this.right) > -1);
|
||||||
R.when(!notContains);
|
R.when(!notContains);
|
||||||
},
|
},
|
||||||
|
@ -133,7 +133,7 @@ _stringRules.BeginsWith = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
R.when(!(this.left.indexOf(this.right) === 0));
|
R.when(!(this.left.indexOf(this.right) === 0));
|
||||||
},
|
},
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
|
@ -148,7 +148,7 @@ _stringRules.EndsWith = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lenLeft = this.left.length;
|
var lenLeft = this.left.length;
|
||||||
var lenRight = this.right.length;
|
var lenRight = this.right.length;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ _stringRules.EndsWith = {
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var _numberRules = function(){};
|
var _numberRules = function(){};
|
||||||
|
@ -169,14 +169,14 @@ _numberRules.GreaterThan = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var greaterThan = (this.left > this.right);
|
var greaterThan = (this.left > this.right);
|
||||||
R.when(!greaterThan);
|
R.when(!greaterThan);
|
||||||
},
|
},
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
_numberRules.SmallerThan = {
|
_numberRules.SmallerThan = {
|
||||||
"condition" : function(R) {
|
"condition" : function(R) {
|
||||||
|
@ -185,7 +185,7 @@ _numberRules.SmallerThan = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var smallerThan = (this.left < this.right);
|
var smallerThan = (this.left < this.right);
|
||||||
R.when(!smallerThan);
|
R.when(!smallerThan);
|
||||||
},
|
},
|
||||||
|
@ -201,14 +201,14 @@ _numberRules.GreaterThanOrEqual = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var greaterThanOrEqual = (this.left >= this.right);
|
var greaterThanOrEqual = (this.left >= this.right);
|
||||||
R.when(!greaterThanOrEqual);
|
R.when(!greaterThanOrEqual);
|
||||||
},
|
},
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_numberRules.SmallerThanOrEqual = {
|
_numberRules.SmallerThanOrEqual = {
|
||||||
|
@ -218,14 +218,14 @@ _numberRules.SmallerThanOrEqual = {
|
||||||
this.left = currTuple.left;
|
this.left = currTuple.left;
|
||||||
this.right = currTuple.right;
|
this.right = currTuple.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
var smallerThanOrEqual = (this.left <= this.right);
|
var smallerThanOrEqual = (this.left <= this.right);
|
||||||
R.when(!smallerThanOrEqual);
|
R.when(!smallerThanOrEqual);
|
||||||
},
|
},
|
||||||
"consequence" : function(R) {
|
"consequence" : function(R) {
|
||||||
this.result = false;
|
this.result = false;
|
||||||
R.next();
|
R.next();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -191,7 +191,7 @@ NODE_ENV: 'test',
|
||||||
src: watchFiles.allTests, // a folder works nicely
|
src: watchFiles.allTests, // a folder works nicely
|
||||||
options: {
|
options: {
|
||||||
mask: '*.test.js',
|
mask: '*.test.js',
|
||||||
require: ['server.js'],
|
require: ['server.js']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coverageClient: {
|
coverageClient: {
|
||||||
|
@ -199,7 +199,7 @@ NODE_ENV: 'test',
|
||||||
options: {
|
options: {
|
||||||
coverageFolder: 'coverageClient',
|
coverageFolder: 'coverageClient',
|
||||||
mask: '*.test.js',
|
mask: '*.test.js',
|
||||||
require: ['server.js'],
|
require: ['server.js']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coverageServer: {
|
coverageServer: {
|
||||||
|
@ -207,7 +207,7 @@ NODE_ENV: 'test',
|
||||||
options: {
|
options: {
|
||||||
coverageFolder: 'coverageServer',
|
coverageFolder: 'coverageServer',
|
||||||
mask: '*.test.js',
|
mask: '*.test.js',
|
||||||
require: ['server.js'],
|
require: ['server.js']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coveralls: {
|
coveralls: {
|
||||||
|
@ -244,7 +244,7 @@ NODE_ENV: 'test',
|
||||||
removeAttributeQuotes: true,
|
removeAttributeQuotes: true,
|
||||||
removeComments: true,
|
removeComments: true,
|
||||||
removeEmptyAttributes: true,
|
removeEmptyAttributes: true,
|
||||||
removeRedundantAttributes: true,
|
removeRedundantAttributes: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
main: {
|
main: {
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
"math": "0.0.3",
|
"math": "0.0.3",
|
||||||
"method-override": "~2.3.0",
|
"method-override": "~2.3.0",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mongoose": "~3.8.8",
|
"mongoose": "^3.8.40",
|
||||||
"mongoose-utilities": "~0.1.1",
|
"mongoose-utilities": "~0.1.1",
|
||||||
"morgan": "~1.6.1",
|
"morgan": "~1.6.1",
|
||||||
"multer": "~1.1.0",
|
"multer": "~1.1.0",
|
||||||
|
|
|
@ -10,10 +10,10 @@ angular.module('core').service('Menus', [
|
||||||
// Define the menus object
|
// Define the menus object
|
||||||
this.menus = {};
|
this.menus = {};
|
||||||
|
|
||||||
// A private function for rendering decision
|
// A private function for rendering decision
|
||||||
var shouldRender = function(user) {
|
var shouldRender = function(user) {
|
||||||
if (user) {
|
if (user) {
|
||||||
if (!!~this.roles.indexOf('*')) {
|
if (~this.roles.indexOf('*')) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (var userRoleIndex in user.roles) {
|
for (var userRoleIndex in user.roles) {
|
||||||
|
@ -168,4 +168,4 @@ angular.module('core').service('Menus', [
|
||||||
//Adding the bottombar menu for the Form-Footer view
|
//Adding the bottombar menu for the Form-Footer view
|
||||||
this.addMenu('bottombar', false, ['*']);
|
this.addMenu('bottombar', false, ['*']);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -18,15 +18,15 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
heading: 'Design',
|
heading: 'Design',
|
||||||
route: 'viewForm.design',
|
route: 'viewForm.design'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
heading: 'Configure',
|
heading: 'Configure',
|
||||||
route: 'viewForm.configure',
|
route: 'viewForm.configure'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
heading: 'Analyze',
|
heading: 'Analyze',
|
||||||
route: 'viewForm.analyze',
|
route: 'viewForm.analyze'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** DeleteModal Functions
|
** DeleteModal Functions
|
||||||
*/
|
*/
|
||||||
$scope.openDeleteModal = function(){
|
$scope.openDeleteModal = function(){
|
||||||
$scope.deleteModal = $uibModal.open({
|
$scope.deleteModal = $uibModal.open({
|
||||||
|
@ -72,15 +72,15 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
if($scope.deleteModal && $scope.deleteModal.opened){
|
if($scope.deleteModal && $scope.deleteModal.opened){
|
||||||
|
|
||||||
$scope.deleteModal.close();
|
$scope.deleteModal.close();
|
||||||
|
|
||||||
var form_id = $scope.myform._id;
|
var form_id = $scope.myform._id;
|
||||||
if(!form_id) throw new Error('Error - removeCurrentForm(): $scope.myform._id does not exist');
|
if(!form_id) throw new Error('Error - removeCurrentForm(): $scope.myform._id does not exist');
|
||||||
|
|
||||||
$http.delete('/forms/'+form_id)
|
$http.delete('/forms/'+form_id)
|
||||||
.success(function(data, status, headers){
|
.success(function(data, status, headers){
|
||||||
console.log('form deleted successfully');
|
console.log('form deleted successfully');
|
||||||
|
|
||||||
$state.go('listForms', {}, {reload: true});
|
$state.go('listForms', {}, {reload: true});
|
||||||
|
|
||||||
}).error(function(error){
|
}).error(function(error){
|
||||||
console.log('ERROR: Form could not be deleted.');
|
console.log('ERROR: Form could not be deleted.');
|
||||||
|
@ -96,7 +96,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
if(!updateImmediately){
|
if(!updateImmediately){
|
||||||
continueUpdate = !$rootScope.saveInProgress;
|
continueUpdate = !$rootScope.saveInProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update form **if we are not currently updating** or if **shouldUpdateNow flag is set**
|
//Update form **if we are not currently updating** or if **shouldUpdateNow flag is set**
|
||||||
if(continueUpdate){
|
if(continueUpdate){
|
||||||
var err = null;
|
var err = null;
|
||||||
|
@ -111,12 +111,12 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
console.log('Error occured during form UPDATE.\n');
|
console.log('Error occured during form UPDATE.\n');
|
||||||
// console.log(response.data);
|
// console.log(response.data);
|
||||||
err = response.data;
|
err = response.data;
|
||||||
}).finally(function() {
|
}).finally(function() {
|
||||||
// console.log('finished updating');
|
// console.log('finished updating');
|
||||||
if(!updateImmediately){$rootScope.saveInProgress = false; }
|
if(!updateImmediately){$rootScope.saveInProgress = false; }
|
||||||
|
|
||||||
if( (typeof cb) === 'function'){
|
if( (typeof cb) === 'function'){
|
||||||
cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -124,4 +124,4 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -77,7 +77,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
|
||||||
console.log('Error occured during upload.\n');
|
console.log('Error occured during upload.\n');
|
||||||
console.log(resp.status);
|
console.log(resp.status);
|
||||||
}, function (evt) {
|
}, function (evt) {
|
||||||
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
|
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total, 10);
|
||||||
$scope.log = 'progress: ' + progressPercentage + '% ' +
|
$scope.log = 'progress: ' + progressPercentage + '% ' +
|
||||||
evt.config.data.file.name + '\n' + $scope.log;
|
evt.config.data.file.name + '\n' + $scope.log;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
templateUrl: 'modules/forms/views/directiveViews/form/edit-form.client.view.html',
|
templateUrl: 'modules/forms/views/directiveViews/form/edit-form.client.view.html',
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
myform:'=',
|
myform:'='
|
||||||
},
|
},
|
||||||
controller: function($scope){
|
controller: function($scope){
|
||||||
var field_ids = _($scope.myform.form_fields).pluck('_id');
|
var field_ids = _($scope.myform.form_fields).pluck('_id');
|
||||||
|
@ -45,7 +45,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
|
|
||||||
if( $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id) ){
|
if( $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id) ){
|
||||||
currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]);
|
currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get all oscarhostFields that haven't been mapped to a formfield
|
//Get all oscarhostFields that haven't been mapped to a formfield
|
||||||
return _(oscarhostFields).difference(currentFields).value();
|
return _(oscarhostFields).difference(currentFields).value();
|
||||||
|
@ -59,7 +59,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
$scope.dropzone = {
|
$scope.dropzone = {
|
||||||
handle: ' .handle',
|
handle: ' .handle',
|
||||||
containment: '.dropzoneContainer',
|
containment: '.dropzoneContainer',
|
||||||
cursor: 'grabbing',
|
cursor: 'grabbing'
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,9 +73,9 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
var fieldTitle;
|
var fieldTitle;
|
||||||
|
|
||||||
for(var i = 0; i < $scope.addField.types.length; i++){
|
for(var i = 0; i < $scope.addField.types.length; i++){
|
||||||
if($scope.addField.types[i].name === fieldType){
|
if($scope.addField.types[i].name === fieldType){
|
||||||
$scope.addField.types[i].lastAddedID++;
|
$scope.addField.types[i].lastAddedID++;
|
||||||
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
|
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,12 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
// console.log('\n\n---------\nAdded field CLIENT');
|
// console.log('\n\n---------\nAdded field CLIENT');
|
||||||
// console.log(newField);
|
// console.log(newField);
|
||||||
// newField._id = _.uniqueId();
|
// newField._id = _.uniqueId();
|
||||||
|
|
||||||
// put newField into fields array
|
// put newField into fields array
|
||||||
if(modifyForm){
|
if(modifyForm){
|
||||||
$scope.myform.form_fields.push(newField);
|
$scope.myform.form_fields.push(newField);
|
||||||
}
|
}
|
||||||
return newField;
|
return newField;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Delete particular field on button click
|
// Delete particular field on button click
|
||||||
|
@ -109,7 +109,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
$scope.myform.form_fields.splice(field_index, 1);
|
$scope.myform.form_fields.splice(field_index, 1);
|
||||||
};
|
};
|
||||||
$scope.duplicateField = function (field_index){
|
$scope.duplicateField = function (field_index){
|
||||||
var currField = _.cloneDeep($scope.myform.form_fields[field_index]);
|
var currField = _.cloneDeep($scope.myform.form_fields[field_index]);
|
||||||
currField._id = 'cloned'+_.uniqueId();
|
currField._id = 'cloned'+_.uniqueId();
|
||||||
currField.title += ' copy';
|
currField.title += ' copy';
|
||||||
|
|
||||||
|
@ -158,8 +158,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
$scope.addOption = function(field_index){
|
$scope.addOption = function(field_index){
|
||||||
var currField = $scope.myform.form_fields[field_index];
|
var currField = $scope.myform.form_fields[field_index];
|
||||||
console.log(field_index);
|
console.log(field_index);
|
||||||
console.log(currField);
|
console.log(currField);
|
||||||
|
|
||||||
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
|
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
|
||||||
if(!currField.fieldOptions) $scope.myform.form_fields[field_index].fieldOptions = [];
|
if(!currField.fieldOptions) $scope.myform.form_fields[field_index].fieldOptions = [];
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
var newOption = {
|
var newOption = {
|
||||||
'option_id' : Math.floor(100000*Math.random()),
|
'option_id' : Math.floor(100000*Math.random()),
|
||||||
'option_title' : 'Option '+lastOptionID,
|
'option_title' : 'Option '+lastOptionID,
|
||||||
'option_value' : 'Option ' +lastOptionID,
|
'option_value' : 'Option ' +lastOptionID
|
||||||
};
|
};
|
||||||
|
|
||||||
// put new option into fieldOptions array
|
// put new option into fieldOptions array
|
||||||
|
@ -208,8 +208,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -49,7 +49,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
||||||
|
|
||||||
// console.log('before textField2: '+data[0].form_fields[1].fieldValue);
|
// console.log('before textField2: '+data[0].form_fields[1].fieldValue);
|
||||||
|
|
||||||
//Iterate through form's submissions
|
//Iterate through form's submissions
|
||||||
for(var i=0; i<data.length; i++){
|
for(var i=0; i<data.length; i++){
|
||||||
for(var x=0; x<data[i].form_fields; x++){
|
for(var x=0; x<data[i].form_fields; x++){
|
||||||
|
@ -69,8 +69,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
})
|
})
|
||||||
.error(function(err){
|
.error(function(err){
|
||||||
console.error('Could not fetch form submissions.\nError: '+err);
|
console.error('Could not fetch form submissions.\nError: '+err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//Delete selected submissions of Form
|
//Delete selected submissions of Form
|
||||||
$scope.deleteSelectedSubmissions = function(){
|
$scope.deleteSelectedSubmissions = function(){
|
||||||
|
@ -79,7 +79,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
return !!row.selected;
|
return !!row.selected;
|
||||||
}).pluck('_id').value();
|
}).pluck('_id').value();
|
||||||
|
|
||||||
$http({ url: '/forms/'+$scope.myform._id+'/submissions',
|
$http({ url: '/forms/'+$scope.myform._id+'/submissions',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
data: {deleted_submissions: delete_ids},
|
data: {deleted_submissions: delete_ids},
|
||||||
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
||||||
|
@ -97,7 +97,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
console.log('Could not delete form submissions.\nError: ');
|
console.log('Could not delete form submissions.\nError: ');
|
||||||
console.log(err);
|
console.log(err);
|
||||||
console.error = err;
|
console.error = err;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//Export selected submissions of Form
|
//Export selected submissions of Form
|
||||||
|
@ -105,7 +105,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
var fileMIMETypeMap = {
|
var fileMIMETypeMap = {
|
||||||
'xls': 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
'xls': 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
'json': 'json',
|
'json': 'json',
|
||||||
'csv': 'csv',
|
'csv': 'csv'
|
||||||
};
|
};
|
||||||
|
|
||||||
var blob = new Blob([document.getElementById('table-submission-data').innerHTM], {
|
var blob = new Blob([document.getElementById('table-submission-data').innerHTM], {
|
||||||
|
|
|
@ -32,7 +32,6 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
|
||||||
if (__indexOf.call(supported_fields, type) >= 0) {
|
if (__indexOf.call(supported_fields, type) >= 0) {
|
||||||
templateUrl = templateUrl+type+'.html';
|
templateUrl = templateUrl+type+'.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $templateCache.get('../public/'+templateUrl);
|
return $templateCache.get('../public/'+templateUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,28 +48,30 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
|
||||||
$scope.fieldBottom = elemBox.bottom;
|
$scope.fieldBottom = elemBox.bottom;
|
||||||
|
|
||||||
//console.log($scope.forms.myForm);
|
//console.log($scope.forms.myForm);
|
||||||
|
var field_id;
|
||||||
|
var field_index;
|
||||||
|
|
||||||
if(!$scope.noscroll){
|
if(!$scope.noscroll){
|
||||||
//Focus on submit button
|
//Focus on submit button
|
||||||
if( $scope.selected.index === $scope.myform.form_fields.length-1 && $scope.fieldBottom < 200){
|
if( $scope.selected.index === $scope.myform.form_fields.length-1 && $scope.fieldBottom < 200){
|
||||||
var field_index = $scope.selected.index+1;
|
field_index = $scope.selected.index+1;
|
||||||
var field_id = 'submit_field';
|
field_id = 'submit_field';
|
||||||
$scope.setActiveField(field_id, field_index, false);
|
$scope.setActiveField(field_id, field_index, false);
|
||||||
}
|
}
|
||||||
//Focus on field above submit button
|
//Focus on field above submit button
|
||||||
else if($scope.selected.index === $scope.myform.form_fields.length){
|
else if($scope.selected.index === $scope.myform.form_fields.length){
|
||||||
if($scope.fieldTop > 200){
|
if($scope.fieldTop > 200){
|
||||||
var field_index = $scope.selected.index-1;
|
field_index = $scope.selected.index-1;
|
||||||
var field_id = $scope.myform.form_fields[field_index]._id;
|
field_id = $scope.myform.form_fields[field_index]._id;
|
||||||
$scope.setActiveField(field_id, field_index, false);
|
$scope.setActiveField(field_id, field_index, false);
|
||||||
}
|
}
|
||||||
}else if( $scope.fieldBottom < 0){
|
}else if( $scope.fieldBottom < 0){
|
||||||
var field_index = $scope.selected.index+1;
|
field_index = $scope.selected.index+1;
|
||||||
var field_id = $scope.myform.form_fields[field_index]._id;
|
field_id = $scope.myform.form_fields[field_index]._id;
|
||||||
$scope.setActiveField(field_id, field_index, false);
|
$scope.setActiveField(field_id, field_index, false);
|
||||||
}else if ( $scope.selected.index !== 0 && $scope.fieldTop > 0) {
|
}else if ( $scope.selected.index !== 0 && $scope.fieldTop > 0) {
|
||||||
var field_index = $scope.selected.index-1;
|
field_index = $scope.selected.index-1;
|
||||||
var field_id = $scope.myform.form_fields[field_index]._id;
|
field_id = $scope.myform.form_fields[field_index]._id;
|
||||||
$scope.setActiveField(field_id, field_index, false);
|
$scope.setActiveField(field_id, field_index, false);
|
||||||
}
|
}
|
||||||
//console.log('$scope.selected.index: '+$scope.selected.index);
|
//console.log('$scope.selected.index: '+$scope.selected.index);
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load the main application module
|
// Load the main application module
|
||||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||||
|
|
||||||
|
@ -136,12 +136,12 @@
|
||||||
dupSampleForm_index = 3,
|
dupSampleForm_index = 3,
|
||||||
newSampleFormList = _.clone(sampleFormList);
|
newSampleFormList = _.clone(sampleFormList);
|
||||||
dupSampleForm._id = 'a02df75b44c1d26b6a5e05b8';
|
dupSampleForm._id = 'a02df75b44c1d26b6a5e05b8';
|
||||||
newSampleFormList.splice(3, 0, dupSampleForm);
|
newSampleFormList.splice(3, 0, dupSampleForm);
|
||||||
|
|
||||||
var controller = createListFormsController();
|
var controller = createListFormsController();
|
||||||
|
|
||||||
// Set GET response
|
// Set GET response
|
||||||
$httpBackend.expectGET(/^(\/forms)$/).respond(200, sampleFormList);
|
$httpBackend.expectGET(/^(\/forms)$/).respond(200, sampleFormList);
|
||||||
// Run controller functionality
|
// Run controller functionality
|
||||||
scope.findAll();
|
scope.findAll();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
// Test scope value
|
// Test scope value
|
||||||
expect( scope.myforms.length ).toEqual(newSampleFormList.length);
|
expect( scope.myforms.length ).toEqual(newSampleFormList.length);
|
||||||
for(var i=0; i<scope.myforms.length; i++){
|
for(var i=0; i<scope.myforms.length; i++){
|
||||||
expect( scope.myforms[i] ).toEqualData(newSampleFormList[i]);
|
expect( scope.myforms[i] ).toEqualData(newSampleFormList[i]);
|
||||||
}
|
}
|
||||||
expect( scope.myforms[dupSampleForm_index] ).toEqualData(dupSampleForm);
|
expect( scope.myforms[dupSampleForm_index] ).toEqualData(dupSampleForm);
|
||||||
}));
|
}));
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
// Test scope value
|
// Test scope value
|
||||||
expect( scope.myforms.length ).toEqual(delSampleFormList.length);
|
expect( scope.myforms.length ).toEqual(delSampleFormList.length);
|
||||||
for(var i=0; i<scope.myforms.length; i++){
|
for(var i=0; i<scope.myforms.length; i++){
|
||||||
expect( scope.myforms[i] ).toEqualData(delSampleFormList[i]);
|
expect( scope.myforms[i] ).toEqualData(delSampleFormList[i]);
|
||||||
}
|
}
|
||||||
expect( scope.myforms[0] ).not.toEqualData(delSampleForm);
|
expect( scope.myforms[0] ).not.toEqualData(delSampleForm);
|
||||||
}));
|
}));
|
||||||
|
@ -205,10 +205,10 @@
|
||||||
$modelValue: 'Test Form5'
|
$modelValue: 'Test Form5'
|
||||||
},
|
},
|
||||||
$dirty: true,
|
$dirty: true,
|
||||||
$valid: true,
|
$valid: true
|
||||||
};
|
};
|
||||||
|
|
||||||
//Set $state transition
|
//Set $state transition
|
||||||
$state.expectTransitionTo('viewForm.create');
|
$state.expectTransitionTo('viewForm.create');
|
||||||
|
|
||||||
// Set GET response
|
// Set GET response
|
||||||
|
@ -221,4 +221,4 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': '', 'deletePreserved': false},
|
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': '', 'deletePreserved': false},
|
||||||
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': '', 'deletePreserved': false},
|
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': '', 'deletePreserved': false},
|
||||||
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': '', 'deletePreserved': false}
|
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': '', 'deletePreserved': false}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
//Mock Users Service
|
//Mock Users Service
|
||||||
|
@ -212,7 +212,7 @@
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('on controller instantiation it should populate $scope.myform with current Form', inject(function(Forms) {
|
it('on controller instantiation it should populate $scope.myform with current Form', inject(function(Forms) {
|
||||||
|
|
||||||
var controller = createSubmitFormController();
|
var controller = createSubmitFormController();
|
||||||
|
@ -227,4 +227,4 @@
|
||||||
expect( scope.hideNav ).toEqual(false);
|
expect( scope.hideNav ).toEqual(false);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
password: 'password',
|
password: 'password',
|
||||||
provider: 'local',
|
provider: 'local',
|
||||||
roles: ['user'],
|
roles: ['user'],
|
||||||
_id: 'ed873933b1f1dea0ce12fab9',
|
_id: 'ed873933b1f1dea0ce12fab9'
|
||||||
};
|
};
|
||||||
|
|
||||||
var pdfObj = {
|
var pdfObj = {
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
isGenerated: false,
|
isGenerated: false,
|
||||||
isLive: false,
|
isLive: false,
|
||||||
autofillPDFs: false,
|
autofillPDFs: false,
|
||||||
_id: '525a8422f6d0f87f0e407a33',
|
_id: '525a8422f6d0f87f0e407a33'
|
||||||
};
|
};
|
||||||
|
|
||||||
// The $resource service augments the response object with methods for updating and deleting the resource.
|
// The $resource service augments the response object with methods for updating and deleting the resource.
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||||
beforeEach(module('module-templates'));
|
beforeEach(module('module-templates'));
|
||||||
beforeEach(module('stateMock'));
|
beforeEach(module('stateMock'));
|
||||||
|
|
||||||
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
||||||
//Instantiate directive.
|
//Instantiate directive.
|
||||||
var tmp_scope = $rootScope.$new();
|
var tmp_scope = $rootScope.$new();
|
||||||
|
@ -120,16 +120,16 @@
|
||||||
it('$scope.removePDF() should removed uploaded pdf file', function() {
|
it('$scope.removePDF() should removed uploaded pdf file', function() {
|
||||||
// expect(scope.isInitialized).toBeDefined()
|
// expect(scope.isInitialized).toBeDefined()
|
||||||
// expect(scope.log).toEqual('');
|
// expect(scope.log).toEqual('');
|
||||||
|
|
||||||
scope.myform.pdf = pdfObj;
|
scope.myform.pdf = pdfObj;
|
||||||
scope.myform.isGenerated = true;
|
scope.myform.isGenerated = true;
|
||||||
scope.myform.autofillPDFs = true;
|
scope.myform.autofillPDFs = true;
|
||||||
|
|
||||||
scope.removePDF();
|
scope.removePDF();
|
||||||
|
|
||||||
expect(scope.myform.pdf).toEqual(null);
|
expect(scope.myform.pdf).toEqual(null);
|
||||||
expect(scope.myform.isGenerated).toBe(false);
|
expect(scope.myform.isGenerated).toBe(false);
|
||||||
expect(scope.myform.autofillPDFs).toBe(false);
|
expect(scope.myform.autofillPDFs).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
password: 'password',
|
password: 'password',
|
||||||
provider: 'local',
|
provider: 'local',
|
||||||
roles: ['user'],
|
roles: ['user'],
|
||||||
_id: 'ed873933b1f1dea0ce12fab9',
|
_id: 'ed873933b1f1dea0ce12fab9'
|
||||||
};
|
};
|
||||||
|
|
||||||
var pdfObj = {
|
var pdfObj = {
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
isGenerated: false,
|
isGenerated: false,
|
||||||
isLive: false,
|
isLive: false,
|
||||||
autofillPDFs: false,
|
autofillPDFs: false,
|
||||||
_id: '525a8422f6d0f87f0e407a33',
|
_id: '525a8422f6d0f87f0e407a33'
|
||||||
};
|
};
|
||||||
|
|
||||||
var sampleSubmission = {
|
var sampleSubmission = {
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
||||||
{fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 17.55
|
timeElapsed: 17.55
|
||||||
};
|
};
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
{fieldType:'checkbox', title:'nascar', fieldValue: 0, deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: 0, deletePreserved: false},
|
||||||
{fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 10.33
|
timeElapsed: 10.33
|
||||||
},
|
},
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
||||||
{fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 2.33
|
timeElapsed: 2.33
|
||||||
},
|
},
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
|
||||||
{fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 11.11
|
timeElapsed: 11.11
|
||||||
}];
|
}];
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
beforeEach(module('stateMock'));
|
beforeEach(module('stateMock'));
|
||||||
|
|
||||||
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
||||||
|
|
||||||
// Point global variables to injected services
|
// Point global variables to injected services
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
|
|
||||||
scope.table.masterChecker = true;
|
scope.table.masterChecker = true;
|
||||||
scope.toggleAllCheckers();
|
scope.toggleAllCheckers();
|
||||||
|
|
||||||
$httpBackend.expect('DELETE', /^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200);
|
$httpBackend.expect('DELETE', /^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200);
|
||||||
|
|
||||||
//Run Controller Logic to Test
|
//Run Controller Logic to Test
|
||||||
|
@ -197,4 +197,4 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
password: 'password',
|
password: 'password',
|
||||||
provider: 'local',
|
provider: 'local',
|
||||||
roles: ['user'],
|
roles: ['user'],
|
||||||
_id: 'ed873933b1f1dea0ce12fab9',
|
_id: 'ed873933b1f1dea0ce12fab9'
|
||||||
};
|
};
|
||||||
|
|
||||||
var pdfObj = {
|
var pdfObj = {
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
isGenerated: false,
|
isGenerated: false,
|
||||||
isLive: false,
|
isLive: false,
|
||||||
autofillPDFs: false,
|
autofillPDFs: false,
|
||||||
_id: '525a8422f6d0f87f0e407a33',
|
_id: '525a8422f6d0f87f0e407a33'
|
||||||
};
|
};
|
||||||
|
|
||||||
var sampleSubmission = {
|
var sampleSubmission = {
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: true, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
|
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: true, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
|
||||||
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
|
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 17.55
|
timeElapsed: 17.55
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
|
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
|
||||||
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
|
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 10.33
|
timeElapsed: 10.33
|
||||||
},
|
},
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
|
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
|
||||||
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'true', deletePreserved: false}
|
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'true', deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 2.33
|
timeElapsed: 2.33
|
||||||
},
|
},
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'false', deletePreserved: false},
|
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'false', deletePreserved: false},
|
||||||
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
|
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
|
||||||
],
|
],
|
||||||
admin: sampleUser,
|
admin: sampleUser,
|
||||||
form: sampleForm,
|
form: sampleForm,
|
||||||
timeElapsed: 11.11
|
timeElapsed: 11.11
|
||||||
}];
|
}];
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
beforeEach(module('stateMock'));
|
beforeEach(module('stateMock'));
|
||||||
|
|
||||||
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
|
||||||
|
|
||||||
// Point global variables to injected services
|
// Point global variables to injected services
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpBackend.whenGET('/users/me/').respond('');
|
$httpBackend.whenGET('/users/me/').respond('');
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
scope.submitForm();
|
scope.submitForm();
|
||||||
|
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
expect(scope.myform.submitted).toBe(true);
|
expect(scope.myform.submitted).toBe(true);
|
||||||
expect(scope.error).toEqual('');
|
expect(scope.error).toEqual('');
|
||||||
|
|
|
@ -64,7 +64,7 @@ angular.module('users').factory('Auth', ['$window',
|
||||||
$window.user = null;
|
$window.user = null;
|
||||||
userState.isLoggedIn = false;
|
userState.isLoggedIn = false;
|
||||||
service._currentUser = null;
|
service._currentUser = null;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
logout: function() {
|
logout: function() {
|
||||||
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
$http.get('/auth/signout').success(function(response) {
|
$http.get('/auth/signout').success(function(response) {
|
||||||
|
@ -39,7 +39,7 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
signup: function(credentials) {
|
signup: function(credentials) {
|
||||||
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
$http.post('/auth/signup', credentials).success(function(response) {
|
$http.post('/auth/signup', credentials).success(function(response) {
|
||||||
|
@ -52,7 +52,7 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
resendVerifyEmail: function(_email) {
|
resendVerifyEmail: function(_email) {
|
||||||
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
$http.post('/auth/verify', {email: _email}).success(function(response) {
|
$http.post('/auth/verify', {email: _email}).success(function(response) {
|
||||||
|
@ -64,7 +64,7 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
validateVerifyToken: function(token) {
|
validateVerifyToken: function(token) {
|
||||||
|
|
||||||
//DAVID: TODO: The valid length of a token should somehow be linked to server config values
|
//DAVID: TODO: The valid length of a token should somehow be linked to server config values
|
||||||
//DAVID: TODO: SEMI-URGENT: Should we even be doing this?
|
//DAVID: TODO: SEMI-URGENT: Should we even be doing this?
|
||||||
|
@ -106,11 +106,11 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||||
});
|
});
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return userService;
|
return userService;
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue