fixed autosaving bug for configure tab
This commit is contained in:
parent
b6e6fb93a6
commit
fbc5641388
|
@ -162,6 +162,14 @@ exports.read = function(req, res) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload temp file for submissions
|
||||
*/
|
||||
exports.uploadTemp = function(req, res) {
|
||||
//Send uploaded file data back to form
|
||||
res.json(req.file);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the current form for rendering form live
|
||||
*/
|
||||
|
@ -189,7 +197,6 @@ exports.readForRender = function(req, res) {
|
|||
exports.update = function(req, res) {
|
||||
var form = req.form;
|
||||
|
||||
|
||||
if (req.body.changes) {
|
||||
console.log(req.body.changes);
|
||||
var formChanges = req.body.changes;
|
||||
|
|
|
@ -7,22 +7,27 @@ var users = require('../../app/controllers/users.server.controller'),
|
|||
forms = require('../../app/controllers/forms.server.controller'),
|
||||
multer = require('multer'),
|
||||
config = require('../../config/config'),
|
||||
auth = require('../../config/passport_helpers');
|
||||
auth = require('../../config/passport_helpers'),
|
||||
multerS3 = require('multer-s3'),
|
||||
aws = require('aws-sdk');
|
||||
|
||||
// Setting the pdf upload route and folder
|
||||
var storage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
cb(null, config.tmpUploadPath);
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
var len = file.originalname.split('.').length;
|
||||
var ext = file.originalname.split('.')[len-1];
|
||||
cb(null, Date.now()+ '-' + file.fieldname + '.'+ext);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Amazon S3 Uploads
|
||||
aws.config.update({region: 'us-west-2'});
|
||||
var s3 = new aws.S3();
|
||||
|
||||
var upload = multer({
|
||||
storage: storage
|
||||
storage: multerS3({
|
||||
s3: s3,
|
||||
bucket: 'tellform-test',
|
||||
metadata: function (req, file, cb) {
|
||||
cb(null, {fieldName: file.fieldname});
|
||||
},
|
||||
key: function (req, file, cb) {
|
||||
cb(null, Date.now().toString())
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
module.exports = function(app) {
|
||||
|
@ -41,6 +46,9 @@ module.exports = function(app) {
|
|||
.get(auth.isAuthenticatedOrApiKey, forms.hasAuthorization, forms.listSubmissions)
|
||||
.delete(auth.isAuthenticatedOrApiKey, forms.hasAuthorization, forms.deleteSubmissions);
|
||||
|
||||
app.route('/forms/:formId([a-zA-Z0-9]+)/submissions/upload')
|
||||
.post(upload.single('file'), forms.uploadTemp);
|
||||
|
||||
// Finish by binding the form middleware
|
||||
app.param('formId', forms.formByID);
|
||||
};
|
||||
|
|
5
config/env/all.js
vendored
5
config/env/all.js
vendored
|
@ -14,6 +14,11 @@ module.exports = {
|
|||
pass: ''
|
||||
}
|
||||
},
|
||||
aws: {
|
||||
"accessKeyId": process.env.AWS_ACCESS_ID,
|
||||
"secretAccessKey": process.env.AWS_SECRET_KEY,
|
||||
"region": process.env.AWS_REGION
|
||||
},
|
||||
|
||||
port: process.env.PORT || 3000,
|
||||
socketPort: process.env.SOCKET_PORT || 20523,
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
"dependencies": {
|
||||
"async": "^1.4.2",
|
||||
"async-boolean-expression-evaluator": "^1.1.1",
|
||||
"aws-sdk": "^2.3.9",
|
||||
"aws-sdk": "^2.26.0",
|
||||
"bcrypt": "^0.8.7",
|
||||
"bcrypt-nodejs": "0.0.3",
|
||||
"body-parser": "~1.14.1",
|
||||
|
@ -74,6 +74,7 @@
|
|||
"mongoose-utilities": "~0.1.1",
|
||||
"morgan": "~1.6.1",
|
||||
"multer": "~1.1.0",
|
||||
"multer-s3": "^2.5.0",
|
||||
"nodemailer": "~1.10.0",
|
||||
"nodemailer-sendgrid-transport": "^0.2.0",
|
||||
"nodemailer-sparkpost-transport": "^1.0.0",
|
||||
|
|
50
public/dist/application.js
vendored
50
public/dist/application.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/application.min.js
vendored
8
public/dist/application.min.js
vendored
File diff suppressed because one or more lines are too long
6
public/dist/form-application.js
vendored
6
public/dist/form-application.js
vendored
File diff suppressed because one or more lines are too long
4
public/dist/form-application.min.js
vendored
4
public/dist/form-application.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -79,12 +79,12 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
|
|||
delete oldValue.visible_form_fields;
|
||||
newValue.form_fields = _.removeDateFields(newValue.form_fields);
|
||||
oldValue.form_fields = _.removeDateFields(oldValue.form_fields);
|
||||
|
||||
var changedFields = !!DeepDiff.diff(oldValue, newValue) && DeepDiff.diff(oldValue, newValue).length > 0;
|
||||
|
||||
console.log(DeepDiff.diff(oldValue, newValue));
|
||||
//If our form is undefined, don't save form
|
||||
if(!changedFields){
|
||||
var changedStartPage = !!DeepDiff.diff(oldValue.startPage, newValue.startPage) && DeepDiff.diff(oldValue.startPage, newValue.startPage).length > 0;
|
||||
var changedFields = !!DeepDiff.diff(oldValue.form_fields, newValue.form_fields) && DeepDiff.diff(oldValue.form_fields, newValue.form_fields).length > 0;
|
||||
|
||||
//If our form's startPage or form fields have not changed, don't autosave form
|
||||
if(!changedFields && !changedStartPage){
|
||||
$rootScope.finishedRender = true;
|
||||
return;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
|
|||
// console.log(newValue.form_fields);
|
||||
|
||||
//Save form ONLY IF rendering is finished, form_fields have been changed AND currently not save in progress
|
||||
if( $rootScope.finishedRender && (changedFields) && !$rootScope.saveInProgress) {
|
||||
if( $rootScope.finishedRender && (changedFields || changedStartPage) && !$rootScope.saveInProgress) {
|
||||
|
||||
if(savePromise) {
|
||||
$timeout.cancel(savePromise);
|
||||
|
@ -116,8 +116,6 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
|
|||
savePromise = $timeout(function() {
|
||||
$rootScope.saveInProgress = true;
|
||||
|
||||
delete newValue.visible_form_fields;
|
||||
delete newValue.visible_form_fields;
|
||||
var _diff = DeepDiff.diff(oldValue, newValue);
|
||||
debounceSave(_diff);
|
||||
});
|
||||
|
|
|
@ -40,10 +40,10 @@ angular.module('forms').service('FormFields', [
|
|||
// name : 'sig',
|
||||
// value : 'Signature'
|
||||
// },
|
||||
// {
|
||||
// name : 'file',
|
||||
// value : 'File Upload'
|
||||
// },
|
||||
{
|
||||
name : 'file',
|
||||
value : 'File Upload'
|
||||
},
|
||||
{
|
||||
name : 'rating',
|
||||
value : 'Rating'
|
||||
|
@ -62,13 +62,13 @@ angular.module('forms').service('FormFields', [
|
|||
// },
|
||||
// {
|
||||
// name : 'stripe',
|
||||
// value : 'Payment'
|
||||
// value : 'Payment'
|
||||
// },
|
||||
{
|
||||
name : 'statement',
|
||||
value : 'Statement'
|
||||
value : 'Statement'
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
]);
|
||||
|
|
|
@ -17,6 +17,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
|
|||
var supported_fields = [
|
||||
'textfield',
|
||||
'textarea',
|
||||
'file',
|
||||
'date',
|
||||
'dropdown',
|
||||
'hidden',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="field row" ng-if="form.autofillPDFs" ng-click="setActiveField(field._id, index, true)">
|
||||
<div class="field row" ng-click="setActiveField(field._id, index, true)">
|
||||
<div class="col-xs-12 field-title" ng-style="{'color': design.colors.questionColor}">
|
||||
<h3>
|
||||
<small class="field-number">
|
||||
|
@ -12,8 +12,8 @@
|
|||
<div class="col-sm-8 field-input">
|
||||
<div class="input-group ">
|
||||
<div tabindex="-1" class="form-control file-caption">
|
||||
<span class="file-caption-ellipsis" ng-if="!form.pdf">…</span>
|
||||
<div class="file-caption-name" ng-if="form.pdf">
|
||||
<span class="file-caption-ellipsis" ng-if="!field.file">…</span>
|
||||
<div class="file-caption-name" ng-if="field.file">
|
||||
{{field.file.originalname}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue