Merge pull request #63 from lalop/fix-html2js

Fix html2js
This commit is contained in:
David Baldwynn 2016-04-27 14:19:07 -07:00
commit 16d23fb4f2
13 changed files with 72 additions and 3107 deletions

View file

@ -227,7 +227,7 @@ module.exports = function(grunt) {
},
html2js: {
options: {
base: 'NodeForm',
base: 'public',
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', 'ngAnnotate', 'uglify', 'html2js:main']);
grunt.registerTask('build', ['lint', 'loadConfig', 'cssmin', 'html2js:main', 'ngAnnotate', 'uglify']);
// Test task(s).
grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,9 @@
'use strict';
// Setting up route
angular.module('forms').config(['$stateProvider',
angular.module('forms').config([
'$stateProvider',
function($stateProvider) {
// Forms state routing
$stateProvider.
@ -45,7 +46,7 @@ angular.module('forms').config(['$stateProvider',
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,8 +1,12 @@
'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;
@ -39,8 +43,8 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
});
};
/*
** DeleteModal Functions
/*
** DeleteModal Functions
*/
$scope.openDeleteModal = function(){
$scope.deleteModal = $uibModal.open({
@ -72,15 +76,15 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
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.');
@ -96,7 +100,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
if(!updateImmediately){
continueUpdate = !$rootScope.saveInProgress;
}
//Update form **if we are not currently updating** or if **shouldUpdateNow flag is set**
if(continueUpdate){
var err = null;
@ -111,12 +115,12 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
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);
}
});
}
@ -124,4 +128,4 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
}
]);
]);

View file

@ -1,6 +1,7 @@
'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',
@ -21,7 +22,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
$scope.log = '';
$scope.pdfLoading = false;
$scope.languages = $rootScope.languages;
this._current_upload = null;
$scope.resetForm = $rootScope.resetForm;
$scope.update = $rootScope.update;
@ -66,7 +67,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
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;
@ -91,4 +92,4 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$htt
}
};
}
]);
]);

View file

@ -1,6 +1,7 @@
'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',
@ -45,7 +46,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
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();
@ -73,9 +74,9 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
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;
}
}
@ -90,12 +91,12 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
// 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
@ -109,7 +110,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$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';
@ -158,8 +159,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$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 = [];
@ -209,7 +210,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
};
},
};
}
]);

View file

@ -1,6 +1,7 @@
'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',
@ -49,7 +50,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
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++){
@ -69,8 +70,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
})
.error(function(err){
console.error('Could not fetch form submissions.\nError: '+err);
});
};
});
};
//Delete selected submissions of Form
$scope.deleteSelectedSubmissions = function(){
@ -79,7 +80,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
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'}
@ -97,7 +98,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
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('../public/'+templateUrl);
return $templateCache.get(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,7 +1,8 @@
'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) {
@ -67,7 +68,7 @@ angular.module('users').config(['$stateProvider',
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'
@ -94,4 +95,4 @@ angular.module('users').config(['$stateProvider',
templateUrl: 'modules/users/views/password/reset-password.client.view.html'
});
}
]);
]);

File diff suppressed because one or more lines are too long