removed autosave for configuration settings

This commit is contained in:
David Baldwynn 2015-07-06 19:52:55 -07:00
parent c07a9ba267
commit 23fd8e36d6
12 changed files with 81 additions and 80 deletions

View file

@ -1,4 +1,4 @@
FROM dockerfile/nodejs FROM node:0.10
MAINTAINER Matthias Luebken, matthias@catalyst-zero.com MAINTAINER Matthias Luebken, matthias@catalyst-zero.com

View file

@ -39,7 +39,7 @@ exports.signup = function(req, res) {
if (err) { if (err) {
res.status(400).send(err); res.status(400).send(err);
} else { } else {
res.json(user); res.status(200).send('user successfully loggedin');
} }
}); });
} }

View file

@ -4,6 +4,7 @@
angular.module('forms').controller('ViewFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm','$http', angular.module('forms').controller('ViewFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm','$http',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http) { function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http) {
$scope.myform = CurrentForm.getForm(); $scope.myform = CurrentForm.getForm();
$scope.submissions = undefined; $scope.submissions = undefined;
$scope.viewSubmissions = false; $scope.viewSubmissions = false;
@ -147,9 +148,7 @@ angular.module('forms').controller('ViewFormController', ['$rootScope', '$scope'
}else { }else {
form._id = form_id; form._id = form_id;
} }
$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');

View file

@ -31,11 +31,15 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
$scope.finishedRender = true; $scope.finishedRender = true;
}); });
$scope.$watch('form', function(newValue, oldValue) { $scope.$watch('myform.form_fields', function(newValue, oldValue) {
// console.log('auto saving'); // console.log('auto saving');
// console.log(oldValue); console.log(oldValue);
// console.log(newValue); console.log(newValue);
if(difference(oldValue.form_fields,newValue.form_fields).length !== 0 && !$formCtrl.$dirty) { if(difference(oldValue,newValue).length === 0 || oldValue === undefined){
console.log('returning');
return;
}
if(difference(oldValue,newValue).length !== 0 && !$formCtrl.$dirty) {
$formCtrl.$setDirty(); $formCtrl.$setDirty();
} }
// else if(difference(oldValue.form_fields,newValue.form_fields).length === 0 ){ // else if(difference(oldValue.form_fields,newValue.form_fields).length === 0 ){
@ -43,13 +47,13 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
// } // }
// console.log('\n\n-------\n$pristine: '+( $formCtrl.$pristine ) ); // console.log('\n\n-------\n$pristine: '+( $formCtrl.$pristine ) );
// console.log('$dirty: '+( $formCtrl.$dirty ) ); // console.log('$dirty: '+( $formCtrl.$dirty ) );
console.log('form_fields changed: '+difference(oldValue.form_fields,newValue.form_fields).length ); // console.log('form_fields changed: '+difference(oldValue.form_fields,newValue.form_fields).length );
console.log('$valid: '+$formCtrl.$valid); // console.log('$valid: '+$formCtrl.$valid);
console.log('finishedRender: '+$scope.finishedRender); // console.log('finishedRender: '+$scope.finishedRender);
console.log('saveInProgress: '+$scope.saveInProgress); // console.log('saveInProgress: '+$scope.saveInProgress);
if($scope.finishedRender && ($formCtrl.$dirty || difference(oldValue.form_fields,newValue.form_fields).length !== 0)) { if($scope.finishedRender && ($formCtrl.$dirty || difference(oldValue,newValue).length !== 0)) {
console.log('auto saving'); // console.log('auto saving');
if(savePromise) { if(savePromise) {
$timeout.cancel(savePromise); $timeout.cancel(savePromise);
@ -63,7 +67,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
// console.log('inside'); // console.log('inside');
if($scope.$eval(expression) !== false) { if($scope.$eval(expression) !== false) {
console.log('Form data persisted -- setting pristine flag'); // console.log('Form data persisted -- setting pristine flag');
$formCtrl.$setPristine(); $formCtrl.$setPristine();
// $scope.finishedRender = false; // $scope.finishedRender = false;
} }

View file

@ -6,6 +6,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope','$http
controller: function($scope){ controller: function($scope){
$scope.log = ''; $scope.log = '';
$scope.pdfLoading = false; $scope.pdfLoading = false;
$scope.languages = $rootScope.languages;
var _current_upload = null; var _current_upload = null;
$scope.createOrUpdate = $rootScope.createOrUpdate; $scope.createOrUpdate = $rootScope.createOrUpdate;
$scope.resetForm = $rootScope.resetForm; $scope.resetForm = $rootScope.resetForm;
@ -25,11 +26,11 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope','$http
}; };
$scope.removePDF = function(){ $scope.removePDF = function(){
$scope.form.pdf = null; $scope.myform.pdf = null;
$scope.form.isGenerated = false; $scope.myform.isGenerated = false;
$scope.form.autofillPDFs = false; $scope.myform.autofillPDFs = false;
console.log('form.pdf: '+$scope.form.pdf+' REMOVED'); console.log('form.pdf: '+$scope.myform.pdf+' REMOVED');
}; };
$scope.uploadPDF = function(files) { $scope.uploadPDF = function(files) {
@ -41,7 +42,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope','$http
url: '/upload/pdf', url: '/upload/pdf',
fields: { fields: {
'user': $scope.user, 'user': $scope.user,
'form': $scope.form 'form': $scope.myform
}, },
file: file file: file
}).progress(function (evt) { }).progress(function (evt) {
@ -51,12 +52,12 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope','$http
$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;
console.log($scope.form.pdf); console.log($scope.myform.pdf);
$scope.form.pdf = angular.fromJson(angular.toJson(data)); $scope.myform.pdf = angular.fromJson(angular.toJson(data));
$scope.pdfLoading = false; $scope.pdfLoading = false;
console.log($scope.log); console.log($scope.log);
console.log('$scope.pdf: '+$scope.form.pdf.name); console.log('$scope.pdf: '+$scope.myform.pdf.name);
if(!$scope.$$phase){ if(!$scope.$$phase){
$scope.$apply(); $scope.$apply();
} }
@ -73,7 +74,7 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope','$http
templateUrl: './modules/forms/views/directiveViews/form/configure-form.html', templateUrl: './modules/forms/views/directiveViews/form/configure-form.html',
restrict: 'E', restrict: 'E',
scope: { scope: {
form:'=', myform:'=',
user:'=', user:'=',
pdfFields:'@', pdfFields:'@',
formFields:'@' formFields:'@'

View file

@ -9,7 +9,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
templateUrl: './modules/forms/views/directiveViews/form/edit-form.html', templateUrl: './modules/forms/views/directiveViews/form/edit-form.html',
restrict: 'E', restrict: 'E',
scope: { scope: {
form:'=', myform:'=',
user:'=' user:'='
}, },
controller: function($scope){ controller: function($scope){
@ -53,25 +53,25 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$ht
}; };
// put newField into fields array // put newField into fields array
$scope.form.form_fields.unshift(newField); $scope.myform.form_fields.unshift(newField);
console.log($scope.myform.form_fields.length);
}; };
// deletes particular field on button click // deletes particular field on button click
$scope.deleteField = function (hashKey){ $scope.deleteField = function (hashKey){
console.log($scope.form.form_fields); console.log($scope.myform.form_fields);
for(var i = 0; i < $scope.form.form_fields.length; i++){ for(var i = 0; i < $scope.myform.form_fields.length; i++){
console.log($scope.form.form_fields[i].$$hashKey === hashKey); console.log($scope.myform.form_fields[i].$$hashKey === hashKey);
if($scope.form.form_fields[i].$$hashKey === hashKey){ if($scope.myform.form_fields[i].$$hashKey === hashKey){
$scope.form.form_fields.splice(i, 1); $scope.myform.form_fields.splice(i, 1);
break; break;
} }
} }
}; };
$scope.duplicateField = function (field, field_index){ $scope.duplicateField = function (field, field_index){
for(var i = 0; i < $scope.form.form_fields.length; i++){ for(var i = 0; i < $scope.myform.form_fields.length; i++){
if($scope.form.form_fields[i].field_id === field.field_id){ if($scope.myform.form_fields[i].field_id === field.field_id){
// $scope.form.form_fields.splice(field_index+1, 0, field); $scope.addNewField($scope.myform.form_fields[i].fieldType);
$scope.addNewField($scope.form.form_fields[i].fieldType);
break; break;
} }
} }

View file

@ -15,12 +15,12 @@
<div class="field-input col-sm-6"> <div class="field-input col-sm-6">
<label> <label>
<input type="radio" data-ng-value="true" ng-model="form.hideFooter" ng-required="true" /> <input type="radio" data-ng-value="true" ng-model="myform.hideFooter" ng-required="true" />
&nbsp;<span>Yes</span> &nbsp;<span>Yes</span>
</label> </label>
<label> <label>
<input type="radio" data-ng-value="false" ng-model="form.hideFooter" ng-required="true" /> <input type="radio" data-ng-value="false" ng-model="myform.hideFooter" ng-required="true" />
&nbsp;<span>No</span> &nbsp;<span>No</span>
</label> </label>
@ -29,7 +29,7 @@
</div> </div>
<!-- autofillPDFs yes/no field --> <!-- autofillPDFs yes/no field -->
<div class="row field" ng-if="form.isGenerated"> <div class="row field">
<div class="field-title col-sm-6"> <div class="field-title col-sm-6">
<h5>Save Submissions as PDFs?</h5> <h5>Save Submissions as PDFs?</h5>
</div> </div>
@ -37,12 +37,12 @@
<div class="field-input col-sm-6"> <div class="field-input col-sm-6">
<label> <label>
<input type="radio" data-ng-value="true" ng-model="form.autofillPDFs" ng-required="true" /> <input type="radio" data-ng-value="true" ng-model="myform.autofillPDFs" ng-required="true" />
&nbsp;<span>Yes</span> &nbsp;<span>Yes</span>
</label> </label>
<label> <label>
<input type="radio" data-ng-value="false" ng-model="form.autofillPDFs" ng-required="true" /> <input type="radio" data-ng-value="false" ng-model="myform.autofillPDFs" ng-required="true" />
&nbsp;<span>No</span> &nbsp;<span>No</span>
</label> </label>
@ -51,20 +51,20 @@
</div> </div>
<!-- Upload PDF Field --> <!-- Upload PDF Field -->
<div class="row field" ng-if="form.autofillPDFs"> <div class="row field" ng-if="myform.autofillPDFs || myform.isGenerated">
<div class="col-sm-6 field-title"> <div class="col-sm-6 field-title">
<h5>Upload Your PDF Template</h5> <h5>Upload Your PDF Template</h5>
</div> </div>
<div class="col-sm-6 field-input"> <div class="col-sm-6 field-input">
<div class="input-group "> <div class="input-group ">
<div tabindex="-1" class="form-control file-caption"> <div tabindex="-1" class="form-control file-caption">
<span class="file-caption-ellipsis" ng-if="!form.pdf"></span> <span class="file-caption-ellipsis" ng-if="!myform.pdf"></span>
<div class="file-caption-name" ng-if="form.pdf"> <div class="file-caption-name" ng-if="myform.pdf">
{{form.pdf.originalname}} {{myform.pdf.originalname}}
</div> </div>
</div> </div>
<div class="input-group-btn"> <div class="input-group-btn">
<button type="button" ng-if="form.pdf" ng-click="removePDF();" title="Clear selected files" class="btn btn-danger fileinput-remove fileinput-remove-button"> <button type="button" ng-if="myform.pdf" ng-click="removePDF();" title="Clear selected files" class="btn btn-danger fileinput-remove fileinput-remove-button">
<i class="glyphicon glyphicon-trash" ></i> <i class="glyphicon glyphicon-trash" ></i>
Delete Delete
</button> </button>
@ -74,7 +74,7 @@
Cancel Cancel
</button> </button>
<div class="btn btn-success btn-file" ngf-select ngf-change="uploadPDF($files)" ng-if="!form.pdf"> <div class="btn btn-success btn-file" ngf-select ngf-change="uploadPDF($files)" ng-if="!myform.pdf">
<i class="glyphicon glyphicon-upload"></i> <i class="glyphicon glyphicon-upload"></i>
Upload your PDF Upload your PDF
</div> </div>
@ -84,19 +84,19 @@
</div> </div>
<!-- generate form from PDF yes/no field --> <!-- generate form from PDF yes/no field -->
<div class="row field" ng-if="form.pdf"> <div class="row field">
<div class="col-sm-6 field-title"> <div class="col-sm-6 field-title">
<h5>Autogenerate Form?</h5> <h5>Autogenerate Form?</h5>
</div> </div>
<div class="col-sm-6 field-input"> <div class="col-sm-6 field-input">
<label> <label>
<input type="radio" data-ng-value="true" ng-model="form.isGenerated" ng-required="true" /> <input type="radio" data-ng-value="true" ng-model="myform.isGenerated" ng-required="true" />
&nbsp;<span>Yes</span> &nbsp;<span>Yes</span>
</label> </label>
<label> <label>
<input type="radio" data-ng-value="false" ng-model="form.isGenerated" ng-required="true" /> <input type="radio" data-ng-value="false" ng-model="myform.isGenerated" ng-required="true" />
&nbsp;<span>No</span> &nbsp;<span>No</span>
</label> </label>
</div> </div>
@ -105,7 +105,7 @@
<!-- !!!!!!DAVID: TODO: Finish this so we can upload pdfFieldMap!!!!!!!!! --> <!-- !!!!!!DAVID: TODO: Finish this so we can upload pdfFieldMap!!!!!!!!! -->
<!-- Map form inputs to PDF inputs Field --> <!-- Map form inputs to PDF inputs Field -->
<!-- <div class="textfield field row" ng-if="form.pdf"> <!-- <div class="textfield field row" ng-if="myform.pdf">
<div class="col-xs-2 field-title field-title">Map Form Fields to PDF Fields </div> <div class="col-xs-2 field-title field-title">Map Form Fields to PDF Fields </div>
<div class="col-xs-4 field-input field-input"> <div class="col-xs-4 field-input field-input">
<div class="row" ng-repeat="field in formFields"> <div class="row" ng-repeat="field in formFields">
@ -137,8 +137,8 @@
<div class="col-sm-6 field-input field-input"> <div class="col-sm-6 field-input field-input">
<input type="text" <input type="text"
ng-model="form.title" ng-model="myform.title"
value="{{form.title}}"> value="{{myform.title}}">
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span> <span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
</div> </div>
</div> </div>
@ -151,12 +151,12 @@
<div class="field-input col-sm-6"> <div class="field-input col-sm-6">
<label> <label>
<input type="radio" data-ng-value="true" ng-model="form.isLive" ng-required="true" style="background-color:#33CC00;"/> <input type="radio" data-ng-value="true" ng-model="myform.isLive" ng-required="true" style="background-color:#33CC00;"/>
&nbsp;<span>Public</span> &nbsp;<span>Public</span>
</label> </label>
<label> <label>
<input type="radio" data-ng-value="false" ng-model="form.isLive" ng-required="true" /> <input type="radio" data-ng-value="false" ng-model="myform.isLive" ng-required="true" />
&nbsp;<span>Private</span> &nbsp;<span>Private</span>
</label> </label>
@ -164,13 +164,13 @@
</div> </div>
</div> </div>
<div class="row field"> <div class="row field">
<div class="col-xs-7 field-title">{{field.title}} </div> <div class="col-xs-6 field-title">Language</div>
<div class="col-xs-5 field-input"> <div class="col-xs-4 field-input">
<select ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"> <select ng-model="myform.language">
<option ng-repeat="option in field.field_options" <option ng-repeat="language in languages"
ng-selected="option.option_value == field.fieldValue" ng-selected="language == myform.language"
value="{{option.option_id}}"> value="{{language}}">
{{option.option_title}} {{language}}
</option> </option>
</select> </select>
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span> <span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>

View file

@ -1,4 +1,4 @@
<form class="row" name="fieldForm" form-locator auto-save-form="update()" form="form" novalidation> <form class="row" name="fieldForm" form-locator auto-save-form="update()" form="myform" novalidation>
<div class="add-field col-xs-5"> <div class="add-field col-xs-5">
<!-- <select ng-model="addField.new" ng-options="type.name as type.value for type in addField.types"></select> <!-- <select ng-model="addField.new" ng-options="type.name as type.value for type in addField.types"></select>
<button type="submit" class="btn" ng-click="addNewField()"> <button type="submit" class="btn" ng-click="addNewField()">
@ -28,7 +28,7 @@
<div class="row"> <div class="row">
<div class="col-xs-10"> <div class="col-xs-10">
<accordion close-others="accordion.oneAtATime"> <accordion close-others="accordion.oneAtATime">
<accordion-group ng-repeat="field in form.form_fields" is-open="accordion[$index].isOpen" on-finish-render="setFormValid()"> <accordion-group ng-repeat="field in myform.form_fields" is-open="accordion[$index].isOpen" on-finish-render="setFormValid()">
<accordion-heading> <accordion-heading>
<span class="pull-left" ng-switch="field.fieldType"> <span class="pull-left" ng-switch="field.fieldType">

View file

@ -1,17 +1,14 @@
<section data-ng-controller="ViewFormController" data-ng-init="findOne()" class="container admin-form"> <section data-ng-controller="ViewFormController" data-ng-init="findOne()" class="container admin-form">
<div class="page-header row" style="padding-bottom: 0px;"> <div class="page-header row" style="padding-bottom: 0px;">
<div class="col-xs-6"> <div class="col-xs-6">
<h1 data-ng-bind="form.title" style="margin-bottom: 0px;"></h1> <h1 data-ng-bind="myform.title" style="margin-bottom: 0px;"></h1>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-2 col-xs-offset-2">
<small class=" pull-right"> <small class=" pull-right">
<a class="btn btn-default" href="/#!/forms/{{form._id}}"> <button class="btn btn-danger" ng-click="remove()"><i class="fa fa-trash-o"></i> Delete Form</button>
<span ng-click="remove()">Delete Form</span>
<!-- <i class="fa fa-sign-out"></i> -->
</a>
</small> </small>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-2">
<small class=" pull-right"> <small class=" pull-right">
<a class="btn btn-default" href="/#!/forms/{{form._id}}"> <a class="btn btn-default" href="/#!/forms/{{form._id}}">
<span ng-show="myform.isLive">View Live</span> <span ng-hide="myform.isLive">Preview</span> Form <span ng-show="myform.isLive">View Live</span> <span ng-hide="myform.isLive">Preview</span> Form
@ -30,19 +27,19 @@
<tab-heading> <tab-heading>
Edit Form Fields Edit Form Fields
</tab-heading> </tab-heading>
<edit-form-directive form="myform" user="user"></edit-form-directive> <edit-form-directive myform="myform" user="user"></edit-form-directive>
</tab> </tab>
<tab disabled="true"> <tab disabled="true">
<tab-heading > <tab-heading >
Edit Design Edit Design
</tab-heading> </tab-heading>
<edit-form-directive form="myform" user="user"></edit-form-directive> <edit-form-directive myform="myform" user="user"></edit-form-directive>
</tab> </tab>
<tab> <tab>
<tab-heading> <tab-heading>
Configure Configure
</tab-heading> </tab-heading>
<configure-form-directive form="myform" user="user"></configure-form-directive> <configure-form-directive myform="myform" user="user"></configure-form-directive>
</tab> </tab>
<tab data-ng-click="showSubmissions()"> <tab data-ng-click="showSubmissions()">
<tab-heading> <tab-heading>

View file

@ -5,6 +5,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
$scope = $rootScope; $scope = $rootScope;
$scope.credentials = {}; $scope.credentials = {};
$scope.error = null;
// If user is signed in then redirect back home // If user is signed in then redirect back home
if ($scope.authentication.isAuthenticated()) $state.go('home'); if ($scope.authentication.isAuthenticated()) $state.go('home');
@ -14,9 +15,8 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
// console.log($scope.credentials); // console.log($scope.credentials);
Auth.currentUser = User.login($scope.credentials).then( Auth.currentUser = User.login($scope.credentials).then(
function(response) { function(response) {
Auth.login(); Auth.login(response);
$rootScope.user = Auth.ensureHasCurrentUser(User); $scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
$scope = $rootScope;
console.log('$state.previous: \n'); console.log('$state.previous: \n');
console.log($state.previous); console.log($state.previous);
@ -29,7 +29,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
}, },
function(error) { function(error) {
$rootScope.user = Auth.ensureHasCurrentUser(User); $rootScope.user = Auth.ensureHasCurrentUser(User);
$scope = $rootScope; $scope.user = $rootScope.user;
$scope.error = error; $scope.error = error;
console.log('loginError: '+error); console.log('loginError: '+error);
@ -38,7 +38,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
}; };
$scope.signup = function() { $scope.signup = function() {
$scope.user = User.save($scope.registration, User.save($scope.registration,
function() { function() {
$state.go('signup-success'); $state.go('signup-success');
}, },

View file

@ -52,8 +52,9 @@ angular.module('users')
return userState; return userState;
}, },
login: function() { login: function(new_user) {
userState.isLoggedIn = true; userState.isLoggedIn = true;
service.currentUser = new_user;
}, },
logout: function() { logout: function() {

View file

@ -22,7 +22,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
var deferred = $q.defer(); var deferred = $q.defer();
$http.post('/auth/signin', credentials).success(function(response) { $http.post('/auth/signin', credentials).success(function(response) {
// console.log(response);
deferred.resolve(response); deferred.resolve(response);
}).error(function(error) { }).error(function(error) {