got updated deps to work
This commit is contained in:
parent
60aef4204b
commit
3ffd4095cb
|
@ -7,7 +7,7 @@ var mongoose = require('mongoose'),
|
||||||
errorHandler = require('./errors.server.controller'),
|
errorHandler = require('./errors.server.controller'),
|
||||||
Form = mongoose.model('Form'),
|
Form = mongoose.model('Form'),
|
||||||
FormSubmission = mongoose.model('FormSubmission'),
|
FormSubmission = mongoose.model('FormSubmission'),
|
||||||
pdfFiller = require('node-pdffiller'),
|
pdfFiller = require('pdffiller'),
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
fs = require('fs-extra'),
|
fs = require('fs-extra'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
|
@ -25,10 +25,10 @@ exports.uploadPDF = function(req, res, next) {
|
||||||
// console.log('\n\nProperty Descriptor\n-----------');
|
// console.log('\n\nProperty Descriptor\n-----------');
|
||||||
// console.log(Object.getOwnPropertyDescriptor(req.files.file, 'path'));
|
// console.log(Object.getOwnPropertyDescriptor(req.files.file, 'path'));
|
||||||
|
|
||||||
if(req.files){
|
if(req.file){
|
||||||
var pdfFile = req.files.file;
|
var pdfFile = req.file;
|
||||||
var _user = req.user;
|
var _user = req.user;
|
||||||
if (req.files.size === 0) {
|
if (req.file.size === 0) {
|
||||||
next(new Error('File uploaded is EMPTY'));
|
next(new Error('File uploaded is EMPTY'));
|
||||||
}else if(req.files.size > 200000000){
|
}else if(req.files.size > 200000000){
|
||||||
next(new Error('File uploaded exceeds MAX SIZE of 200MB'));
|
next(new Error('File uploaded exceeds MAX SIZE of 200MB'));
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
var mongoose = require('mongoose'),
|
var mongoose = require('mongoose'),
|
||||||
Schema = mongoose.Schema,
|
Schema = mongoose.Schema,
|
||||||
pdfFiller = require('node-pdffiller'),
|
pdfFiller = require('pdffiller'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
var mongoose = require('mongoose'),
|
var mongoose = require('mongoose'),
|
||||||
relationship = require('mongoose-relationship'),
|
// relationship = require('mongoose-relationship'),
|
||||||
mUtilities = require('mongoose-utilities'),
|
mUtilities = require('mongoose-utilities'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
Schema = mongoose.Schema;
|
Schema = mongoose.Schema;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
var mongoose = require('mongoose'),
|
var mongoose = require('mongoose'),
|
||||||
Schema = mongoose.Schema,
|
Schema = mongoose.Schema,
|
||||||
pdfFiller = require('node-pdffiller'),
|
pdfFiller = require('pdffiller'),
|
||||||
satelize = require('satelize'),
|
satelize = require('satelize'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
|
|
|
@ -4,12 +4,30 @@
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
var users = require('../../app/controllers/users.server.controller'),
|
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) {
|
module.exports = function(app) {
|
||||||
// Form Routes
|
// Form Routes
|
||||||
app.route('/upload/pdf')
|
app.route('/upload/pdf')
|
||||||
.post(users.requiresLogin, forms.uploadPDF);
|
.post(users.requiresLogin, upload.single('file'), forms.uploadPDF);
|
||||||
|
|
||||||
app.route('/forms')
|
app.route('/forms')
|
||||||
.get(users.requiresLogin, forms.list)
|
.get(users.requiresLogin, forms.list)
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
"angular-permission": "~0.3.1",
|
"angular-permission": "~0.3.1",
|
||||||
"angular-input-stars": "*",
|
"angular-input-stars": "*",
|
||||||
"file-saver.js": "~1.20150507.2",
|
"file-saver.js": "~1.20150507.2",
|
||||||
"angular-bootstrap-colorpicker": "~3.0.19"
|
"angular-bootstrap-colorpicker": "~3.0.19",
|
||||||
|
"font-awesome": "~4.4.0"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"angular": "~1.3.17"
|
"angular": "~1.3.17"
|
||||||
|
|
|
@ -18,9 +18,10 @@ var fs = require('fs-extra'),
|
||||||
multer = require('multer'),
|
multer = require('multer'),
|
||||||
passport = require('passport'),
|
passport = require('passport'),
|
||||||
raven = require('raven'),
|
raven = require('raven'),
|
||||||
mongoStore = require('connect-mongo')({
|
MongoStore = require('connect-mongo')(session),
|
||||||
session: session
|
// mongoStore = require('connect-mongo')({
|
||||||
}),
|
// session: session
|
||||||
|
// }),
|
||||||
flash = require('connect-flash'),
|
flash = require('connect-flash'),
|
||||||
config = require('./config'),
|
config = require('./config'),
|
||||||
consolidate = require('consolidate'),
|
consolidate = require('consolidate'),
|
||||||
|
@ -140,27 +141,17 @@ module.exports = function(db) {
|
||||||
app.use(helmet.nosniff());
|
app.use(helmet.nosniff());
|
||||||
app.use(helmet.ienoopen());
|
app.use(helmet.ienoopen());
|
||||||
app.disable('x-powered-by');
|
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
|
// Setting the app router and static folder
|
||||||
app.use('/', express.static(path.resolve('./public')));
|
app.use('/', express.static(path.resolve('./public')));
|
||||||
app.use('/uploads', express.static(path.resolve('./uploads')));
|
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
|
// CookieParser should be above session
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
|
@ -169,12 +160,12 @@ module.exports = function(db) {
|
||||||
saveUninitialized: true,
|
saveUninitialized: true,
|
||||||
resave: true,
|
resave: true,
|
||||||
secret: config.sessionSecret,
|
secret: config.sessionSecret,
|
||||||
store: new mongoStore({
|
store: new MongoStore({
|
||||||
db: db.connection.db,
|
mongooseConnection: db.connection,
|
||||||
collection: config.sessionCollection
|
collection: config.sessionCollection
|
||||||
}),
|
}),
|
||||||
cookie: config.sessionCookie,
|
cookie: config.sessionCookie,
|
||||||
name: config.sessionName
|
name: config.sessionName,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// use passport session
|
// use passport session
|
||||||
|
|
110
package.json
110
package.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "NodeForm",
|
"name": "NodeForm",
|
||||||
"description": "PDF generated form builder",
|
"description": "PDF generated form builder",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"homepage": "https://github.com/whitef0x0/NodeForm",
|
"homepage": "https://github.com/whitef0x0/NodeForm",
|
||||||
"authors": [
|
"authors": [
|
||||||
"David Baldwynn <polydaic@gmail.com>"
|
"David Baldwynn <polydaic@gmail.com>"
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "~0.12.6",
|
"node": "~0.12.6",
|
||||||
"npm": "~1.4.28"
|
"npm": "~2.11.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "grunt",
|
"start": "grunt",
|
||||||
|
@ -23,81 +23,79 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^1.4.2",
|
"async": "^1.4.2",
|
||||||
"bcrypt": "^0.8.5",
|
"bcrypt": "^0.8.5",
|
||||||
"body-parser": "~1.9.0",
|
"body-parser": "~1.14.1",
|
||||||
"bower": "~1.3.8",
|
"bower": "~1.6.5",
|
||||||
"chalk": "~1.0.0",
|
"chalk": "~1.1.1",
|
||||||
"compression": "~1.2.0",
|
"compression": "~1.6.0",
|
||||||
"connect-flash": "~0.1.1",
|
"connect-flash": "~0.1.1",
|
||||||
"connect-mongo": "~0.4.1",
|
"connect-mongo": "~0.8.2",
|
||||||
"consolidate": "~0.10.0",
|
"consolidate": "~0.13.1",
|
||||||
"cookie-parser": "~1.3.2",
|
"cookie-parser": "~1.4.0",
|
||||||
"email-verification": "whitef0x0/node-email-verification",
|
"email-verification": "whitef0x0/node-email-verification",
|
||||||
"express": "~4.10.1",
|
"express": "~4.13.3",
|
||||||
"express-session": "~1.9.1",
|
"express-session": "~1.12.1",
|
||||||
"forever": "~0.11.0",
|
"forever": "~0.15.1",
|
||||||
"fs-extra": "~0.18.3",
|
"fs-extra": "~0.26.0",
|
||||||
"glob": "~4.0.5",
|
"glob": "~4.0.5",
|
||||||
"grunt": "~0.4.1",
|
"helmet": "~0.13.0",
|
||||||
"grunt-cli": "~0.1.13",
|
"load-grunt-tasks": "~3.3.0",
|
||||||
"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",
|
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^3.10.1",
|
||||||
"mailosaur": "^1.0.1",
|
"main-bower-files": "~2.9.0",
|
||||||
"main-bower-files": "~2.8.2",
|
|
||||||
"math": "0.0.3",
|
"math": "0.0.3",
|
||||||
"method-override": "~2.3.0",
|
"method-override": "~2.3.0",
|
||||||
"mocha": ">=1.20.0",
|
"mocha": ">=1.20.0",
|
||||||
"mongoose": "~3.8.8",
|
"mongoose": "~3.8.8",
|
||||||
"mongoose-utilities": "^0.1.1",
|
"mongoose-utilities": "^0.1.1",
|
||||||
"morgan": "~1.4.1",
|
"morgan": "~1.6.1",
|
||||||
"multer": "~0.1.8",
|
"multer": "~1.1.0",
|
||||||
"node-pdffiller": "~0.0.5",
|
"pdffiller": "~0.1.1",
|
||||||
"nodemailer": "~1.3.0",
|
"nodemailer": "~1.8.0",
|
||||||
"nools": "^0.4.1",
|
"passport": "~0.3.0",
|
||||||
"passport": "~0.2.0",
|
"passport-facebook": "~2.0.0",
|
||||||
"passport-facebook": "~1.0.2",
|
"passport-github": "~1.0.0",
|
||||||
"passport-github": "~0.1.5",
|
"passport-google-oauth": "~0.2.0",
|
||||||
"passport-google-oauth": "~0.1.5",
|
"passport-linkedin": "~1.0.0",
|
||||||
"passport-linkedin": "~0.1.3",
|
|
||||||
"passport-local": "~1.0.0",
|
"passport-local": "~1.0.0",
|
||||||
"passport-twitter": "~1.0.2",
|
"passport-twitter": "~1.0.2",
|
||||||
"raven": "^0.8.1",
|
"raven": "^0.8.1",
|
||||||
"request": "^2.60.0",
|
"request": "^2.60.0",
|
||||||
"request-promise": "^0.4.3",
|
"request-promise": "^1.0.2",
|
||||||
"satelize": "~0.1.1",
|
"satelize": "~0.1.1",
|
||||||
"shortid": "^2.2.2",
|
"soap": "^0.11.0",
|
||||||
"should": "~4.1.0",
|
|
||||||
"soap": "^0.9.1",
|
|
||||||
"supertest": "~0.14.0",
|
|
||||||
"supertest-session": "^1.0.0",
|
|
||||||
"swig": "~1.4.1",
|
"swig": "~1.4.1",
|
||||||
"then-fs": "~2.0.0"
|
"then-fs": "~2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"node-mandrill": "^1.0.1",
|
||||||
"grunt-html2js": "^0.3.5",
|
"grunt-html2js": "^0.3.5",
|
||||||
"karma-chrome-launcher": "^0.1.12",
|
"karma-chrome-launcher": "^0.1.12",
|
||||||
"karma-jasmine-html-reporter": "^0.1.8",
|
"karma-jasmine-html-reporter": "^0.1.8",
|
||||||
"karma-mocha-reporter": "^1.1.1",
|
"karma-mocha-reporter": "^1.1.1",
|
||||||
"karma-ng-html2js-preprocessor": "^0.1.2",
|
"karma-ng-html2js-preprocessor": "^0.2.0",
|
||||||
"node-mandrill": "^1.0.1"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
317
public/dist/application.js
vendored
317
public/dist/application.js
vendored
|
@ -87,10 +87,11 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
||||||
|
|
||||||
if(user){
|
if(user){
|
||||||
authenticator = new Authorizer(user);
|
authenticator = new Authorizer(user);
|
||||||
|
console.log('access denied: '+!authenticator.canAccess(permissions));
|
||||||
|
|
||||||
if( (permissions !== null) && !authenticator.canAccess(permissions) ){
|
if( (permissions !== null) && !authenticator.canAccess(permissions) ){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log('access denied')
|
console.log('access denied');
|
||||||
$state.go('access_denied');
|
$state.go('access_denied');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,7 @@ ApplicationConfiguration.registerModule('core', ['users']);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Use Application configuration module to register a new module
|
// 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 strict';
|
||||||
|
|
||||||
// Use Application configuration module to register a new module
|
// Use Application configuration module to register a new module
|
||||||
|
@ -399,11 +400,11 @@ angular.module('forms').run(['Menus',
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
}).config(['$provide', function ($provide){
|
}).config(['$provide', function ($provide){
|
||||||
$provide.decorator('accordionDirective', function($delegate) {
|
$provide.decorator('accordionDirective', ["$delegate", function($delegate) {
|
||||||
var directive = $delegate[0];
|
var directive = $delegate[0];
|
||||||
directive.replace = true;
|
directive.replace = true;
|
||||||
return $delegate;
|
return $delegate;
|
||||||
});
|
}]);
|
||||||
}]);
|
}]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -426,13 +427,27 @@ angular.module('forms').config(['$stateProvider',
|
||||||
data: {
|
data: {
|
||||||
hideNav: true,
|
hideNav: true,
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
Forms: 'Forms',
|
||||||
|
myForm: ["Forms", "$stateParams", function (Forms, $stateParams) {
|
||||||
|
return Forms.get({formId: $stateParams.formId}).$promise;
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
controller: 'SubmitFormController'
|
||||||
}).
|
}).
|
||||||
state('viewForm', {
|
state('viewForm', {
|
||||||
url: '/forms/:formId/admin',
|
url: '/forms/:formId/admin',
|
||||||
templateUrl: 'modules/forms/views/admin-form.client.view.html',
|
templateUrl: 'modules/forms/views/admin-form.client.view.html',
|
||||||
data: {
|
data: {
|
||||||
permissions: [ 'editForm' ]
|
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';
|
'use strict';
|
||||||
|
|
||||||
// Forms controller
|
// Forms controller
|
||||||
angular.module('forms').controller('AdminFormController', ['$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) {
|
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $modal, myForm) {
|
||||||
|
|
||||||
$scope = $rootScope;
|
$scope = $rootScope;
|
||||||
|
|
||||||
$scope.myform = CurrentForm.getForm();
|
$scope.myform = myForm;
|
||||||
$scope.myform._id = $stateParams.formId;
|
|
||||||
$rootScope.saveInProgress = false;
|
$rootScope.saveInProgress = false;
|
||||||
|
CurrentForm.setForm($scope.myform);
|
||||||
|
|
||||||
|
// console.log($scope.myform);
|
||||||
|
|
||||||
// Find a specific Form
|
// Find a specific Form
|
||||||
$scope.findOne = function(){
|
$scope.findOne = function(){
|
||||||
|
@ -530,7 +547,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
$rootScope.myform = $scope.myform = response.data;
|
$rootScope.myform = $scope.myform = response.data;
|
||||||
// console.log(response.data);
|
// console.log(response.data);
|
||||||
}).catch(function(response){
|
}).catch(function(response){
|
||||||
// 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() {
|
||||||
|
@ -544,6 +561,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -593,7 +611,7 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
|
||||||
console.log($scope.myforms[3]._id);
|
console.log($scope.myforms[3]._id);
|
||||||
}).error(function(errorResponse){
|
}).error(function(errorResponse){
|
||||||
console.log(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';
|
'use strict';
|
||||||
|
|
||||||
// Forms controller
|
// Forms controller
|
||||||
angular.module('forms').controller('SubmitFormController', ['$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) {
|
function($scope, $rootScope, $stateParams, $state, Forms, CurrentForm, Auth, myForm) {
|
||||||
$scope.authentication = Auth;
|
$scope.authentication = Auth;
|
||||||
|
$scope.myform = myForm;
|
||||||
$scope.initForm = function(){
|
|
||||||
Forms.get({
|
|
||||||
formId: $stateParams.formId
|
|
||||||
}).$promise.then(
|
|
||||||
//success
|
|
||||||
function(form){
|
|
||||||
$scope.myform = form;
|
|
||||||
|
|
||||||
if(!$scope.myform.isLive){
|
if(!$scope.myform.isLive){
|
||||||
// Show navbar if form is not public AND user IS loggedin
|
// Show navbar if form is not public AND user IS loggedin
|
||||||
if($scope.authentication.isAuthenticated()){
|
if($scope.authentication.isAuthenticated()){
|
||||||
$scope.hideNav = $rootScope.hideNav = false;
|
$scope.hideNav = $rootScope.hideNav = false;
|
||||||
}
|
}
|
||||||
// Redirect if form is not public user IS NOT loggedin
|
// Redirect if form is not public user IS NOT loggedin
|
||||||
else {
|
else {
|
||||||
$scope.hideNav = $rootScope.hideNav = true;
|
$scope.hideNav = $rootScope.hideNav = true;
|
||||||
$state.go('access_denied');
|
$state.go('access_denied');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$scope.hideNav = $rootScope.hideNav = true;
|
$scope.hideNav = $rootScope.hideNav = true;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
//error
|
|
||||||
function( error ){
|
|
||||||
$scope.error = error.message;
|
|
||||||
console.error('ERROR: '+error.message);
|
|
||||||
$state.go('access_denied');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
'use strict';
|
'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) {
|
angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', function($rootScope, $timeout) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -693,10 +708,10 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
|
||||||
savePromise = null;
|
savePromise = null;
|
||||||
|
|
||||||
$rootScope.finishedRender = false;
|
$rootScope.finishedRender = false;
|
||||||
$scope.$on('editFormFieldsStarted', function(ngRepeatFinishedEvent) {
|
$scope.$on('editFormFields Started', function(ngRepeatFinishedEvent) {
|
||||||
$rootScope.finishedRender = false;
|
$rootScope.finishedRender = false;
|
||||||
});
|
});
|
||||||
$scope.$on('editFormFieldsFinished', function(ngRepeatFinishedEvent) {
|
$scope.$on('editFormFields Finished', function(ngRepeatFinishedEvent) {
|
||||||
$rootScope.finishedRender = true;
|
$rootScope.finishedRender = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -713,7 +728,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.debounceSave = function () {
|
var debounceSave = function () {
|
||||||
$rootScope.saveInProgress = true;
|
$rootScope.saveInProgress = true;
|
||||||
$rootScope[$attrs.autoSaveCallback](true,
|
$rootScope[$attrs.autoSaveCallback](true,
|
||||||
function(err){
|
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) {
|
$scope.$watch(function(newValue, oldValue) {
|
||||||
if($scope.anyDirtyAndTouched($scope.editForm) && !$rootScope.saveInProgress){
|
// console.log($scope);
|
||||||
this.debounceSave();
|
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
|
//Autosave Form when model (specificed in $attrs.autoSaveWatch) changes
|
||||||
$scope.$watch($attrs.autoSaveWatch, function(newValue, oldValue) {
|
$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 ){
|
if( (!newValue && !oldValue) || !oldValue ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log('Autosaving');
|
||||||
// console.log('\n\n----------');
|
// console.log('\n\n----------');
|
||||||
// console.log('$dirty: '+ $formCtrl.$dirty );
|
// console.log('!$dirty: '+ !$formCtrl.$dirty );
|
||||||
// console.log('changedFields: '+changedFields);
|
// console.log('changedFields: '+changedFields);
|
||||||
|
// console.log('changedFieldMap: '+changedFieldMap);
|
||||||
// console.log('finishedRender: '+$rootScope.finishedRender);
|
// console.log('finishedRender: '+$rootScope.finishedRender);
|
||||||
// console.log('saveInProgress: '+$rootScope.saveInProgress);
|
// console.log('!saveInProgress: '+!$rootScope.saveInProgress);
|
||||||
// console.log('newValue: '+newValue);
|
// console.log('newValue: '+newValue);
|
||||||
// console.log('oldValue: '+oldValue);
|
// 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
|
//Save form ONLY IF rendering is finished, form_fields have been changed AND currently not save in progress
|
||||||
if($rootScope.finishedRender && (changedFields && !$formCtrl.$dirty) && !$rootScope.saveInProgress) {
|
if( $rootScope.finishedRender && ((changedFields && !$formCtrl.$dirty) || changedFieldMap) && !$rootScope.saveInProgress) {
|
||||||
|
|
||||||
|
// console.log('saving form now');
|
||||||
if(savePromise) {
|
if(savePromise) {
|
||||||
$timeout.cancel(savePromise);
|
$timeout.cancel(savePromise);
|
||||||
savePromise = null;
|
savePromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
savePromise = $timeout(function() {
|
savePromise = $timeout(function() {
|
||||||
console.log('Saving Form');
|
// console.log('Saving Form');
|
||||||
this.debounceSave();
|
debounceSave();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//If we are finished rendering then form saving should be finished
|
//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';
|
'use strict';
|
||||||
|
|
||||||
angular.module('forms').directive('configureFormDirective', ['$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) {
|
function ($rootScope, $http, Upload, $timeout, TimeCounter, Auth, FormFields, CurrentForm) {
|
||||||
return {
|
return {
|
||||||
templateUrl: 'modules/forms/views/directiveViews/form/configure-form.client.view.html',
|
templateUrl: 'modules/forms/views/directiveViews/form/configure-form.client.view.html',
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
@ -792,7 +824,13 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
|
||||||
pdfFields:'@',
|
pdfFields:'@',
|
||||||
formFields:'@'
|
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.log = '';
|
||||||
$scope.pdfLoading = false;
|
$scope.pdfLoading = false;
|
||||||
$scope.languages = $rootScope.languages;
|
$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: {
|
scope: {
|
||||||
myform:'=',
|
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
|
** Initialize scope with variables
|
||||||
*/
|
*/
|
||||||
|
@ -901,6 +942,26 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
|
||||||
//Populate local scope with rootScope methods/variables
|
//Populate local scope with rootScope methods/variables
|
||||||
$scope.update = $rootScope.update;
|
$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
|
** FormFields (ui-sortable) drag-and-drop configuration
|
||||||
*/
|
*/
|
||||||
|
@ -908,7 +969,6 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
|
||||||
handle: ' .handle'
|
handle: ' .handle'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// $scope.draggable = {
|
// $scope.draggable = {
|
||||||
// connectWith: ".dropzone",
|
// connectWith: ".dropzone",
|
||||||
// start: function (e, ui) {
|
// 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('\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){
|
||||||
|
@ -992,6 +1052,12 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
|
||||||
|
|
||||||
// Delete particular field on button click
|
// Delete particular field on button click
|
||||||
$scope.deleteField = function (field_index){
|
$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.myform.form_fields.splice(field_index, 1);
|
||||||
};
|
};
|
||||||
$scope.duplicateField = function (field_index){
|
$scope.duplicateField = function (field_index){
|
||||||
|
@ -1054,8 +1120,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
|
||||||
|
|
||||||
var newOption = {
|
var newOption = {
|
||||||
'option_id' : option_id,
|
'option_id' : option_id,
|
||||||
'option_title' : 'Option ' + option_id,
|
'option_value' : 'Option ' + option_id,
|
||||||
'option_value' : option_id
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// put new option into fieldOptions array
|
// 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:'=',
|
myform:'=',
|
||||||
user:'='
|
user:'='
|
||||||
},
|
},
|
||||||
controller: function($scope){
|
controller: ["$scope", function($scope){
|
||||||
$scope.table = {
|
$scope.table = {
|
||||||
masterChecker: false,
|
masterChecker: false,
|
||||||
rows: []
|
rows: []
|
||||||
|
@ -1198,60 +1263,13 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
saveAs(blob, $scope.myform.title+'_sumbissions_export_'+Date.now()+'.'+type);
|
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';
|
'use strict';
|
||||||
|
|
||||||
angular.module('forms').directive('fieldIconDirective', function($http, $compile) {
|
angular.module('forms').directive('fieldIconDirective', ["$http", "$compile", function($http, $compile) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
template: '<i class="{{typeIcon}}"></i>',
|
template: '<i class="{{typeIcon}}"></i>',
|
||||||
|
@ -1259,7 +1277,7 @@ angular.module('forms').directive('fieldIconDirective', function($http, $compile
|
||||||
scope: {
|
scope: {
|
||||||
typeName: '@'
|
typeName: '@'
|
||||||
},
|
},
|
||||||
controller: function($scope){
|
controller: ["$scope", function($scope){
|
||||||
var iconTypeMap = {
|
var iconTypeMap = {
|
||||||
'textfield': 'fa fa-pencil-square-o',
|
'textfield': 'fa fa-pencil-square-o',
|
||||||
'dropdown': 'fa fa-th-list',
|
'dropdown': 'fa fa-th-list',
|
||||||
|
@ -1279,10 +1297,10 @@ angular.module('forms').directive('fieldIconDirective', function($http, $compile
|
||||||
'number': 'fa fa-slack'
|
'number': 'fa fa-slack'
|
||||||
};
|
};
|
||||||
$scope.typeIcon = iconTypeMap[$scope.typeName];
|
$scope.typeIcon = iconTypeMap[$scope.typeName];
|
||||||
},
|
}],
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
}]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// coffeescript's for in loop
|
// coffeescript's for in loop
|
||||||
|
@ -1298,7 +1316,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
|
|
||||||
|
|
||||||
var getTemplateUrl = function(field) {
|
var getTemplateUrl = function(field) {
|
||||||
|
console.log(field.validFieldTypes);
|
||||||
var type = field.fieldType;
|
var type = field.fieldType;
|
||||||
var templateUrl = 'modules/forms/views/directiveViews/field/';
|
var templateUrl = 'modules/forms/views/directiveViews/field/';
|
||||||
var supported_fields = [
|
var supported_fields = [
|
||||||
|
@ -1307,6 +1325,7 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
'textarea',
|
'textarea',
|
||||||
'checkbox',
|
'checkbox',
|
||||||
'date',
|
'date',
|
||||||
|
'link',
|
||||||
'dropdown',
|
'dropdown',
|
||||||
'hidden',
|
'hidden',
|
||||||
'password',
|
'password',
|
||||||
|
@ -1319,10 +1338,9 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
'natural'
|
'natural'
|
||||||
];
|
];
|
||||||
if (__indexOf.call(supported_fields, type) >= 0) {
|
if (__indexOf.call(supported_fields, type) >= 0) {
|
||||||
templateUrl += type + '.html';
|
templateUrl = templateUrl+type+'.html';
|
||||||
}
|
}
|
||||||
var template = $templateCache.get(templateUrl);
|
return templateUrl;
|
||||||
return template;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var linker = function(scope, element) {
|
var linker = function(scope, element) {
|
||||||
|
@ -1338,24 +1356,13 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
defaultDate: 0,
|
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
|
// GET template content from path
|
||||||
var template = getTemplateUrl(scope.field);
|
var templateUrl = getTemplateUrl(scope.field);
|
||||||
// $http.get(templateUrl).success(function(data) {
|
$http.get(templateUrl).success(function(data) {
|
||||||
element.html(template).show();
|
element.html(data).show();
|
||||||
// console.log(element.contents());
|
$compile(element.contents())(scope);
|
||||||
$compile(element.contents())(scope);
|
});
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1363,14 +1370,15 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http',
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
field: '=',
|
field: '=',
|
||||||
required: '&'
|
required: '&',
|
||||||
|
design: '='
|
||||||
},
|
},
|
||||||
link: linker
|
link: linker
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('forms').directive('onFinishRender', function ($rootScope, $timeout) {
|
angular.module('forms').directive('onFinishRender', ["$rootScope", "$timeout", function ($rootScope, $timeout) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function (scope, element, attrs) {
|
link: function (scope, element, attrs) {
|
||||||
|
@ -1383,17 +1391,16 @@ angular.module('forms').directive('onFinishRender', function ($rootScope, $timeo
|
||||||
}
|
}
|
||||||
|
|
||||||
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
|
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
|
||||||
|
|
||||||
if(scope.$first) {
|
if(scope.$first && !scope.$last) {
|
||||||
scope.$evalAsync(function () {
|
scope.$evalAsync(function () {
|
||||||
// console.log(broadcastMessage+' Started');
|
|
||||||
// console.log(Date.now());
|
// console.log(Date.now());
|
||||||
$rootScope.$broadcast(broadcastMessage+' Started');
|
$rootScope.$broadcast(broadcastMessage+' Started');
|
||||||
});
|
});
|
||||||
}else if(scope.$last) {
|
}else if(scope.$last) {
|
||||||
scope.$evalAsync(function () {
|
scope.$evalAsync(function () {
|
||||||
// element.ready(function () {
|
// element.ready(function () {
|
||||||
// console.log(broadcastMessage+'Finished');
|
console.log(broadcastMessage+'Finished');
|
||||||
// console.log(Date.now());
|
// console.log(Date.now());
|
||||||
$rootScope.$broadcast(broadcastMessage+' Finished');
|
$rootScope.$broadcast(broadcastMessage+' Finished');
|
||||||
// });
|
// });
|
||||||
|
@ -1401,7 +1408,7 @@ angular.module('forms').directive('onFinishRender', function ($rootScope, $timeo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
}]);
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -1413,7 +1420,7 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', '
|
||||||
scope: {
|
scope: {
|
||||||
myform:'='
|
myform:'='
|
||||||
},
|
},
|
||||||
controller: function($scope){
|
controller: ["$scope", function($scope){
|
||||||
angular.element(document).ready(function() {
|
angular.element(document).ready(function() {
|
||||||
$scope.error = '';
|
$scope.error = '';
|
||||||
$scope.selected = null;
|
$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',
|
method: 'GET',
|
||||||
transformResponse: function(data, header) {
|
transformResponse: function(data, header) {
|
||||||
var form = angular.fromJson(data);
|
var form = angular.fromJson(data);
|
||||||
|
console.log(form);
|
||||||
|
|
||||||
form.visible_form_fields = _.filter(form.form_fields, function(field){
|
form.visible_form_fields = _.filter(form.form_fields, function(field){
|
||||||
return (field.deletePreserved === false);
|
return (field.deletePreserved === false);
|
||||||
|
@ -1664,7 +1672,7 @@ angular.module('forms').service('TimeCounter', [
|
||||||
// Config HTTP Error Handling
|
// Config HTTP Error Handling
|
||||||
angular.module('users').config(['$httpProvider',
|
angular.module('users').config(['$httpProvider',
|
||||||
function($httpProvider) {
|
function($httpProvider) {
|
||||||
$httpProvider.interceptors.push(function($q, $location) {
|
$httpProvider.interceptors.push(["$q", "$location", function($q, $location) {
|
||||||
return {
|
return {
|
||||||
responseError: function(response) {
|
responseError: function(response) {
|
||||||
// console.log($location.path());
|
// console.log($location.path());
|
||||||
|
@ -1684,7 +1692,7 @@ angular.module('users').config(['$httpProvider',
|
||||||
return $q.reject(response);
|
return $q.reject(response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
}]);
|
||||||
}]);
|
}]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -1714,6 +1722,7 @@ angular.module('users').config(['$stateProvider',
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
checkLoggedin.$inject = ["$q", "$timeout", "$state", "User", "Auth"];
|
||||||
|
|
||||||
// Users state routing
|
// Users state routing
|
||||||
$stateProvider.
|
$stateProvider.
|
||||||
|
@ -2065,7 +2074,7 @@ angular.module('users').factory('Auth', ['$window',
|
||||||
|
|
||||||
'use strict';
|
'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 function(user) {
|
||||||
return {
|
return {
|
||||||
canAccess: function(permissions) {
|
canAccess: function(permissions) {
|
||||||
|
@ -2096,7 +2105,7 @@ angular.module('users').service('Authorizer', function(APP_PERMISSIONS, USER_ROL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}]);
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '$state',
|
angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '$state',
|
||||||
|
|
2
public/dist/application.min.css
vendored
2
public/dist/application.min.css
vendored
File diff suppressed because one or more lines are too long
4
public/dist/application.min.js
vendored
4
public/dist/application.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,7 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
|
||||||
console.log($scope.myforms[3]._id);
|
console.log($scope.myforms[3]._id);
|
||||||
}).error(function(errorResponse){
|
}).error(function(errorResponse){
|
||||||
console.log(errorResponse);
|
console.log(errorResponse);
|
||||||
$scope.error = errorResponse.data.message;
|
if(errorResponse == null) $scope.error = errorResponse.data.message;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.log = 'file ' + data.originalname + ' uploaded as '+ data.name +'. JSON: ' + JSON.stringify(data) + '\n' + $scope.log;
|
||||||
$scope.myform.pdf = angular.fromJson(angular.toJson(data));
|
$scope.myform.pdf = angular.fromJson(angular.toJson(data));
|
||||||
|
|
||||||
console.log($scope.myform.pdf);
|
// console.log($scope.myform.pdf);
|
||||||
|
|
||||||
$scope.pdfLoading = false;
|
$scope.pdfLoading = false;
|
||||||
|
|
||||||
|
|
|
@ -144,9 +144,10 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
|
||||||
|
|
||||||
// Delete particular field on button click
|
// Delete particular field on button click
|
||||||
$scope.deleteField = function (field_index){
|
$scope.deleteField = function (field_index){
|
||||||
|
console.log(field_index);
|
||||||
//Delete field from field map
|
//Delete field from field map
|
||||||
var currFieldId = $scope.myform.form_fields[field_index]._id
|
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
|
//Delete field
|
||||||
$scope.myform.form_fields.splice(field_index, 1);
|
$scope.myform.form_fields.splice(field_index, 1);
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 field-input container">
|
<div class="col-xs-6 field-input container">
|
||||||
<div class="row-fluid">
|
<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"/>
|
<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>
|
<span> I accept </span>
|
||||||
</label>
|
</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"/>
|
<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>
|
<span>I don't accept </span>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<h2 class="text-center col-xs-8 ">{{field.title}} </h2>
|
<h2 class="text-center col-xs-8 ">{{field.title}} </h2>
|
||||||
<i class="fa fa-quote-right fa-3 col-xs-1"></i>
|
<i class="fa fa-quote-right fa-3 col-xs-1"></i>
|
||||||
</div>
|
</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>
|
<p class="col-sm-12">{{field.description}} </p>
|
||||||
<!-- <br>
|
<!-- <br>
|
||||||
|
|
Loading…
Reference in a new issue