got updated deps to work

This commit is contained in:
David Baldwynn 2015-10-31 17:32:37 -07:00
parent 60aef4204b
commit 3ffd4095cb
16 changed files with 269 additions and 251 deletions

View file

@ -7,7 +7,7 @@ var mongoose = require('mongoose'),
errorHandler = require('./errors.server.controller'),
Form = mongoose.model('Form'),
FormSubmission = mongoose.model('FormSubmission'),
pdfFiller = require('node-pdffiller'),
pdfFiller = require('pdffiller'),
config = require('../../config/config'),
fs = require('fs-extra'),
async = require('async'),
@ -25,10 +25,10 @@ exports.uploadPDF = function(req, res, next) {
// console.log('\n\nProperty Descriptor\n-----------');
// console.log(Object.getOwnPropertyDescriptor(req.files.file, 'path'));
if(req.files){
var pdfFile = req.files.file;
if(req.file){
var pdfFile = req.file;
var _user = req.user;
if (req.files.size === 0) {
if (req.file.size === 0) {
next(new Error('File uploaded is EMPTY'));
}else if(req.files.size > 200000000){
next(new Error('File uploaded exceeds MAX SIZE of 200MB'));

View file

@ -5,7 +5,7 @@
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
pdfFiller = require('node-pdffiller'),
pdfFiller = require('pdffiller'),
_ = require('lodash'),
config = require('../../config/config'),
path = require('path'),

View file

@ -4,7 +4,7 @@
* Module dependencies.
*/
var mongoose = require('mongoose'),
relationship = require('mongoose-relationship'),
// relationship = require('mongoose-relationship'),
mUtilities = require('mongoose-utilities'),
_ = require('lodash'),
Schema = mongoose.Schema;

View file

@ -5,7 +5,7 @@
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
pdfFiller = require('node-pdffiller'),
pdfFiller = require('pdffiller'),
satelize = require('satelize'),
_ = require('lodash'),
config = require('../../config/config'),

View file

@ -4,12 +4,30 @@
* Module dependencies.
*/
var users = require('../../app/controllers/users.server.controller'),
forms = require('../../app/controllers/forms.server.controller');
forms = require('../../app/controllers/forms.server.controller'),
multer = require('multer'),
config = require('../../config/config');
// Setting the pdf upload route and folder
var upload = multer({ dest: config.tmpUploadPath,
rename: function (fieldname, filename) {
return Date.now();
},
onFileUploadStart: function (file) {
//Check to make sure we can only upload images and pdfs
console.log(file.originalname + ' is starting ...');
},
onFileUploadComplete: function (file, req, res) {
console.log(file.originalname + ' uploaded to ' + file.path);
// console.log('\n\nheadersSent in onFileUploadComplete: ', res.headersSent);
// res.status(200).send(file);
}
});
module.exports = function(app) {
// Form Routes
app.route('/upload/pdf')
.post(users.requiresLogin, forms.uploadPDF);
.post(users.requiresLogin, upload.single('file'), forms.uploadPDF);
app.route('/forms')
.get(users.requiresLogin, forms.list)

View file

@ -30,7 +30,8 @@
"angular-permission": "~0.3.1",
"angular-input-stars": "*",
"file-saver.js": "~1.20150507.2",
"angular-bootstrap-colorpicker": "~3.0.19"
"angular-bootstrap-colorpicker": "~3.0.19",
"font-awesome": "~4.4.0"
},
"resolutions": {
"angular": "~1.3.17"

View file

@ -18,9 +18,10 @@ var fs = require('fs-extra'),
multer = require('multer'),
passport = require('passport'),
raven = require('raven'),
mongoStore = require('connect-mongo')({
session: session
}),
MongoStore = require('connect-mongo')(session),
// mongoStore = require('connect-mongo')({
// session: session
// }),
flash = require('connect-flash'),
config = require('./config'),
consolidate = require('consolidate'),
@ -140,27 +141,17 @@ module.exports = function(db) {
app.use(helmet.nosniff());
app.use(helmet.ienoopen());
app.disable('x-powered-by');
var SIX_MONTHS = 15778476000;
app.use(helmet.hsts({
maxAge: SIX_MONTHS,
includeSubdomains: true,
force: true
}));
// Setting the app router and static folder
app.use('/', express.static(path.resolve('./public')));
app.use('/uploads', express.static(path.resolve('./uploads')));
// Setting the pdf upload route and folder
app.use(multer({ dest: config.tmpUploadPath,
rename: function (fieldname, filename) {
return Date.now();
},
onFileUploadStart: function (file) {
//Check to make sure we can only upload images and pdfs
console.log(file.originalname + ' is starting ...');
},
onFileUploadComplete: function (file, req, res) {
console.log(file.originalname + ' uploaded to ' + file.path);
// console.log('\n\nheadersSent in onFileUploadComplete: ', res.headersSent);
// res.status(200).send(file);
}
}));
// CookieParser should be above session
app.use(cookieParser());
@ -169,12 +160,12 @@ module.exports = function(db) {
saveUninitialized: true,
resave: true,
secret: config.sessionSecret,
store: new mongoStore({
db: db.connection.db,
store: new MongoStore({
mongooseConnection: db.connection,
collection: config.sessionCollection
}),
cookie: config.sessionCookie,
name: config.sessionName
name: config.sessionName,
}));
// use passport session

View file

@ -1,7 +1,7 @@
{
"name": "NodeForm",
"description": "PDF generated form builder",
"version": "1.0.3",
"version": "1.1.0",
"homepage": "https://github.com/whitef0x0/NodeForm",
"authors": [
"David Baldwynn <polydaic@gmail.com>"
@ -13,7 +13,7 @@
},
"engines": {
"node": "~0.12.6",
"npm": "~1.4.28"
"npm": "~2.11.2"
},
"scripts": {
"start": "grunt",
@ -23,81 +23,79 @@
"dependencies": {
"async": "^1.4.2",
"bcrypt": "^0.8.5",
"body-parser": "~1.9.0",
"bower": "~1.3.8",
"chalk": "~1.0.0",
"compression": "~1.2.0",
"body-parser": "~1.14.1",
"bower": "~1.6.5",
"chalk": "~1.1.1",
"compression": "~1.6.0",
"connect-flash": "~0.1.1",
"connect-mongo": "~0.4.1",
"consolidate": "~0.10.0",
"cookie-parser": "~1.3.2",
"connect-mongo": "~0.8.2",
"consolidate": "~0.13.1",
"cookie-parser": "~1.4.0",
"email-verification": "whitef0x0/node-email-verification",
"express": "~4.10.1",
"express-session": "~1.9.1",
"forever": "~0.11.0",
"fs-extra": "~0.18.3",
"express": "~4.13.3",
"express-session": "~1.12.1",
"forever": "~0.15.1",
"fs-extra": "~0.26.0",
"glob": "~4.0.5",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.13",
"grunt-concurrent": "~1.0.0",
"grunt-contrib-csslint": "~0.3.1",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.1",
"grunt-karma": "~0.9.0",
"grunt-mocha-test": "~0.12.1",
"grunt-newer": "~1.1.1",
"grunt-ng-annotate": "~0.4.0",
"grunt-node-inspector": "~0.1.3",
"grunt-nodemon": "~0.3.0",
"helmet": "~0.5.0",
"karma": "~0.12.0",
"karma-chrome-launcher": "~0.1.2",
"karma-coverage": "~0.2.0",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "^0.2.3",
"karma-phantomjs-launcher": "~0.1.2",
"load-grunt-tasks": "~1.0.0",
"helmet": "~0.13.0",
"load-grunt-tasks": "~3.3.0",
"lodash": "^3.10.1",
"mailosaur": "^1.0.1",
"main-bower-files": "~2.8.2",
"main-bower-files": "~2.9.0",
"math": "0.0.3",
"method-override": "~2.3.0",
"mocha": ">=1.20.0",
"mongoose": "~3.8.8",
"mongoose-utilities": "^0.1.1",
"morgan": "~1.4.1",
"multer": "~0.1.8",
"node-pdffiller": "~0.0.5",
"nodemailer": "~1.3.0",
"nools": "^0.4.1",
"passport": "~0.2.0",
"passport-facebook": "~1.0.2",
"passport-github": "~0.1.5",
"passport-google-oauth": "~0.1.5",
"passport-linkedin": "~0.1.3",
"morgan": "~1.6.1",
"multer": "~1.1.0",
"pdffiller": "~0.1.1",
"nodemailer": "~1.8.0",
"passport": "~0.3.0",
"passport-facebook": "~2.0.0",
"passport-github": "~1.0.0",
"passport-google-oauth": "~0.2.0",
"passport-linkedin": "~1.0.0",
"passport-local": "~1.0.0",
"passport-twitter": "~1.0.2",
"raven": "^0.8.1",
"request": "^2.60.0",
"request-promise": "^0.4.3",
"request-promise": "^1.0.2",
"satelize": "~0.1.1",
"shortid": "^2.2.2",
"should": "~4.1.0",
"soap": "^0.9.1",
"supertest": "~0.14.0",
"supertest-session": "^1.0.0",
"soap": "^0.11.0",
"swig": "~1.4.1",
"then-fs": "~2.0.0"
},
"devDependencies": {
"node-mandrill": "^1.0.1",
"grunt-html2js": "^0.3.5",
"karma-chrome-launcher": "^0.1.12",
"karma-jasmine-html-reporter": "^0.1.8",
"karma-mocha-reporter": "^1.1.1",
"karma-ng-html2js-preprocessor": "^0.1.2",
"node-mandrill": "^1.0.1"
"karma-ng-html2js-preprocessor": "^0.2.0",
"should": "~7.1.1",
"supertest": "~1.1.0",
"supertest-session": "^1.0.0",
"mailosaur": "^1.0.1",
"grunt-mocha-test": "~0.12.1",
"karma": "~0.13.14",
"karma-chrome-launcher": "~0.2.1",
"karma-coverage": "~0.5.3",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "~0.2.1",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.13",
"grunt-concurrent": "~2.0.4",
"grunt-contrib-csslint": "~0.5.0",
"grunt-contrib-cssmin": "~0.14.0",
"grunt-contrib-jshint": "~0.11.3",
"grunt-contrib-uglify": "~0.10.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.1",
"grunt-karma": "~0.12.1",
"grunt-newer": "~1.1.1",
"grunt-ng-annotate": "~1.0.1",
"grunt-node-inspector": "~0.4.1",
"grunt-nodemon": "~0.4.0"
}
}

View file

@ -87,10 +87,11 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
if(user){
authenticator = new Authorizer(user);
console.log('access denied: '+!authenticator.canAccess(permissions));
if( (permissions !== null) && !authenticator.canAccess(permissions) ){
event.preventDefault();
console.log('access denied')
console.log('access denied');
$state.go('access_denied');
}
}
@ -113,7 +114,7 @@ ApplicationConfiguration.registerModule('core', ['users']);
'use strict';
// Use Application configuration module to register a new module
ApplicationConfiguration.registerModule('forms', ['ngFileUpload', 'ui.date', 'ui.sortable', 'angular-input-stars', 'users']);
ApplicationConfiguration.registerModule('forms', ['ngFileUpload', 'colorpicker.module', 'ui.date', 'ui.sortable', 'angular-input-stars', 'users']);
'use strict';
// Use Application configuration module to register a new module
@ -399,11 +400,11 @@ angular.module('forms').run(['Menus',
return 0;
};
}).config(['$provide', function ($provide){
$provide.decorator('accordionDirective', function($delegate) {
$provide.decorator('accordionDirective', ["$delegate", function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}]);
}]);
'use strict';
@ -426,13 +427,27 @@ angular.module('forms').config(['$stateProvider',
data: {
hideNav: true,
},
resolve: {
Forms: 'Forms',
myForm: ["Forms", "$stateParams", function (Forms, $stateParams) {
return Forms.get({formId: $stateParams.formId}).$promise;
}],
},
controller: 'SubmitFormController'
}).
state('viewForm', {
url: '/forms/:formId/admin',
templateUrl: 'modules/forms/views/admin-form.client.view.html',
data: {
permissions: [ 'editForm' ]
}
},
resolve: {
Forms: 'Forms',
myForm: ["Forms", "$stateParams", function (Forms, $stateParams) {
return Forms.get({formId: $stateParams.formId}).$promise;
}],
},
controller: 'AdminFormController'
});
}
@ -440,14 +455,16 @@ angular.module('forms').config(['$stateProvider',
'use strict';
// Forms controller
angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$modal',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $modal) {
angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$modal', 'myForm',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $modal, myForm) {
$scope = $rootScope;
$scope.myform = CurrentForm.getForm();
$scope.myform._id = $stateParams.formId;
$scope.myform = myForm;
$rootScope.saveInProgress = false;
CurrentForm.setForm($scope.myform);
// console.log($scope.myform);
// Find a specific Form
$scope.findOne = function(){
@ -530,7 +547,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
$rootScope.myform = $scope.myform = response.data;
// console.log(response.data);
}).catch(function(response){
// console.log('Error occured during form UPDATE.\n');
console.log('Error occured during form UPDATE.\n');
// console.log(response.data);
err = response.data;
}).finally(function() {
@ -544,6 +561,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
}
};
}
]);
'use strict';
@ -593,7 +611,7 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
console.log($scope.myforms[3]._id);
}).error(function(errorResponse){
console.log(errorResponse);
$scope.error = errorResponse.data.message;
if(errorResponse == null) $scope.error = errorResponse.data.message;
});
}
@ -640,45 +658,42 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
'use strict';
// Forms controller
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$stateParams', '$state', 'Forms', 'CurrentForm', 'Auth',
function($scope, $rootScope, $stateParams, $state, Forms, CurrentForm, Auth) {
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$stateParams', '$state', 'Forms', 'CurrentForm', 'Auth', 'myForm',
function($scope, $rootScope, $stateParams, $state, Forms, CurrentForm, Auth, myForm) {
$scope.authentication = Auth;
$scope.initForm = function(){
Forms.get({
formId: $stateParams.formId
}).$promise.then(
//success
function(form){
$scope.myform = form;
$scope.myform = myForm;
if(!$scope.myform.isLive){
// Show navbar if form is not public AND user IS loggedin
if($scope.authentication.isAuthenticated()){
$scope.hideNav = $rootScope.hideNav = false;
}
// Redirect if form is not public user IS NOT loggedin
else {
$scope.hideNav = $rootScope.hideNav = true;
$state.go('access_denied');
}
}else{
$scope.hideNav = $rootScope.hideNav = true;
}
},
//error
function( error ){
$scope.error = error.message;
console.error('ERROR: '+error.message);
$state.go('access_denied');
}
);
};
if(!$scope.myform.isLive){
// Show navbar if form is not public AND user IS loggedin
if($scope.authentication.isAuthenticated()){
$scope.hideNav = $rootScope.hideNav = false;
}
// Redirect if form is not public user IS NOT loggedin
else {
$scope.hideNav = $rootScope.hideNav = true;
$state.go('access_denied');
}
}else{
$scope.hideNav = $rootScope.hideNav = true;
}
}
]);
'use strict';
_.mixin({ removeDateFields : function(o){
var clone = _.clone(o);
for(var i=0; i<clone.length; i++){
_.each(clone[i], function(v,k){
// console.log('key: '+k);
if(k === 'lastModified' || k === 'created'){
delete clone[i][k];
}
});
}
return clone;
}});
angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', function($rootScope, $timeout) {
return {
@ -693,10 +708,10 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
savePromise = null;
$rootScope.finishedRender = false;
$scope.$on('editFormFieldsStarted', function(ngRepeatFinishedEvent) {
$scope.$on('editFormFields Started', function(ngRepeatFinishedEvent) {
$rootScope.finishedRender = false;
});
$scope.$on('editFormFieldsFinished', function(ngRepeatFinishedEvent) {
$scope.$on('editFormFields Finished', function(ngRepeatFinishedEvent) {
$rootScope.finishedRender = true;
});
@ -713,7 +728,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
return false;
};
this.debounceSave = function () {
var debounceSave = function () {
$rootScope.saveInProgress = true;
$rootScope[$attrs.autoSaveCallback](true,
function(err){
@ -727,40 +742,57 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
});
};
//Update/save Form if any Form fields are Dirty and Touched
//Update/Save Form if any Form fields are Dirty and Touched
$scope.$watch(function(newValue, oldValue) {
if($scope.anyDirtyAndTouched($scope.editForm) && !$rootScope.saveInProgress){
this.debounceSave();
// console.log($scope);
console.log($scope.editForm);
if($rootScope.finishedRender && $scope.anyDirtyAndTouched($scope.editForm) && !$rootScope.saveInProgress){
console.log('Form saving started');
debounceSave();
}
});
//Autosave Form when model (specificed in $attrs.autoSaveWatch) changes
$scope.$watch($attrs.autoSaveWatch, function(newValue, oldValue) {
var changedFields = !_.isEqual(oldValue,newValue);
newValue = angular.copy(newValue);
oldValue = angular.copy(oldValue);
newValue.form_fields = _.removeDateFields(newValue.form_fields);
oldValue.form_fields = _.removeDateFields(oldValue.form_fields);
var changedFields = !_.isEqual(oldValue.form_fields,newValue.form_fields) || !_.isEqual(oldValue.startPage, newValue.startPage);
var changedFieldMap = !!oldValue.plugins.oscarhost.settings.fieldMap && !_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap);
if( (!newValue && !oldValue) || !oldValue ){
return;
}
// console.log('Autosaving');
// console.log('\n\n----------');
// console.log('$dirty: '+ $formCtrl.$dirty );
// console.log('!$dirty: '+ !$formCtrl.$dirty );
// console.log('changedFields: '+changedFields);
// console.log('changedFieldMap: '+changedFieldMap);
// console.log('finishedRender: '+$rootScope.finishedRender);
// console.log('saveInProgress: '+$rootScope.saveInProgress);
// console.log('!saveInProgress: '+!$rootScope.saveInProgress);
// console.log('newValue: '+newValue);
// console.log('oldValue: '+oldValue);
// console.log(oldValue.form_fields);
// console.log(newValue.form_fields);
if(oldValue.form_fields.length === 0) $rootScope.finishedRender = true
//Save form ONLY IF rendering is finished, form_fields have been change AND currently not save in progress
if($rootScope.finishedRender && (changedFields && !$formCtrl.$dirty) && !$rootScope.saveInProgress) {
//Save form ONLY IF rendering is finished, form_fields have been changed AND currently not save in progress
if( $rootScope.finishedRender && ((changedFields && !$formCtrl.$dirty) || changedFieldMap) && !$rootScope.saveInProgress) {
// console.log('saving form now');
if(savePromise) {
$timeout.cancel(savePromise);
savePromise = null;
}
savePromise = $timeout(function() {
console.log('Saving Form');
this.debounceSave();
// console.log('Saving Form');
debounceSave();
});
}
//If we are finished rendering then form saving should be finished
@ -781,8 +813,8 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
'use strict';
angular.module('forms').directive('configureFormDirective', ['$rootScope', '$http', 'Upload', '$timeout', 'TimeCounter', 'Auth', 'FormFields',
function ($rootScope, $http, Upload, $timeout, TimeCounter, Auth, FormFields) {
angular.module('forms').directive('configureFormDirective', ['$rootScope', '$http', 'Upload', '$timeout', 'TimeCounter', 'Auth', 'FormFields', 'CurrentForm',
function ($rootScope, $http, Upload, $timeout, TimeCounter, Auth, FormFields, CurrentForm) {
return {
templateUrl: 'modules/forms/views/directiveViews/form/configure-form.client.view.html',
restrict: 'E',
@ -792,7 +824,13 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
pdfFields:'@',
formFields:'@'
},
controller: function($scope){
controller: ["$scope", function($scope){
console.log($scope.myform);
if( CurrentForm.getForm().plugins){
if(CurrentForm.getForm().plugins.oscarhost.baseUrl) $scope.oscarhostAPI = true;
}else{
$scope.oscarhostAPI = false;
}
$scope.log = '';
$scope.pdfLoading = false;
$scope.languages = $rootScope.languages;
@ -864,7 +902,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
}
};
}
}]
};
}
]);
@ -878,8 +916,11 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
scope: {
myform:'=',
},
controller: function($scope){
controller: ["$scope", function($scope){
var field_ids = _($scope.myform.form_fields).pluck('_id');
for(var i=0; i<field_ids.length; i++){
$scope.myform.plugins.oscarhost.settings.fieldMap[field_ids[i]] = null;
}
/*
** Initialize scope with variables
*/
@ -901,6 +942,26 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
//Populate local scope with rootScope methods/variables
$scope.update = $rootScope.update;
//Many-to-many Select for Mapping OscarhostFields -> FormFields
$scope.oscarFieldsLeft = function(field_id){
if($scope.myform && $scope.myform.plugins.oscarhost.settings.validFields.length > 0){
if(!$scope.myform.plugins.oscarhost.settings.fieldMap) $scope.myform.plugins.oscarhost.settings.fieldMap = {};
var oscarhostFields = $scope.myform.plugins.oscarhost.settings.validFields;
var currentFields = _($scope.myform.plugins.oscarhost.settings.fieldMap).invert().keys().value();
if( $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id) ){
currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]);
}
// console.log($scope.myform.plugins.oscarhost.settings.fieldMap);
//Get all oscarhostFields that haven't been mapped to a formfield
return _(oscarhostFields).difference(currentFields).value();
}
return [];
};
/*
** FormFields (ui-sortable) drag-and-drop configuration
*/
@ -908,7 +969,6 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
handle: ' .handle'
};
// $scope.draggable = {
// connectWith: ".dropzone",
// start: function (e, ui) {
@ -981,7 +1041,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
};
// console.log('\n\n---------\nAdded field CLIENT');
// console.log(newField);
newField._id = _.uniqueId();
// newField._id = _.uniqueId();
// put newField into fields array
if(modifyForm){
@ -992,6 +1052,12 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
// Delete particular field on button click
$scope.deleteField = function (field_index){
console.log(field_index);
//Delete field from field map
var currFieldId = $scope.myform.form_fields[field_index]._id
if($scope.myform.plugins.oscarhost.baseUrl) delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId];
//Delete field
$scope.myform.form_fields.splice(field_index, 1);
};
$scope.duplicateField = function (field_index){
@ -1054,8 +1120,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
var newOption = {
'option_id' : option_id,
'option_title' : 'Option ' + option_id,
'option_value' : option_id
'option_value' : 'Option ' + option_id,
};
// put new option into fieldOptions array
@ -1081,7 +1146,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
}
};
},
}],
};
}
@ -1097,7 +1162,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
myform:'=',
user:'='
},
controller: function($scope){
controller: ["$scope", function($scope){
$scope.table = {
masterChecker: false,
rows: []
@ -1198,60 +1263,13 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
saveAs(blob, $scope.myform.title+'_sumbissions_export_'+Date.now()+'.'+type);
};
}
}]
};
}
]);
// 'use strict';
// angular.module('forms').directive('entryPage', ['$templateCache', '$http', '$compile', '$rootScope',
// function($templateCache, $http, $compile, $rootScope) {
// var getTemplateUrl = function(type) {
// var templateUrl = 'modules/forms/views/directiveViews/entryPage/';
// var supported_pages = [
// 'welcome',
// 'thankyou'
// ];
// if (__indexOf.call(supported_pages, type) >= 0) {
// templateUrl += type + '.html';
// }
// var template = $templateCache.get(templateUrl);
// return template;
// };
// return {
// restrict: 'E',
// template: '<div>Start Page</div>',
// scope: {
// 'pageData': '=',
// 'pageType': '&'
// },
// link: function(scope, element) {
// // console.log(attrs);
// console.log('scope.pageData');
// // console.log(scope);
// scope.exitStartPage = function() {
// // console.log(scope.pageData);
// // if(attrs.pageData.showStart) attrs.pageData.showStart = false;
// };
// var template = getTemplateUrl(scope.pageType);
// element.html(template);
// $compile(element.contents())(scope);
// },
// controller: function($scope){
// console.log('entryPage Controller');
// console.log($scope.pageData);
// // $scope.exitStartPage = function() {
// // if($scope.pageData.showStart) scope.pageData.showStart = false;
// // };
// }
// };
// }]);
'use strict';
angular.module('forms').directive('fieldIconDirective', function($http, $compile) {
angular.module('forms').directive('fieldIconDirective', ["$http", "$compile", function($http, $compile) {
return {
template: '<i class="{{typeIcon}}"></i>',
@ -1259,7 +1277,7 @@ angular.module('forms').directive('fieldIconDirective', function($http, $compile
scope: {
typeName: '@'
},
controller: function($scope){
controller: ["$scope", function($scope){
var iconTypeMap = {
'textfield': 'fa fa-pencil-square-o',
'dropdown': 'fa fa-th-list',
@ -1279,10 +1297,10 @@ angular.module('forms').directive('fieldIconDirective', function($http, $compile
'number': 'fa fa-slack'
};
$scope.typeIcon = iconTypeMap[$scope.typeName];
},
}],
};
});
}]);
'use strict';
// coffeescript's for in loop
@ -1298,7 +1316,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
var getTemplateUrl = function(field) {
console.log(field.validFieldTypes);
var type = field.fieldType;
var templateUrl = 'modules/forms/views/directiveViews/field/';
var supported_fields = [
@ -1307,6 +1325,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
'textarea',
'checkbox',
'date',
'link',
'dropdown',
'hidden',
'password',
@ -1319,10 +1338,9 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
'natural'
];
if (__indexOf.call(supported_fields, type) >= 0) {
templateUrl += type + '.html';
templateUrl = templateUrl+type+'.html';
}
var template = $templateCache.get(templateUrl);
return template;
return templateUrl;
};
var linker = function(scope, element) {
@ -1338,24 +1356,13 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
defaultDate: 0,
};
}
//DAVID: TODO: Make natural language processing work
//Set only if we have a natural lang processing field
// else if(scope.field.fieldType === 'natural'){
// scope.field.fieldMatchValue = '';
// //Fires when field is changed
// scope.$watch('scope.field', function(newField, oldField) {
// });
// }
// GET template content from path
var template = getTemplateUrl(scope.field);
// $http.get(templateUrl).success(function(data) {
element.html(template).show();
// console.log(element.contents());
$compile(element.contents())(scope);
// });
var templateUrl = getTemplateUrl(scope.field);
$http.get(templateUrl).success(function(data) {
element.html(data).show();
$compile(element.contents())(scope);
});
};
return {
@ -1363,14 +1370,15 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
restrict: 'E',
scope: {
field: '=',
required: '&'
required: '&',
design: '='
},
link: linker
};
}]);
'use strict';
angular.module('forms').directive('onFinishRender', function ($rootScope, $timeout) {
angular.module('forms').directive('onFinishRender', ["$rootScope", "$timeout", function ($rootScope, $timeout) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
@ -1383,17 +1391,16 @@ angular.module('forms').directive('onFinishRender', function ($rootScope, $timeo
}
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
if(scope.$first) {
if(scope.$first && !scope.$last) {
scope.$evalAsync(function () {
// console.log(broadcastMessage+' Started');
// console.log(Date.now());
$rootScope.$broadcast(broadcastMessage+' Started');
});
}else if(scope.$last) {
scope.$evalAsync(function () {
// element.ready(function () {
// console.log(broadcastMessage+'Finished');
console.log(broadcastMessage+'Finished');
// console.log(Date.now());
$rootScope.$broadcast(broadcastMessage+' Finished');
// });
@ -1401,7 +1408,7 @@ angular.module('forms').directive('onFinishRender', function ($rootScope, $timeo
}
}
};
});
}]);
'use strict';
@ -1413,7 +1420,7 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', '
scope: {
myform:'='
},
controller: function($scope){
controller: ["$scope", function($scope){
angular.element(document).ready(function() {
$scope.error = '';
$scope.selected = null;
@ -1469,7 +1476,7 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', '
};
});
}
}]
};
}
]);
@ -1599,6 +1606,7 @@ angular.module('forms').factory('Forms', ['$resource',
method: 'GET',
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);
@ -1664,7 +1672,7 @@ angular.module('forms').service('TimeCounter', [
// Config HTTP Error Handling
angular.module('users').config(['$httpProvider',
function($httpProvider) {
$httpProvider.interceptors.push(function($q, $location) {
$httpProvider.interceptors.push(["$q", "$location", function($q, $location) {
return {
responseError: function(response) {
// console.log($location.path());
@ -1684,7 +1692,7 @@ angular.module('users').config(['$httpProvider',
return $q.reject(response);
}
};
});
}]);
}]);
'use strict';
@ -1714,6 +1722,7 @@ angular.module('users').config(['$stateProvider',
return deferred.promise;
};
checkLoggedin.$inject = ["$q", "$timeout", "$state", "User", "Auth"];
// Users state routing
$stateProvider.
@ -2065,7 +2074,7 @@ angular.module('users').factory('Auth', ['$window',
'use strict';
angular.module('users').service('Authorizer', function(APP_PERMISSIONS, USER_ROLES) {
angular.module('users').service('Authorizer', ["APP_PERMISSIONS", "USER_ROLES", function(APP_PERMISSIONS, USER_ROLES) {
return function(user) {
return {
canAccess: function(permissions) {
@ -2096,7 +2105,7 @@ angular.module('users').service('Authorizer', function(APP_PERMISSIONS, USER_ROL
}
};
};
});
}]);
'use strict';
angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '$state',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -45,7 +45,7 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
console.log($scope.myforms[3]._id);
}).error(function(errorResponse){
console.log(errorResponse);
$scope.error = errorResponse.data.message;
if(errorResponse == null) $scope.error = errorResponse.data.message;
});
}

View file

@ -73,7 +73,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
$scope.log = 'file ' + data.originalname + ' uploaded as '+ data.name +'. JSON: ' + JSON.stringify(data) + '\n' + $scope.log;
$scope.myform.pdf = angular.fromJson(angular.toJson(data));
console.log($scope.myform.pdf);
// console.log($scope.myform.pdf);
$scope.pdfLoading = false;

View file

@ -144,9 +144,10 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
// Delete particular field on button click
$scope.deleteField = function (field_index){
console.log(field_index);
//Delete field from field map
var currFieldId = $scope.myform.form_fields[field_index]._id
delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId];
if($scope.myform.plugins.oscarhost.baseUrl) delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId];
//Delete field
$scope.myform.form_fields.splice(field_index, 1);

View file

@ -6,11 +6,11 @@
</div>
<div class="col-xs-6 field-input container">
<div class="row-fluid">
<label class="btn col-xs-4">
<label class="btn col-xs-6">
<input ng-focus="setActiveField(field._id)" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" type="radio" value="true" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"/>
<span> I accept </span>
</label>
<label class="btn col-xs-5 col-xs-offset-1">
<label class="btn col-xs-6 col-xs-offset-1">
<input ng-focus="setActiveField(field._id)" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" type="radio" value="false" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"/>
<span>I don't accept </span>
</label>

View file

@ -4,7 +4,7 @@
<h2 class="text-center col-xs-8 ">{{field.title}} </h2>
<i class="fa fa-quote-right fa-3 col-xs-1"></i>
</div>
<div class="col-xs-10row field-title field-input">
<div class="col-xs-10 row field-title field-input">
<p class="col-sm-12">{{field.description}} </p>
<!-- <br>