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: {
options: {
base: 'public',
base: 'NodeForm',
watch: true,
module: 'NodeForm.templates',
singleModule: true,
@ -294,7 +294,7 @@ module.exports = function(grunt) {
grunt.registerTask('lint:tests', ['jshint:allTests']);
// 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).
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';
// Setting up route
angular.module('forms').config([
'$stateProvider',
angular.module('forms').config(['$stateProvider',
function($stateProvider) {
// Forms state routing
$stateProvider.
@ -46,7 +45,7 @@ angular.module('forms').config([
templateUrl: 'modules/forms/views/adminTabs/design.html'
}).state('viewForm.analyze', {
url: '/analyze',
templateUrl: 'modules/forms/views/adminTabs/analyze.html'
templateUrl: 'modules/forms/views/adminTabs/analyze.html',
}).state('viewForm.create', {
url: '/create',
templateUrl: 'modules/forms/views/adminTabs/create.html'

View file

@ -1,12 +1,8 @@
'use strict';
// Forms controller
angular.module('forms').controller('AdminFormController', [
'$rootScope', '$scope', '$stateParams', '$state', 'Forms',
'CurrentForm', '$http', '$uibModal', 'myForm',
function($rootScope, $scope, $stateParams, $state, Forms,
CurrentForm, $http, $uibModal, myForm) {
angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$uibModal', 'myForm',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $uibModal, myForm) {
$scope = $rootScope;
$scope.animationsEnabled = true;
@ -43,8 +39,8 @@ angular.module('forms').controller('AdminFormController', [
});
};
/*
** DeleteModal Functions
/*
** DeleteModal Functions
*/
$scope.openDeleteModal = function(){
$scope.deleteModal = $uibModal.open({
@ -76,15 +72,15 @@ angular.module('forms').controller('AdminFormController', [
if($scope.deleteModal && $scope.deleteModal.opened){
$scope.deleteModal.close();
var form_id = $scope.myform._id;
if(!form_id) throw new Error('Error - removeCurrentForm(): $scope.myform._id does not exist');
$http.delete('/forms/'+form_id)
.success(function(data, status, headers){
console.log('form deleted successfully');
$state.go('listForms', {}, {reload: true});
$state.go('listForms', {}, {reload: true});
}).error(function(error){
console.log('ERROR: Form could not be deleted.');
@ -100,7 +96,7 @@ angular.module('forms').controller('AdminFormController', [
if(!updateImmediately){
continueUpdate = !$rootScope.saveInProgress;
}
//Update form **if we are not currently updating** or if **shouldUpdateNow flag is set**
if(continueUpdate){
var err = null;
@ -115,12 +111,12 @@ angular.module('forms').controller('AdminFormController', [
console.log('Error occured during form UPDATE.\n');
// console.log(response.data);
err = response.data;
}).finally(function() {
}).finally(function() {
// console.log('finished updating');
if(!updateImmediately){$rootScope.saveInProgress = false; }
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';
angular.module('forms').directive('configureFormDirective', [
'$rootScope', '$http', 'Upload', 'CurrentForm',
angular.module('forms').directive('configureFormDirective', ['$rootScope', '$http', 'Upload', 'CurrentForm',
function ($rootScope, $http, Upload, CurrentForm) {
return {
templateUrl: 'modules/forms/views/directiveViews/form/configure-form.client.view.html',
@ -22,7 +21,7 @@ angular.module('forms').directive('configureFormDirective', [
$scope.log = '';
$scope.pdfLoading = false;
$scope.languages = $rootScope.languages;
this._current_upload = null;
$scope.resetForm = $rootScope.resetForm;
$scope.update = $rootScope.update;
@ -67,7 +66,7 @@ angular.module('forms').directive('configureFormDirective', [
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$scope.log = 'progress: ' + progressPercentage + '% ' +
evt.config.file.name + '\n' + $scope.log;
$scope.pdfLoading = true;
}).success(function (data, status, headers, config) {
$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';
angular.module('forms').directive('editFormDirective', [
'$rootScope', 'FormFields',
angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormFields',
function ($rootScope, FormFields) {
return {
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) ){
currentFields = _(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id]);
}
}
//Get all oscarhostFields that haven't been mapped to a formfield
return _(oscarhostFields).difference(currentFields).value();
@ -74,9 +73,9 @@ angular.module('forms').directive('editFormDirective', [
var fieldTitle;
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++;
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
break;
}
}
@ -91,12 +90,12 @@ angular.module('forms').directive('editFormDirective', [
// console.log('\n\n---------\nAdded field CLIENT');
// console.log(newField);
// newField._id = _.uniqueId();
// put newField into fields array
if(modifyForm){
$scope.myform.form_fields.push(newField);
}
return newField;
return newField;
};
// Delete particular field on button click
@ -110,7 +109,7 @@ angular.module('forms').directive('editFormDirective', [
$scope.myform.form_fields.splice(field_index, 1);
};
$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.title += ' copy';
@ -159,8 +158,8 @@ angular.module('forms').directive('editFormDirective', [
$scope.addOption = function(field_index){
var currField = $scope.myform.form_fields[field_index];
console.log(field_index);
console.log(currField);
console.log(currField);
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
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';
angular.module('forms').directive('editSubmissionsFormDirective', [
'$rootScope', '$http',
angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope', '$http',
function ($rootScope, $http) {
return {
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);
// console.log('before textField2: '+data[0].form_fields[1].fieldValue);
//Iterate through form's submissions
for(var i=0; i<data.length; i++){
for(var x=0; x<data[i].form_fields; x++){
@ -70,8 +69,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
})
.error(function(err){
console.error('Could not fetch form submissions.\nError: '+err);
});
};
});
};
//Delete selected submissions of Form
$scope.deleteSelectedSubmissions = function(){
@ -80,7 +79,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', [
return !!row.selected;
}).pluck('_id').value();
$http({ url: '/forms/'+$scope.myform._id+'/submissions',
$http({ url: '/forms/'+$scope.myform._id+'/submissions',
method: 'DELETE',
data: {deleted_submissions: delete_ids},
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(err);
console.error = err;
});
});
};
//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',
function($http, $compile, $rootScope, $templateCache) {
var getTemplateUrl = function(fieldType) {
var type = fieldType;
var templateUrl = 'modules/forms/views/directiveViews/field/';
@ -33,7 +33,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
templateUrl = templateUrl+type+'.html';
}
return $templateCache.get(templateUrl);
return $templateCache.get('../public/'+templateUrl);
};
return {
@ -47,20 +47,20 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
},
link: function(scope, element) {
scope.setActiveField = $rootScope.setActiveField;
//Set format only if field is a date
if(scope.field.fieldType === 'date'){
scope.dateOptions = {
changeYear: true,
changeMonth: true,
altFormat: 'mm/dd/yyyy',
yearRange: '1900:-0',
yearRange: '1900:-0',
defaultDate: 0,
};
}
var fieldType = scope.field.fieldType;
if(scope.field.fieldType === 'number' || scope.field.fieldType === 'textfield' || scope.field.fieldType === 'email' || scope.field.fieldType === 'link'){
switch(scope.field.fieldType){
case 'textfield':

View file

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

View file

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

File diff suppressed because one or more lines are too long