Compare commits

...

1 commit

Author SHA1 Message Date
David Baldwynn a2423708e1 got docker to work 2017-10-26 08:05:05 -07:00
25 changed files with 301 additions and 40270 deletions

View file

@ -4,7 +4,7 @@
var ApplicationConfiguration = (function() { var ApplicationConfiguration = (function() {
// Init module configuration options // Init module configuration options
var applicationModuleName = 'TellForm'; var applicationModuleName = 'TellForm';
var applicationModuleVendorDependencies = ['duScroll', 'ui.select', 'ngSanitize', 'vButton', 'ngResource', 'TellForm.templates', 'ui.router', 'ui.bootstrap', 'ui.utils', 'pascalprecht.translate', 'view-form']; var applicationModuleVendorDependencies = ['ui.select', 'ngSanitize', 'vButton', 'ngResource', 'TellForm.templates', 'ui.router', 'ui.bootstrap', 'ui.utils', 'pascalprecht.translate', 'view-form'];
// Add a new vertical module // Add a new vertical module
var registerModule = function(moduleName, dependencies) { var registerModule = function(moduleName, dependencies) {

View file

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

View file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -9,5 +9,8 @@ angular.module('view-form').controller('SubmitFormController', [
$(".loader").fadeOut("slow"); $(".loader").fadeOut("slow");
document.body.style.background = myForm.design.colors.backgroundColor; document.body.style.background = myForm.design.colors.backgroundColor;
$translate.use(myForm.language); $translate.use(myForm.language);
var ctrl = this;
ctrl.visible_form_fields = $scope.myform.visible_form_fields;
} }
]); ]);

View file

@ -16,11 +16,13 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
restrict: 'E', restrict: 'E',
scope: { scope: {
myform:'=', myform:'=',
ispreview: '=' ispreview: '=',
ctrl: '='
}, },
controller: function($document, $window, $scope){ controller: function($document, $window, $scope){
var NOSCROLL = false; var NOSCROLL = false;
var FORM_ACTION_ID = 'submit_field'; var FORM_ACTION_ID = 'submit_field';
var FIELDS_HIDDEN = false;
$scope.forms = {}; $scope.forms = {};
//Don't start timer if we are looking at a design preview //Don't start timer if we are looking at a design preview
@ -28,21 +30,21 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
TimeCounter.restartClock(); TimeCounter.restartClock();
} }
var form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ var visible_form_fields_count = $scope.ctrl.visible_form_fields.filter(function(field){
return field.fieldType !== 'statement'; return field.fieldType !== 'statement';
}).length; }).length;
var nb_valid = $filter('formValidity')($scope.myform); var nb_valid = $filter('formValidity')($scope.myform);
$scope.translateAdvancementData = { $scope.translateAdvancementData = {
done: nb_valid, done: nb_valid,
total: form_fields_count, total: visible_form_fields_count,
answers_not_completed: form_fields_count - nb_valid answers_not_completed: visible_form_fields_count - nb_valid
}; };
$scope.reloadForm = function(){ $scope.reloadForm = function(){
//Reset Form //Reset Form
$scope.myform.submitted = false; $scope.myform.submitted = false;
$scope.myform.form_fields = _.chain($scope.myform.visible_form_fields).map(function(field){ $scope.ctrl.visible_form_fields = _.chain($scope.ctrl.visible_form_fields).map(function(field){
field.fieldValue = ''; field.fieldValue = '';
return field; return field;
}).value(); }).value();
@ -54,12 +56,17 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
_id: '', _id: '',
index: 0 index: 0
}; };
$scope.setActiveField($scope.myform.visible_form_fields[0]._id, 0, false); $scope.setActiveField($scope.ctrl.visible_form_fields[0]._id, 0, false);
//Reset Timer //Reset Timer
TimeCounter.restartClock(); TimeCounter.restartClock();
}; };
angular.element('.submission-form').ready(function(){
//Reload our form
$scope.reloadForm();
});
/* /*
** Field Controls ** Field Controls
*/ */
@ -130,7 +137,7 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
} }
if($scope.selected._id === FORM_ACTION_ID) { if($scope.selected._id === FORM_ACTION_ID) {
return $scope.myform.form_fields.length - 1; return $scope.ctrl.visible_form_fields.length - 1;
} }
return $scope.selected.index; return $scope.selected.index;
}; };
@ -142,19 +149,30 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
return false; return false;
}; };
var hideFieldsFromIndex = function(index){
for(var i=index; i < $scope.ctrl.visible_form_fields.length; i++){
$scope.ctrl.visible_form_fields[i].deletePreserved = true;
}
}
var showFieldsFromIndex = function(index){
for(var i=index; i < $scope.ctrl.visible_form_fields; i++){
$scope.ctrl.visible_form_fields[i].deletePreserved = false;
}
}
$scope.setActiveField = $rootScope.setActiveField = function(field_id, field_index, animateScroll) { $scope.setActiveField = $rootScope.setActiveField = function(field_id, field_index, animateScroll) {
if($scope.selected === null || (!field_id && field_index === null) ) { if($scope.selected === null || (!field_id && field_index === null) ) {
return; return;
} }
if(!field_id){ if(!field_id){
field_id = $scope.myform.visible_form_fields[field_index]._id; field_id = $scope.ctrl.visible_form_fields[field_index]._id;
} else if(field_index === null){ } else if(field_index === null){
field_index = $scope.myform.visible_form_fields.length field_index = 0;
for(var i=0; i < $scope.ctrl.visible_form_fields.length; i++){
for(var i=0; i < $scope.myform.visible_form_fields.length; i++){ var curr_field = $scope.ctrl.visible_form_fields[i];
var currField = $scope.myform.visible_form_fields[i]; if(curr_field['_id'] == field_id){
if(currField['_id'] == field_id){
field_index = i; field_index = i;
break; break;
} }
@ -165,15 +183,41 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
return; return;
} }
//Required Field Validation Handling
var selected_index = $scope.selected.index;
var curr_field = $scope.ctrl.visible_form_fields[selected_index];
if(curr_field.required === true){
if($scope.forms.myForm && $scope.forms.myForm[curr_field.fieldType + '' + selected_index].$valid === false && !FIELDS_HIDDEN){
var hideIndex = selected_index;
if(selected_index == 0) hideIndex++;
hideFieldsFromIndex(hideIndex);
FIELDS_HIDDEN = true;
$scope.selected._id = field_id; $scope.selected._id = field_id;
$scope.selected.index = field_index; $scope.selected.index = field_index;
return;
} else if ($scope.forms.myForm && $scope.forms.myForm[curr_field.fieldType + '' + selected_index].$valid === true && FIELDS_HIDDEN) {
console.log("made it!");
showFieldsFromIndex(selected_index);
FIELDS_HIDDEN = false;
return 1;
} else if($scope.FIELDS_HIDDEN){
return;
}
}
console.log("$scope.ctrl.visible_form_fields[1].deletePreserved: "+$scope.ctrl.visible_form_fields[1].deletePreserved);
$scope.selected._id = field_id;
$scope.selected.index = field_index;
var nb_valid = $filter('formValidity')($scope.myform); var nb_valid = $filter('formValidity')($scope.myform);
$scope.translateAdvancementData = { $scope.translateAdvancementData = {
done: nb_valid, done: nb_valid,
total: form_fields_count, total: visible_form_fields_count,
answers_not_completed: form_fields_count - nb_valid answers_not_completed: visible_form_fields_count - nb_valid
}; };
if(animateScroll){ if(animateScroll){
@ -195,11 +239,24 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
}); });
}); });
}); });
} else {
setTimeout(function() {
if (document.querySelectorAll('.activeField .focusOn').length) {
//Handle default case
document.querySelectorAll('.activeField .focusOn')[0].focus();
} else if(document.querySelectorAll('.activeField input').length) {
//Handle case for rating input
document.querySelectorAll('.activeField input')[0].focus();
} else {
//Handle case for dropdown input
document.querySelectorAll('.activeField .selectize-input')[0].focus();
}
});
} }
}; };
$scope.$watch('selected.index', function(oldValue, newValue){ $scope.$watch('selected.index', function(oldValue, newValue){
if(oldValue !== newValue && newValue < $scope.myform.form_fields.length){ if(oldValue !== newValue && newValue < $scope.ctrl.visible_form_fields.length){
//Only send analytics data if form has not been submitted //Only send analytics data if form has not been submitted
if(!$scope.myform.submitted){ if(!$scope.myform.submitted){
console.log('SendVisitorData.send()'); console.log('SendVisitorData.send()');
@ -210,7 +267,7 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
//Fire event when window is scrolled //Fire event when window is scrolled
$window.onscroll = function(){ $window.onscroll = function(){
if(!NOSCROLL){ if(!NOSCROLL || $scope.FIELDS_HIDDEN){
var scrollTop = $(window).scrollTop(); var scrollTop = $(window).scrollTop();
var elemBox = document.getElementsByClassName('activeField')[0].getBoundingClientRect(); var elemBox = document.getElementsByClassName('activeField')[0].getBoundingClientRect();
@ -224,14 +281,14 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
var maxScrollTop = $(document).height() - $(window).height(); var maxScrollTop = $(document).height() - $(window).height();
var fieldWrapperHeight = $('form_fields').height(); var fieldWrapperHeight = $('form_fields').height();
var selector = 'form > .field-directive:nth-of-type(' + String($scope.myform.visible_form_fields.length - 1)+ ')' var selector = 'form > .field-directive:nth-of-type(' + String($scope.ctrl.visible_form_fields.length - 1)+ ')'
var fieldDirectiveHeight = $(selector).height() var fieldDirectiveHeight = $(selector).height()
var scrollPosition = maxScrollTop - submitSectionHeight - fieldDirectiveHeight*1.2; var scrollPosition = maxScrollTop - submitSectionHeight - fieldDirectiveHeight*1.2;
var fractionToJump = 0.9; var fractionToJump = 0.9;
//Focus on field above submit form button //Focus on field above submit form button
if($scope.selected.index === $scope.myform.visible_form_fields.length){ if($scope.selected.index === $scope.ctrl.visible_form_fields.length){
if(scrollTop < scrollPosition){ if(scrollTop < scrollPosition){
field_index = $scope.selected.index-1; field_index = $scope.selected.index-1;
$scope.setActiveField(null, field_index, false); $scope.setActiveField(null, field_index, false);
@ -239,13 +296,13 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
} }
//Focus on submit form button //Focus on submit form button
else if($scope.selected.index === $scope.myform.visible_form_fields.length-1 && scrollTop > scrollPosition){ else if($scope.selected.index === $scope.ctrl.visible_form_fields.length-1 && scrollTop > scrollPosition){
field_index = $scope.selected.index+1; field_index = $scope.selected.index+1;
$scope.setActiveField(FORM_ACTION_ID, field_index, false); $scope.setActiveField(FORM_ACTION_ID, field_index, false);
} }
//If we scrolled bellow the current field, move to next field //If we scrolled bellow the current field, move to next field
else if(fieldBottom < elemHeight * fractionToJump && $scope.selected.index < $scope.myform.visible_form_fields.length-1 ){ else if(fieldBottom < elemHeight * fractionToJump && $scope.selected.index < $scope.ctrl.visible_form_fields.length-1 ){
field_index = $scope.selected.index+1; field_index = $scope.selected.index+1;
$scope.setActiveField(null, field_index, false); $scope.setActiveField(null, field_index, false);
} }
@ -263,25 +320,26 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
if($scope.selected && $scope.selected.index > -1){ if($scope.selected && $scope.selected.index > -1){
if($scope.selected._id !== FORM_ACTION_ID){ if($scope.selected._id !== FORM_ACTION_ID){
var currField = $scope.myform.visible_form_fields[$scope.selected.index]; var curr_field = $scope.ctrl.visible_form_fields[$scope.selected.index];
var retVal = null;
//Jump to logicJump's destination if it is true //Jump to logicJump's destination if it is true
if(currField.logicJump && currField.logicJump.jumpTo && evaluateLogicJump(currField)){ if(curr_field.logicJump && curr_field.logicJump.jumpTo && evaluateLogicJump(curr_field)){
$scope.setActiveField(currField.logicJump.jumpTo, null, true); retVal = $scope.setActiveField(curr_field.logicJump.jumpTo, null, true);
} else if($scope.selected.index < $scope.myform.visible_form_fields.length-1){ } else if($scope.selected.index < $scope.ctrl.visible_form_fields.length-1){
$scope.setActiveField(null, $scope.selected.index+1, true); retVal = $scope.setActiveField(null, $scope.selected.index+1, true);
} else { } else {
$scope.setActiveField(FORM_ACTION_ID, null, true); retVal = $scope.setActiveField(FORM_ACTION_ID, null, true);
}
} else {
//If we are at the submit actions page, go to the first field
$rootScope.setActiveField(null, 0, true);
}
} else {
//If selected is not defined go to the first field
$rootScope.setActiveField(null, 0, true);
} }
if(retVal === 1){
$scope.$apply();
return $scope.nextField();
}
return;
}
}
return $scope.setActiveField(null, 0, true);
}; };
$rootScope.prevField = $scope.prevField = function(){ $rootScope.prevField = $scope.prevField = function(){
@ -303,8 +361,8 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
*/ */
$scope.exitStartPage = function(){ $scope.exitStartPage = function(){
$scope.myform.startPage.showStart = false; $scope.myform.startPage.showStart = false;
if($scope.myform.visible_form_fields.length > 0){ if($scope.ctrl.visible_form_fields.length > 0){
$scope.selected._id = $scope.myform.visible_form_fields[0]._id; $scope.selected._id = $scope.ctrl.visible_form_fields[0]._id;
} }
}; };
@ -347,6 +405,15 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
}; };
}; };
var getFromVisibleFormFields = function(globalId){
for(var i=0; i<$scope.ctrl.visible_form_fields.length; i++){
if( $scope.ctrl.visible_form_fields[i].globalId === globalId ){
return $scope.ctrl.visible_form_fields[i];
}
}
return null;
}
$rootScope.submitForm = $scope.submitForm = function() { $rootScope.submitForm = $scope.submitForm = function() {
if($scope.forms.myForm.$invalid){ if($scope.forms.myForm.$invalid){
$scope.goToInvalid(); $scope.goToInvalid();
@ -366,7 +433,7 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
form.geoLocation = geoData.geoLocation; form.geoLocation = geoData.geoLocation;
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.ctrl.visible_form_fields.length * 100;
delete form.endPage delete form.endPage
delete form.isLive delete form.isLive
delete form.provider delete form.provider
@ -377,9 +444,16 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
delete form.submissions; delete form.submissions;
delete form.submitted; delete form.submitted;
for(var i=0; i < $scope.myform.form_fields.length; i++){ for(var i=0; i < $scope.myform.form_fields.length; i++){
visible_form_field = getFromVisibleFormFields( $scope.myform.form_fields[i].globalId);
if(visible_form_field){
$scope.myform.form_fields[i].fieldValue = visible_form_field;
if($scope.myform.form_fields[i].fieldType === 'dropdown' && !$scope.myform.form_fields[i].deletePreserved){ if($scope.myform.form_fields[i].fieldType === 'dropdown' && !$scope.myform.form_fields[i].deletePreserved){
$scope.myform.form_fields[i].fieldValue = $scope.myform.form_fields[i].fieldValue.option_value; $scope.myform.form_fields[i].fieldValue = $scope.myform.form_fields[i].fieldValue.option_value;
} }
} else {
$scope.myform.form_fields[i].fieldValue = '';
}
//Get rid of unnessecary attributes for each form field //Get rid of unnessecary attributes for each form field
delete form.form_fields[i].submissionId; delete form.form_fields[i].submissionId;
@ -390,7 +464,6 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
delete form.form_fields[i].description; delete form.form_fields[i].description;
delete form.form_fields[i].validFieldTypes; delete form.form_fields[i].validFieldTypes;
delete form.form_fields[i].fieldType; delete form.form_fields[i].fieldType;
} }
setTimeout(function () { setTimeout(function () {
@ -407,9 +480,6 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
}); });
}, 500); }, 500);
}; };
//Reload our form
$scope.reloadForm();
} }
}; };
} }

View file

@ -15,7 +15,8 @@
</div> </div>
<div class="col-xs-12 field-input"> <div class="col-xs-12 field-input">
<div class="control-group input-append"> <div class="control-group input-append">
<input class="focusOn" <input class="focusOn inputElem"
name="{{field.fieldType}}{{index}}"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
ng-class="{ 'no-border': !!field.fieldValue }" ng-class="{ 'no-border': !!field.fieldValue }"

View file

@ -15,6 +15,7 @@
</div> </div>
<div class="col-xs-12 field-input"> <div class="col-xs-12 field-input">
<ui-select ng-model="field.fieldValue" <ui-select ng-model="field.fieldValue"
name="{{field.fieldType}}{{index}}"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
theme="selectize" theme="selectize"
search-enabled="true" search-enabled="true"

View file

@ -22,6 +22,7 @@
<label class="btn col-md-5 col-xs-12" <label class="btn col-md-5 col-xs-12"
ng-class="{activeBtn: field.fieldValue == 'true'}"> ng-class="{activeBtn: field.fieldValue == 'true'}">
<input class="focusOn" <input class="focusOn"
name="{{field.fieldType}}{{index}}"
ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
type="radio" value="true" type="radio" value="true"
ng-model="field.fieldValue" ng-model="field.fieldValue"
@ -36,6 +37,7 @@
<label class="btn col-md-5 col-md-offset-1 col-xs-12" <label class="btn col-md-5 col-md-offset-1 col-xs-12"
ng-class="{activeBtn: field.fieldValue == 'false'}"> ng-class="{activeBtn: field.fieldValue == 'false'}">
<input class="focusOn" <input class="focusOn"
name="{{field.fieldType}}{{index}}"
ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
type="radio" value="false" type="radio" value="false"
ng-model="field.fieldValue" ng-model="field.fieldValue"

View file

@ -26,6 +26,7 @@
{{$index+1}} {{$index+1}}
</div> </div>
<input ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" <input ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
name="{{field.fieldType}}{{index}}"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
type="radio" class="focusOn" type="radio" class="focusOn"
value="{{option.option_value}}" value="{{option.option_value}}"

View file

@ -15,6 +15,7 @@
<div class="col-xs-12 field-input"> <div class="col-xs-12 field-input">
<input-stars max="{{field.ratingOptions.steps}}" <input-stars max="{{field.ratingOptions.steps}}"
name="{{field.fieldType}}{{index}}"
ng-init="field.fieldValue = 1" ng-init="field.fieldValue = 1"
on-shape-click="true" on-shape-click="true"
on-star-click="nextField()" on-star-click="nextField()"

View file

@ -16,6 +16,7 @@
<div class="col-xs-12 field-input"> <div class="col-xs-12 field-input">
<small style="font-size:0.6em;">Press SHIFT+ENTER to add a newline</small> <small style="font-size:0.6em;">Press SHIFT+ENTER to add a newline</small>
<textarea class="textarea focusOn" type="text" <textarea class="textarea focusOn" type="text"
name="{{field.fieldType}}{{index}}"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"

View file

@ -27,6 +27,7 @@
style="background: rgba(0,0,0,0.1); text-align:left;"> style="background: rgba(0,0,0,0.1); text-align:left;">
<input type="radio" value="true" <input type="radio" value="true"
class="focusOn" class="focusOn"
name="{{field.fieldType}}{{index}}"
style="opacity: 0; margin-left: 0px;" style="opacity: 0; margin-left: 0px;"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
ng-model="field.fieldValue" ng-model="field.fieldValue"
@ -46,6 +47,7 @@
style="background: rgba(0,0,0,0.1); text-align:left;"> style="background: rgba(0,0,0,0.1); text-align:left;">
<input type="radio" value="false" <input type="radio" value="false"
name="{{field.fieldType}}{{index}}"
style="opacity:0; margin-left:0px;" style="opacity:0; margin-left:0px;"
ng-focus="setActiveField(field._id, null, false)" ng-focus="setActiveField(field._id, null, false)"
ng-model="field.fieldValue" ng-model="field.fieldValue"

View file

@ -41,13 +41,16 @@
<div class="row form-field-wrapper"> <div class="row form-field-wrapper">
<form name="forms.myForm" novalidate class="submission-form"> <form name="forms.myForm" novalidate class="submission-form">
<div ng-repeat="field in myform.form_fields" ng-if="!field.deletePreserved" data-index="{{$index}}" data-id="{{field._id}}" ng-class="{activeField: selected._id == field._id }" class="row field-directive"> <div ng-repeat="field in ctrl.visible_form_fields" ng-if="!field.deletePreserved" data-index="{{$index}}" data-id="{{field._id}}" ng-class="{activeField: (selected._id == field._id), hidden: !!field.deletePreserved }" class="row field-directive">
<field-directive field="field" design="myform.design" index="$index" forms="forms"
<field-directive field="field" design="myform.design" index="$index" forms="forms"> ng-if="!field.deletePreserved"
ng-class="{activeField: (selected._id == field._id), hidden: !!field.deletePreserved }">
</field-directive> </field-directive>
</div> </div>
<div class="row form-actions" id="submit_field" ng-class="{activeField: selected._id == 'submit_field' }" <div class="row form-actions" id="submit_field"
ng-style="{ 'background-color':myform.design.colors.buttonColor}" style="border-top: 1px solid #ddd; margin-top: 30vh; height: 100vh; margin-left: 1%; margin-right: 1%;" ng-class="{activeField: selected._id == 'submit_field' }"
ng-style="{ 'background-color':myform.design.colors.buttonColor}"
style="border-top: 1px solid #ddd; margin-top: 30vh; height: 100vh; margin-left: 1%; margin-right: 1%;"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
on-tab-key="nextField()" on-tab-key="nextField()"
on-enter-key="submitForm()"> on-enter-key="submitForm()">

View file

@ -1,5 +1,5 @@
<section class="public-form"> <section class="public-form">
<submit-form-directive myform="myform"></submit-form-directive> <submit-form-directive myform="myform" ctrl="ctrl"></submit-form-directive>
</section> </section>
<!-- User's Google Analytics --> <!-- User's Google Analytics -->

View file

@ -121,19 +121,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo
// Update existing Form // Update existing Form
$scope.update = $rootScope.update = function(updateImmediately, data, shouldDiff, refreshAfterUpdate, cb){ $scope.update = $rootScope.update = function(updateImmediately, data, shouldDiff, refreshAfterUpdate, cb){
var continueUpdate = true;
if(!updateImmediately){
continueUpdate = !$rootScope.saveInProgress;
}
//Update form **if we are not in the middle of an update** or if **shouldUpdateNow flag is set**
if(continueUpdate) {
var err = null;
if (!updateImmediately) {
$rootScope.saveInProgress = true;
}
if (shouldDiff) { if (shouldDiff) {
//Do this so we can create duplicate fields //Do this so we can create duplicate fields
var checkForValidId = new RegExp('^[0-9a-fA-F]{24}$'); var checkForValidId = new RegExp('^[0-9a-fA-F]{24}$');
@ -154,15 +141,18 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo
$scope.oldForm = _.cloneDeep($scope.myform); $scope.oldForm = _.cloneDeep($scope.myform);
} }
}).catch(function (response) { }).catch(function (response) {
err = response.data; var err = response.data;
console.error(err); console.error(err);
if ((typeof cb) === 'function') {
return cb(err);
}
}).finally(function () { }).finally(function () {
if (!updateImmediately) { if (!updateImmediately) {
$rootScope.saveInProgress = false; $rootScope.saveInProgress = false;
} }
if ((typeof cb) === 'function') { if ((typeof cb) === 'function') {
return cb(err); return cb();
} }
}); });
} else { } else {
@ -197,19 +187,21 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo
} }
}).catch(function (response) { }).catch(function (response) {
err = response.data; var err = response.data;
console.error(err); console.error(err);
if ((typeof cb) === 'function') {
return cb(err);
}
}).finally(function () { }).finally(function () {
if (!updateImmediately) { if (!updateImmediately) {
$rootScope.saveInProgress = false; $rootScope.saveInProgress = false;
} }
if ((typeof cb) === 'function') { if ((typeof cb) === 'function') {
return cb(err); return cb();
} }
}); });
} }
}
}; };

