Revert "Fix html2js"

This commit is contained in:
David Baldwynn 2016-04-28 16:47:50 -07:00
parent e269fd8756
commit 79de5038ac
13 changed files with 3107 additions and 72 deletions

View file

@ -227,7 +227,7 @@ module.exports = function(grunt) {
}, },
html2js: { html2js: {
options: { options: {
base: 'public', base: 'NodeForm',
watch: true, watch: true,
module: 'NodeForm.templates', module: 'NodeForm.templates',
singleModule: true, singleModule: true,
@ -294,7 +294,7 @@ module.exports = function(grunt) {
grunt.registerTask('lint:tests', ['jshint:allTests']); grunt.registerTask('lint:tests', ['jshint:allTests']);
// Build task(s). // Build task(s).
grunt.registerTask('build', ['lint', 'loadConfig', 'cssmin', 'html2js:main', 'ngAnnotate', 'uglify']); grunt.registerTask('build', ['lint', 'loadConfig', 'cssmin', 'ngAnnotate', 'uglify', 'html2js:main']);
// Test task(s). // Test task(s).
grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']); grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']);

2713
public/dist/application.js vendored Normal file

File diff suppressed because one or more lines are too long

4
public/dist/application.min.css vendored Normal file

File diff suppressed because one or more lines are too long

4
public/dist/application.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,8 @@
'use strict'; 'use strict';
// Setting up route // Setting up route
angular.module('forms').config([ angular.module('forms').config(['$stateProvider',
'$stateProvider',
function($stateProvider) { function($stateProvider) {
// Forms state routing // Forms state routing
$stateProvider. $stateProvider.
@ -46,7 +45,7 @@ angular.module('forms').config([
templateUrl: 'modules/forms/views/adminTabs/design.html' templateUrl: 'modules/forms/views/adminTabs/design.html'
}).state('viewForm.analyze', { }).state('viewForm.analyze', {
url: '/analyze', url: '/analyze',
templateUrl: 'modules/forms/views/adminTabs/analyze.html' templateUrl: 'modules/forms/views/adminTabs/analyze.html',
}).state('viewForm.create', { }).state('viewForm.create', {
url: '/create', url: '/create',
templateUrl: 'modules/forms/views/adminTabs/create.html' templateUrl: 'modules/forms/views/adminTabs/create.html'

View file

@ -1,12 +1,8 @@
'use strict'; 'use strict';
// Forms controller // Forms controller
angular.module('forms').controller('AdminFormController', [ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$uibModal', 'myForm',
'$rootScope', '$scope', '$stateParams', '$state', 'Forms', function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $uibModal, myForm) {
'CurrentForm', '$http', '$uibModal', 'myForm',
function($rootScope, $scope, $stateParams, $state, Forms,
CurrentForm, $http, $uibModal, myForm) {
$scope = $rootScope; $scope = $rootScope;
$scope.animationsEnabled = true; $scope.animationsEnabled = true;
@ -43,8 +39,8 @@ angular.module('forms').controller('AdminFormController', [
}); });
}; };
/* /*
** DeleteModal Functions ** DeleteModal Functions
*/ */
$scope.openDeleteModal = function(){ $scope.openDeleteModal = function(){
$scope.deleteModal = $uibModal.open({ $scope.deleteModal = $uibModal.open({
@ -76,15 +72,15 @@ angular.module('forms').controller('AdminFormController', [
if($scope.deleteModal && $scope.deleteModal.opened){ if($scope.deleteModal && $scope.deleteModal.opened){
$scope.deleteModal.close(); $scope.deleteModal.close();
var form_id = $scope.myform._id; var form_id = $scope.myform._id;
if(!form_id) throw new Error('Error - removeCurrentForm(): $scope.myform._id does not exist'); if(!form_id) throw new Error('Error - removeCurrentForm(): $scope.myform._id does not exist');
$http.delete('/forms/'+form_id) $http.delete('/forms/'+form_id)
.success(function(data, status, headers){ .success(function(data, status, headers){
console.log('form deleted successfully'); console.log('form deleted successfully');
$state.go('listForms', {}, {reload: true}); $state.go('listForms', {}, {reload: true});
}).error(function(error){ }).error(function(error){
console.log('ERROR: Form could not be deleted.'); console.log('ERROR: Form could not be deleted.');
@ -100,7 +96,7 @@ angular.module('forms').controller('AdminFormController', [
if(!updateImmediately){ if(!updateImmediately){
continueUpdate = !$rootScope.saveInProgress; continueUpdate = !$rootScope.saveInProgress;
} }
//Update form **if we are not currently updating** or if **shouldUpdateNow flag is set** //Update form **if we are not currently updating** or if **shouldUpdateNow flag is set**
if(continueUpdate){ if(continueUpdate){
var err = null; var err = null;
@ -115,12 +111,12 @@ angular.module('forms').controller('AdminFormController', [
console.log('Error occured during form UPDATE.\n'); console.log('Error occured during form UPDATE.\n');
// console.log(response.data); // console.log(response.data);
err = response.data; err = response.data;
}).finally(function() { }).finally(function() {
// console.log('finished updating'); // console.log('finished updating');
if(!updateImmediately){$rootScope.saveInProgress = false; } if(!updateImmediately){$rootScope.saveInProgress = false; }
if( (typeof cb) === 'function'){ if( (typeof cb) === 'function'){
cb(err); cb(err);
} }
}); });
} }
@ -128,4 +124,4 @@ angular.module('forms').controller('AdminFormController', [
} }
]); ]);

View file

@ -1,7 +1,6 @@
'use strict'; 'use strict';
angular.module('forms').directive('configureFormDirective', [ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$http', 'Upload', 'CurrentForm',
'$rootScope', '$http', 'Upload', 'CurrentForm',
function ($rootScope, $http, Upload, CurrentForm) { function ($rootScope, $http, Upload, 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',
@ -22,7 +21,7 @@ angular.module('forms').directive('configureFormDirective', [
$scope.log = ''; $scope.log = '';
$scope.pdfLoading = false; $scope.pdfLoading = false;
$scope.languages = $rootScope.languages; $scope.languages = $rootScope.languages;
this._current_upload = null; this._current_upload = null;
$scope.resetForm = $rootScope.resetForm; $scope.resetForm = $rootScope.resetForm;
$scope.update = $rootScope.update; $scope.update = $rootScope.update;
@ -67,7 +66,7 @@ angular.module('forms').directive('configureFormDirective', [
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total); var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$scope.log = 'progress: ' + progressPercentage + '% ' + $scope.log = 'progress: ' + progressPercentage + '% ' +
evt.config.file.name + '\n' + $scope.log; evt.config.file.name + '\n' + $scope.log;
$scope.pdfLoading = true; $scope.pdfLoading = true;
}).success(function (data, status, headers, config) { }).success(function (data, status, headers, config) {
$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;
@ -92,4 +91,4 @@ angular.module('forms').directive('configureFormDirective', [
} }
}; };
} }
]); ]);

View file

@ -1,7 +1,6 @@
'use strict'; 'use strict';
angular.module('forms').directive('editFormDirective', [ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormFields',
'$rootScope', 'FormFields',
function ($rootScope, FormFields) { function ($rootScope, FormFields) {
return { return {
templateUrl: 'modules/forms/views/directiveViews/form/edit-form.client.view.html', templateUrl: 'modules/forms/views/directiveViews/form/edit-form.client.view.html',
@ -46,7 +45,7 @@ angular.module('forms').directive('editFormDirective', [
if( $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id) ){ if( $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id) ){
currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]); currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]);
} }
//Get all oscarhostFields that haven't been mapped to a formfield //Get all oscarhostFields that haven't been mapped to a formfield
return _(oscarhostFields).difference(currentFields).value(); return _(oscarhostFields).difference(currentFields).value();
@ -74,9 +73,9 @@ angular.module('forms').directive('editFormDirective', [
var fieldTitle; var fieldTitle;
for(var i = 0; i < $scope.addField.types.length; i++){ for(var i = 0; i < $scope.addField.types.length; i++){
if($scope.addField.types[i].name === fieldType){ if($scope.addField.types[i].name === fieldType){
$scope.addField.types[i].lastAddedID++; $scope.addField.types[i].lastAddedID++;
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID; fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
break; break;
} }
} }
@ -91,12 +90,12 @@ angular.module('forms').directive('editFormDirective', [
// console.log('\n\n---------\nAdded field CLIENT'); // console.log('\n\n---------\nAdded field CLIENT');
// console.log(newField); // console.log(newField);
// newField._id = _.uniqueId(); // newField._id = _.uniqueId();
// put newField into fields array // put newField into fields array
if(modifyForm){ if(modifyForm){
$scope.myform.form_fields.push(newField); $scope.myform.form_fields.push(newField);
} }
return newField; return newField;
}; };
// Delete particular field on button click // Delete particular field on button click
@ -110,7 +109,7 @@ angular.module('forms').directive('editFormDirective', [
$scope.myform.form_fields.splice(field_index, 1); $scope.myform.form_fields.splice(field_index, 1);
}; };
$scope.duplicateField = function (field_index){ $scope.duplicateField = function (field_index){
var currField = _.cloneDeep($scope.myform.form_fields[field_index]); var currField = _.cloneDeep($scope.myform.form_fields[field_index]);
currField._id = 'cloned'+_.uniqueId(); currField._id = 'cloned'+_.uniqueId();
currField.title += ' copy'; currField.title += ' copy';
@ -159,8 +158,8 @@ angular.module('forms').directive('editFormDirective', [
$scope.addOption = function(field_index){ $scope.addOption = function(field_index){
var currField = $scope.myform.form_fields[field_index]; var currField = $scope.myform.form_fields[field_index];
console.log(field_index); console.log(field_index);
console.log(currField); console.log(currField);
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){ if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
if(!currField.fieldOptions) $scope.myform.form_fields[field_index].fieldOptions = []; if(!currField.fieldOptions) $scope.myform.form_fields[field_index].fieldOptions = [];
@ -210,7 +209,7 @@ angular.module('forms').directive('editFormDirective', [
}; };
}, },
}; };
} }
]); ]);

View file

@ -1,7 +1,6 @@
'use strict'; 'use strict';
angular.module('forms').directive('editSubmissionsFormDirective', [ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope', '$http',
'$rootScope', '$http',
function ($rootScope, $http) { function ($rootScope, $http) {
return { return {
templateUrl: 'modules/forms/views/directiveViews/form/edit-submissions-form.client.view.html', templateUrl: 'modules/forms/views/directiveViews/form/edit-submissions-form.client.view.html',
@ -50,7 +49,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
defaultFormFields = _.cloneDeep($scope.myform.form_fields); defaultFormFields = _.cloneDeep($scope.myform.form_fields);
// console.log('before textField2: '+data[0].form_fields[1].fieldValue); // console.log('before textField2: '+data[0].form_fields[1].fieldValue);
//Iterate through form's submissions //Iterate through form's submissions
for(var i=0; i<data.length; i++){ for(var i=0; i<data.length; i++){
for(var x=0; x<data[i].form_fields; x++){ for(var x=0; x<data[i].form_fields; x++){
@ -70,8 +69,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
}) })
.error(function(err){ .error(function(err){
console.error('Could not fetch form submissions.\nError: '+err); console.error('Could not fetch form submissions.\nError: '+err);
}); });
}; };
//Delete selected submissions of Form //Delete selected submissions of Form
$scope.deleteSelectedSubmissions = function(){ $scope.deleteSelectedSubmissions = function(){
@ -80,7 +79,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
return !!row.selected; return !!row.selected;
}).pluck('_id').value(); }).pluck('_id').value();
$http({ url: '/forms/'+$scope.myform._id+'/submissions', $http({ url: '/forms/'+$scope.myform._id+'/submissions',
method: 'DELETE', method: 'DELETE',
data: {deleted_submissions: delete_ids}, data: {deleted_submissions: delete_ids},
headers: {'Content-Type': 'application/json;charset=utf-8'} headers: {'Content-Type': 'application/json;charset=utf-8'}
@ -98,7 +97,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
console.log('Could not delete form submissions.\nError: '); console.log('Could not delete form submissions.\nError: ');
console.log(err); console.log(err);
console.error = err; console.error = err;
}); });
}; };
//Export selected submissions of Form //Export selected submissions of Form

View file

@ -10,7 +10,7 @@ var __indexOf = [].indexOf || function(item) {
angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache', angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache',
function($http, $compile, $rootScope, $templateCache) { function($http, $compile, $rootScope, $templateCache) {
var getTemplateUrl = function(fieldType) { var getTemplateUrl = function(fieldType) {
var type = fieldType; var type = fieldType;
var templateUrl = 'modules/forms/views/directiveViews/field/'; var templateUrl = 'modules/forms/views/directiveViews/field/';
@ -33,7 +33,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
templateUrl = templateUrl+type+'.html'; templateUrl = templateUrl+type+'.html';
} }
return $templateCache.get(templateUrl); return $templateCache.get('../public/'+templateUrl);
}; };
return { return {
@ -47,20 +47,20 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
}, },
link: function(scope, element) { link: function(scope, element) {
scope.setActiveField = $rootScope.setActiveField; scope.setActiveField = $rootScope.setActiveField;
//Set format only if field is a date //Set format only if field is a date
if(scope.field.fieldType === 'date'){ if(scope.field.fieldType === 'date'){
scope.dateOptions = { scope.dateOptions = {
changeYear: true, changeYear: true,
changeMonth: true, changeMonth: true,
altFormat: 'mm/dd/yyyy', altFormat: 'mm/dd/yyyy',
yearRange: '1900:-0', yearRange: '1900:-0',
defaultDate: 0, defaultDate: 0,
}; };
} }
var fieldType = scope.field.fieldType; var fieldType = scope.field.fieldType;
if(scope.field.fieldType === 'number' || scope.field.fieldType === 'textfield' || scope.field.fieldType === 'email' || scope.field.fieldType === 'link'){ if(scope.field.fieldType === 'number' || scope.field.fieldType === 'textfield' || scope.field.fieldType === 'email' || scope.field.fieldType === 'link'){
switch(scope.field.fieldType){ switch(scope.field.fieldType){
case 'textfield': case 'textfield':

View file

@ -3,7 +3,7 @@
angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth', angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth',
function ($http, TimeCounter, $filter, $rootScope, Auth) { function ($http, TimeCounter, $filter, $rootScope, Auth) {
return { return {
templateUrl: 'modules/forms/views/directiveViews/form/submit-form.client.view.html', templateUrl: 'modules/forms/views/directiveViews/form/submit-form.client.view.html',
restrict: 'E', restrict: 'E',
scope: { scope: {
myform:'=' myform:'='
@ -11,14 +11,14 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
controller: function($document, $window, $scope){ controller: function($document, $window, $scope){
$scope.authentication = $rootScope.authentication; $scope.authentication = $rootScope.authentication;
$scope.noscroll = false; $scope.noscroll = false;
$scope.forms = {}; $scope.forms = {};
$scope.form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ $scope.form_fields_count = $scope.myform.visible_form_fields.filter(function(field){
if(field.fieldType === 'statement' || field.fieldType === 'rating'){ if(field.fieldType === 'statement' || field.fieldType === 'rating'){
return false; return false;
} }
return true; return true;
}).length; }).length;
$scope.reloadForm = function(){ $scope.reloadForm = function(){
//Reset Form //Reset Form
$scope.myform.submitted = false; $scope.myform.submitted = false;
@ -29,24 +29,24 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
$scope.loading = false; $scope.loading = false;
$scope.error = ''; $scope.error = '';
$scope.selected = { $scope.selected = {
_id: '', _id: '',
index: 0 index: 0
}; };
$scope.setActiveField($scope.myform.visible_form_fields[0]._id, 0, false); $scope.setActiveField($scope.myform.visible_form_fields[0]._id, 0, false);
console.log($scope.selected); console.log($scope.selected);
//Reset Timer //Reset Timer
TimeCounter.restartClock(); TimeCounter.restartClock();
}; };
$window.onscroll = function(){ $window.onscroll = function(){
$scope.scrollPos = document.body.scrollTop || document.documentElement.scrollTop || 0; $scope.scrollPos = document.body.scrollTop || document.documentElement.scrollTop || 0;
var elemBox = document.getElementsByClassName('activeField')[0].getBoundingClientRect(); var elemBox = document.getElementsByClassName('activeField')[0].getBoundingClientRect();
$scope.fieldTop = elemBox.top; $scope.fieldTop = elemBox.top;
$scope.fieldBottom = elemBox.bottom; $scope.fieldBottom = elemBox.bottom;
//console.log($scope.forms.myForm); //console.log($scope.forms.myForm);
if(!$scope.noscroll){ if(!$scope.noscroll){
@ -55,10 +55,10 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
var field_index = $scope.selected.index+1; var field_index = $scope.selected.index+1;
var field_id = 'submit_field'; var field_id = 'submit_field';
$scope.setActiveField(field_id, field_index, false); $scope.setActiveField(field_id, field_index, false);
} }
//Focus on field above submit button //Focus on field above submit button
else if($scope.selected.index === $scope.myform.form_fields.length){ else if($scope.selected.index === $scope.myform.form_fields.length){
if($scope.fieldTop > 200){ if($scope.fieldTop > 200){
var field_index = $scope.selected.index-1; var field_index = $scope.selected.index-1;
var field_id = $scope.myform.form_fields[field_index]._id; var field_id = $scope.myform.form_fields[field_index]._id;
$scope.setActiveField(field_id, field_index, false); $scope.setActiveField(field_id, field_index, false);
@ -70,11 +70,11 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
}else if ( $scope.selected.index !== 0 && $scope.fieldTop > 0) { }else if ( $scope.selected.index !== 0 && $scope.fieldTop > 0) {
var field_index = $scope.selected.index-1; var field_index = $scope.selected.index-1;
var field_id = $scope.myform.form_fields[field_index]._id; var field_id = $scope.myform.form_fields[field_index]._id;
$scope.setActiveField(field_id, field_index, false); $scope.setActiveField(field_id, field_index, false);
} }
//console.log('$scope.selected.index: '+$scope.selected.index); //console.log('$scope.selected.index: '+$scope.selected.index);
//console.log('scroll pos: '+$scope.scrollPos+' fieldTop: '+$scope.fieldTop+' fieldBottom: '+$scope.fieldBottom); //console.log('scroll pos: '+$scope.scrollPos+' fieldTop: '+$scope.fieldTop+' fieldBottom: '+$scope.fieldBottom);
$scope.$apply(); $scope.$apply();
} }
}; };
@ -127,23 +127,23 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
$scope.setActiveField(selected_id, selected_index, true); $scope.setActiveField(selected_id, selected_index, true);
} }
}; };
/* /*
** Form Display Functions ** Form Display Functions
*/ */
$scope.exitStartPage = function(){ $scope.exitStartPage = function(){
$scope.myform.startPage.showStart = false; $scope.myform.startPage.showStart = false;
if($scope.myform.form_fields.length > 0){ if($scope.myform.form_fields.length > 0){
$scope.selected._id = $scope.myform.form_fields[0]._id; $scope.selected._id = $scope.myform.form_fields[0]._id;
} }
}; };
$scope.submitForm = function(){ $scope.submitForm = function(){
var _timeElapsed = TimeCounter.stopClock(); var _timeElapsed = TimeCounter.stopClock();
$scope.loading = true; $scope.loading = true;
var form = _.cloneDeep($scope.myform); var form = _.cloneDeep($scope.myform);
form.timeElapsed = _timeElapsed; form.timeElapsed = _timeElapsed;
form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100; form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100;
delete form.visible_form_fields; delete form.visible_form_fields;

View file

@ -1,8 +1,7 @@
'use strict'; 'use strict';
// Setting up route // Setting up route
angular.module('users').config([ angular.module('users').config(['$stateProvider',
'$stateProvider',
function($stateProvider) { function($stateProvider) {
var checkLoggedin = function($q, $timeout, $state, User, Auth) { var checkLoggedin = function($q, $timeout, $state, User, Auth) {
@ -68,7 +67,7 @@ angular.module('users').config([
url: '/access_denied', url: '/access_denied',
templateUrl: 'modules/users/views/authentication/access-denied.client.view.html' templateUrl: 'modules/users/views/authentication/access-denied.client.view.html'
}). }).
state('resendVerifyEmail', { state('resendVerifyEmail', {
url: '/verify', url: '/verify',
templateUrl: 'modules/users/views/verify/resend-verify-email.client.view.html' templateUrl: 'modules/users/views/verify/resend-verify-email.client.view.html'
@ -95,4 +94,4 @@ angular.module('users').config([
templateUrl: 'modules/users/views/password/reset-password.client.view.html' templateUrl: 'modules/users/views/password/reset-password.client.view.html'
}); });
} }
]); ]);

File diff suppressed because one or more lines are too long