View file

@ -131,12 +131,15 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$scope.saveField = function(){ $scope.saveField = function(){
if($scope.isEdit){ if($scope.isEdit){
$scope.myform.form_fields[field_index] = $scope.field; $scope.$parent.myform.form_fields[field_index] = $scope.field;
} else { } else {
$scope.myform.form_fields.push(curr_field); $scope.$parent.myform.form_fields.push($scope.field);
} }
$scope.$parent.update(false, $scope.$parent.myform, true, true, function(){ $scope.$parent.update(false, $scope.$parent.myform, true, true, function(err){
if(err){
console.error(err);
}
$uibModalInstance.close(); $uibModalInstance.close();
}); });
@ -344,6 +347,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$scope.duplicateField = function(field_index){ $scope.duplicateField = function(field_index){
var currField = angular.copy($scope.myform.form_fields[field_index]); var currField = angular.copy($scope.myform.form_fields[field_index]);
currField._id = 'cloned'+_.uniqueId(); currField._id = 'cloned'+_.uniqueId();
currField.globalId = 'cloned'+_.uniqueId();
currField.title += ' copy'; currField.title += ' copy';
//Insert field at selected index //Insert field at selected index

View file

@ -485,10 +485,7 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</script> </script>
<!-- Add Fields Element --> <!-- Add Fields Element -->
@ -503,7 +500,7 @@
<div class="col-xs-12 col-sm-12 col-md-6" ng-repeat="type in addField.types" style="padding-top:7.5px;"> <div class="col-xs-12 col-sm-12 col-md-6" ng-repeat="type in addField.types" style="padding-top:7.5px;">
<div class="panel panel-default" style="background-color:#f5f5f5;"> <div class="panel panel-default" style="background-color:#f5f5f5;">
<div class="panel-heading" ng-click="addNewField(false, type.name)" style="cursor: pointer; font-size:12px; padding-left: 10px; padding-right: 10px;"> <div class="panel-heading" ng-click="addNewField(type.name)" style="cursor: pointer; font-size:12px; padding-left: 10px; padding-right: 10px;">
<span> <span>
<field-icon-directive type-name="{{type.name}}"> <field-icon-directive type-name="{{type.name}}">
</field-icon-directive> </field-icon-directive>