added autosaving
This commit is contained in:
parent
6b5eaddd3e
commit
6a949d1b14
|
@ -201,7 +201,8 @@ exports.update = function(req, res) {
|
|||
});
|
||||
} else {
|
||||
console.log('updated form');
|
||||
res.json(form);
|
||||
// res.json(form);
|
||||
res.status(200).send('updated form');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -120,17 +120,19 @@ FormSchema.pre('save', function (next) {
|
|||
});
|
||||
|
||||
//Concatenate submission and form's form_fields
|
||||
FormSchema.pre('save', function (next) {
|
||||
if(this.isModified('form_fields')){
|
||||
if(this.submissions.length){
|
||||
for(var i=0; i<this.submissions.length; i++){
|
||||
this.submissions[i].form_fields = submission.form_fields.concat(_.difference(this.form_fields, this._previousFormFields));
|
||||
}
|
||||
}
|
||||
this.form_fields = this._previousFormFields.concat(_.difference(this.form_fields, this._previousFormFields));
|
||||
}
|
||||
next();
|
||||
});
|
||||
// FormSchema.pre('save', function (next) {
|
||||
// if(this.isModified('form_fields')){
|
||||
// if(this.submissions.length){
|
||||
// for(var i=0; i<this.submissions.length; i++){
|
||||
// var submission = this.submissions[i];
|
||||
// console.log(submission.form_fields);
|
||||
// this.submissions[i].form_fields = submission.form_fields.concat(_.difference(this.form_fields, this._previousFormFields));
|
||||
// }
|
||||
// }
|
||||
// this.form_fields = this._previousFormFields.concat(_.difference(this.form_fields, this._previousFormFields));
|
||||
// }
|
||||
// next();
|
||||
// });
|
||||
|
||||
//Move PDF to permanent location after new template is uploaded
|
||||
FormSchema.pre('save', function (next) {
|
||||
|
|
|
@ -12,19 +12,26 @@ function validateFormFieldType(value) {
|
|||
|
||||
var validTypes = [
|
||||
'textfield',
|
||||
'textarea',
|
||||
'statement',
|
||||
'date',
|
||||
'email',
|
||||
'legal',
|
||||
'url',
|
||||
'number',
|
||||
'filefield',
|
||||
|
||||
'textarea',
|
||||
'statement',
|
||||
'welcome',
|
||||
'thankyou',
|
||||
|
||||
'file',
|
||||
|
||||
'dropdown',
|
||||
'scale',
|
||||
'rating',
|
||||
'radio',
|
||||
'checkbox',
|
||||
'date',
|
||||
'dropdown',
|
||||
|
||||
'hidden',
|
||||
'password'
|
||||
];
|
||||
|
||||
if (validTypes.indexOf(value) > -1) {
|
||||
|
@ -52,6 +59,9 @@ var FormFieldSchema = new Schema({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
options: [{
|
||||
type: String
|
||||
}]
|
||||
required: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
|
|
|
@ -5,7 +5,7 @@ angular.module('core').controller('HeaderController', ['$rootScope','$scope','Me
|
|||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$scope.authentication = $rootScope.authentication = Auth;
|
||||
|
||||
console.log('isAuthenticated(): '+$scope.authentication.isAuthenticated());
|
||||
// console.log('isAuthenticated(): '+$scope.authentication.isAuthenticated());
|
||||
|
||||
$scope.isCollapsed = false;
|
||||
$scope.hideNav = false;
|
||||
|
|
|
@ -71,12 +71,12 @@ angular.module('forms').controller('EditFormController', ['$scope', '$state', '$
|
|||
}
|
||||
};
|
||||
|
||||
$scope.goToWithId = function(route, id) {
|
||||
$rootScope.goToWithId = function(route, id) {
|
||||
$state.go(route, {'formId': id}, {reload: true});
|
||||
};
|
||||
|
||||
// Create new Form
|
||||
$scope.createOrUpdate = function() {
|
||||
$rootScope.createOrUpdate = function() {
|
||||
|
||||
if($scope.isNewForm){
|
||||
// Create new Form object
|
||||
|
@ -100,7 +100,7 @@ angular.module('forms').controller('EditFormController', ['$scope', '$state', '$
|
|||
};
|
||||
|
||||
// Update existing Form
|
||||
$scope.update = function() {
|
||||
$rootScope.update = function() {
|
||||
var form = new Forms($scope.form);
|
||||
console.log('update form');
|
||||
console.log($scope.form);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
// Forms controller
|
||||
angular.module('forms').controller('ViewFormController', ['$scope', '$stateParams', '$state', 'Forms', 'CurrentForm','$http',
|
||||
function($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) {
|
||||
|
||||
// view form submissions
|
||||
$scope.form = CurrentForm.getForm();
|
||||
|
@ -13,6 +13,26 @@ angular.module('forms').controller('ViewFormController', ['$scope', '$stateParam
|
|||
rows: []
|
||||
};
|
||||
|
||||
$scope.saveInProgress = false;
|
||||
$scope.update = function() {
|
||||
if(!$scope.saveInProgress){
|
||||
$scope.saveInProgress = true;
|
||||
|
||||
console.log('start update()');
|
||||
|
||||
$http.put('/forms/'+$scope.form._id, {form: $scope.form})
|
||||
.then(function(response){
|
||||
console.log('form updated successfully');
|
||||
console.log('$scope.saveInProgress: '+$scope.saveInProgress);
|
||||
// $rootScope.goToWithId('viewForm', $scope.form._id);
|
||||
}).catch(function(response){
|
||||
console.log('Error occured during form UPDATE.\n');
|
||||
console.log(response.data);
|
||||
}).finally(function() {
|
||||
$scope.saveInProgress = false;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
//Table Functions
|
||||
$scope.toggleAllCheckers = function(){
|
||||
|
@ -94,7 +114,65 @@ angular.module('forms').controller('ViewFormController', ['$scope', '$stateParam
|
|||
console.log('ERROR: Form could not be deleted.');
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.goToWithId = function(route, id) {
|
||||
$state.go(route, {'formId': id}, {reload: true});
|
||||
};
|
||||
|
||||
// Create new Form
|
||||
$rootScope.createOrUpdate = function() {
|
||||
if($scope.isNewForm){
|
||||
// Create new Form object
|
||||
var form = new Forms($scope.form);
|
||||
|
||||
$http.post('/forms', {form: $scope.form})
|
||||
.success(function(data, status, headers){
|
||||
console.log('form created');
|
||||
|
||||
// Clear form fields
|
||||
$scope.form = {};
|
||||
// Redirect after save
|
||||
$scope.goToWithId('viewForm', $scope.form._id);
|
||||
}).error(function(errorResponse){
|
||||
console.log(errorResponse.data.message);
|
||||
$scope.error = errorResponse.data.message;
|
||||
});
|
||||
} else{
|
||||
$rootScope.update();
|
||||
}
|
||||
};
|
||||
|
||||
// $rootScope.saveInProgress = false;
|
||||
|
||||
var saveFinished = function() {
|
||||
$rootScope.saveInProgress = false;
|
||||
console.log('update form');
|
||||
};
|
||||
|
||||
// Update existing Form
|
||||
$rootScope.update = function() {
|
||||
|
||||
$rootScope.saveInProgress = true;
|
||||
console.log('update form');
|
||||
|
||||
$http.put('/forms/'+$scope.form._id, {form: $scope.form})
|
||||
.then(function(response){
|
||||
console.log('form updated successfully');
|
||||
}).catch(function(response){
|
||||
console.log('Error occured during form UPDATE.\n');
|
||||
console.log(response.data);
|
||||
}).finally(function() {
|
||||
$rootScope.saveInProgress = false;
|
||||
console.log('update form');
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.resetForm = function(){
|
||||
$scope.form = Forms.get({
|
||||
formId: $stateParams.formId
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
]);
|
|
@ -24,7 +24,7 @@ form .row.field {
|
|||
width:600px;
|
||||
}
|
||||
|
||||
form.config-form > .row {
|
||||
div.config-form > .row {
|
||||
padding: 19px;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f5f5f5;
|
||||
|
@ -35,16 +35,16 @@ form.config-form > .row {
|
|||
width: 90%;
|
||||
}
|
||||
|
||||
form.config-form > .row > .container:nth-of-type(odd){
|
||||
div.config-form > .row > .container:nth-of-type(odd){
|
||||
border-right: 1px #ddd solid;
|
||||
/*padding-left: 1em;*/
|
||||
}
|
||||
|
||||
form.config-form .row > .field-input {
|
||||
div.config-form .row > .field-input {
|
||||
padding-top:1.2em;
|
||||
padding-left:0.1em;
|
||||
}
|
||||
form.config-form .row > .field-input label {
|
||||
div.config-form .row > .field-input label {
|
||||
padding-left:1.3em;
|
||||
display: block;
|
||||
}
|
||||
|
@ -126,10 +126,10 @@ form.config-form > .row {
|
|||
padding-left:0.6em;
|
||||
}
|
||||
.status-light.status-light-off {
|
||||
color: red;
|
||||
color: #BE0000;
|
||||
}
|
||||
.status-light.status-light-on {
|
||||
color: green;
|
||||
color: #33CC00;
|
||||
}
|
||||
|
||||
/* Styles for form list view (/forms) */
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', function($rootScope, $timeout) {
|
||||
|
||||
return {
|
||||
require: ['^form'],
|
||||
link: function($scope, $element, $attrs, $ctrls) {
|
||||
|
||||
var difference = function(array){
|
||||
var rest = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
|
||||
|
||||
var containsEquals = function(obj, target) {
|
||||
if (obj == null) return false;
|
||||
return _.any(obj, function(value) {
|
||||
return _.isEqual(value, target);
|
||||
});
|
||||
};
|
||||
|
||||
return _.filter(array, function(value){ return !containsEquals(rest, value); });
|
||||
};
|
||||
|
||||
var $formCtrl = $ctrls[0];
|
||||
var savePromise = null;
|
||||
$scope.finishedRender = false;
|
||||
var expression = $attrs.autoSaveForm || 'true';
|
||||
|
||||
$scope.$on('ngRepeatStarted', function(ngRepeatFinishedEvent) {
|
||||
// $scope.finishedRender = false;
|
||||
});
|
||||
$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
|
||||
$scope.finishedRender = true;
|
||||
});
|
||||
|
||||
$scope.$watch('form', function(newValue, oldValue) {
|
||||
// console.log('auto saving');
|
||||
// console.log(oldValue);
|
||||
// console.log(newValue);
|
||||
if(difference(oldValue.form_fields,newValue.form_fields).length !== 0 && !$formCtrl.$dirty) {
|
||||
$formCtrl.$setDirty();
|
||||
}
|
||||
// else if(difference(oldValue.form_fields,newValue.form_fields).length === 0 ){
|
||||
// $scope.finishedRender = true;
|
||||
// }
|
||||
// console.log('\n\n-------\n$pristine: '+( $formCtrl.$pristine ) );
|
||||
// console.log('$dirty: '+( $formCtrl.$dirty ) );
|
||||
console.log('form_fields changed: '+difference(oldValue.form_fields,newValue.form_fields).length );
|
||||
console.log('$valid: '+$formCtrl.$valid);
|
||||
console.log('finishedRender: '+$scope.finishedRender);
|
||||
console.log('saveInProgress: '+$scope.saveInProgress);
|
||||
|
||||
if($scope.finishedRender && ($formCtrl.$dirty || difference(oldValue.form_fields,newValue.form_fields).length !== 0)) {
|
||||
console.log('auto saving');
|
||||
|
||||
if(savePromise) {
|
||||
$timeout.cancel(savePromise);
|
||||
}
|
||||
|
||||
savePromise = $timeout(function() {
|
||||
savePromise = null;
|
||||
|
||||
// Still valid?
|
||||
if(true) {
|
||||
// console.log('inside');
|
||||
|
||||
if($scope.$eval(expression) !== false) {
|
||||
console.log('Form data persisted -- setting pristine flag');
|
||||
$formCtrl.$setPristine();
|
||||
// $scope.finishedRender = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}, true);
|
||||
}
|
||||
};
|
||||
|
||||
}]);
|
|
@ -1,13 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('forms').directive('configureFormDirective', ['$http', '$timeout', 'timeCounter', 'Auth', 'FormFields',
|
||||
function ($http, $timeout, timeCounter, Auth, FormFields) {
|
||||
angular.module('forms').directive('configureFormDirective', ['$rootScope','$http', '$timeout', 'timeCounter', 'Auth', 'FormFields',
|
||||
function ($rootScope, $http, $timeout, timeCounter, Auth, FormFields) {
|
||||
return {
|
||||
controller: function($scope){
|
||||
$scope.log = '';
|
||||
$scope.pdfLoading = false;
|
||||
var _current_upload = null;
|
||||
|
||||
$scope.createOrUpdate = $rootScope.createOrUpdate;
|
||||
$scope.resetForm = $rootScope.resetForm;
|
||||
|
||||
var _unbindedPdfFields = $scope.pdfFields;
|
||||
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('forms').directive('editFormDirective', ['$http', '$timeout', 'timeCounter', 'Auth', 'FormFields',
|
||||
function ($http, $timeout, timeCounter, Auth, FormFields) {
|
||||
angular.module('forms').directive('editFormDirective', ['$rootScope', '$q', '$http', '$timeout', 'timeCounter', 'Auth', 'FormFields',
|
||||
function ($rootScope, $q, $http, $timeout, timeCounter, Auth, FormFields) {
|
||||
return {
|
||||
// link: function (scope, iElm, iAttrs) {
|
||||
// console.log(scope);
|
||||
// },
|
||||
templateUrl: './modules/forms/views/directiveViews/form/edit-form.html',
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
form:'=',
|
||||
user:'='
|
||||
},
|
||||
controller: function($scope){
|
||||
//Populate local scope with rootScope methods/variables
|
||||
$scope.update = $rootScope.update;
|
||||
|
||||
//Populate AddField with all available form field types
|
||||
$scope.addField = {};
|
||||
$scope.addField.types = FormFields.fields;
|
||||
// $scope.addField.new = $scope.addField.types[0].name;
|
||||
|
||||
$scope.addField.types.forEach(function(type){
|
||||
type.lastAddedID = 0;
|
||||
type.lastAddedID = 1;
|
||||
return type;
|
||||
});
|
||||
|
||||
|
@ -24,9 +36,10 @@ angular.module('forms').directive('editFormDirective', ['$http', '$timeout', 'ti
|
|||
$scope.addField.lastAddedID++;
|
||||
var fieldTitle;
|
||||
for(var i = 0; i < $scope.addField.types.length; i++){
|
||||
console.log($scope.addField.types[i].name === fieldType);
|
||||
// console.log($scope.addField.types[i].name === fieldType);
|
||||
if($scope.addField.types[i].name === fieldType){
|
||||
$scope.addField.types[i].lastAddedID++;
|
||||
console.log($scope.addField.types[i].lastAddedID);
|
||||
fieldTitle = $scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;
|
||||
break;
|
||||
}
|
||||
|
@ -64,11 +77,6 @@ angular.module('forms').directive('editFormDirective', ['$http', '$timeout', 'ti
|
|||
}
|
||||
};
|
||||
|
||||
$scope.hover = function(field) {
|
||||
// Shows/hides the delete button on hover
|
||||
return field.showTools = !field.showTools;
|
||||
};
|
||||
|
||||
// add new option to the field
|
||||
$scope.addOption = function (field){
|
||||
if(!field.field_options)
|
||||
|
@ -104,19 +112,14 @@ angular.module('forms').directive('editFormDirective', ['$http', '$timeout', 'ti
|
|||
|
||||
// decides whether field options block will be shown (true for dropdown and radio fields)
|
||||
$scope.showAddOptions = function (field){
|
||||
if(field.field_type === 'radio' || field.field_type === 'dropdown')
|
||||
if(field.fieldType == 'dropdown' || field.fieldType == 'checkbox' || field.fieldType == 'scale' || field.fieldType == 'rating' || field.fieldType == 'radio')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
},
|
||||
templateUrl: './modules/forms/views/directiveViews/form/edit-form.html',
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
form:'=',
|
||||
user:'='
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
]);
|
|
@ -32,6 +32,8 @@ angular.module('forms').directive('fieldDirective', function($http, $compile) {
|
|||
};
|
||||
|
||||
var linker = function(scope, element) {
|
||||
scope.field.required = scope.required;
|
||||
|
||||
// GET template content from path
|
||||
var templateUrl = getTemplateUrl(scope.field);
|
||||
$http.get(templateUrl).success(function(data) {
|
||||
|
@ -44,7 +46,8 @@ angular.module('forms').directive('fieldDirective', function($http, $compile) {
|
|||
template: '<div>{{field.title}}</div>',
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
field: '='
|
||||
field: '=',
|
||||
required: '&'
|
||||
},
|
||||
link: linker
|
||||
};
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
angular.module('forms').directive('formLocator', function() {
|
||||
return {
|
||||
link: function(scope) {
|
||||
scope.$emit('formLocator');
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('forms').directive('onFinishRender', function ($rootScope, $timeout) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
if (scope.$first === true) {
|
||||
$timeout(function () {
|
||||
$rootScope.$broadcast('ngRepeatStarted');
|
||||
}, 500);
|
||||
}
|
||||
if (scope.$last === true) {
|
||||
$timeout(function () {
|
||||
// console.log('ngRepeatFinished')
|
||||
$rootScope.$broadcast('ngRepeatFinished');
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input field-input">
|
||||
<input ng-model="field.fieldValue" id="{{field.client_id}}" type="checkbox" ng-init="field.fieldValue = false" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<div class="col-xs-5 field-title field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input field-input">
|
||||
<input ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" id="{{field.client_id}}" type="checkbox" ng-init="field.fieldValue = false" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<span class="required-error" ng-show="field.required && field.fieldValue == 0">(* required)</span>
|
||||
</div>
|
||||
<div class="field row">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required </span>
|
||||
<div class="col-xs-4 field-input">
|
||||
<div class="col-xs-7 field-input">
|
||||
<div class="control-group input-append">
|
||||
<input type="text" ng-model="field.fieldValue" data-date-format="mm/dd/yyyy" bs-datepicker ng-required="field.required" ng-disabled="field.disabled">
|
||||
<input type="text" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" data-date-format="mm/dd/yyyy" bs-datepicker ng-required="field.required" ng-disabled="field.disabled">
|
||||
<button type="button" class="btn" data-toggle="datepicker"><i class="icon-calendar"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<select ng-model="field.fieldValue" ng-required="field.required" ng-disabled="field.disabled">
|
||||
<div class="col-xs-7 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-5 field-input">
|
||||
<select ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled">
|
||||
<option ng-repeat="option in field.field_options"
|
||||
ng-selected="option.option_value == field.fieldValue"
|
||||
value="{{option.option_id}}">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<input type="email" placeholder="Email" value="{{field.fieldValue}}" ng-model="field.fieldValue" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<input type="email" placeholder="Email" value="{{field.fieldValue}}" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<input type="hidden" ng-model="field.fieldValue" value="{{field.fieldValue}}" ng-disabled="field.disabled">
|
||||
<input type="hidden" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" value="{{field.fieldValue}}" ng-disabled="field.disabled">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<input type="link" placeholder="link" value="{{field.fieldValue}}" ng-model="field.fieldValue" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<input type="link" placeholder="link" value="{{field.fieldValue}}" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<input type="password" ng-model="field.fieldValue" value="{{field.fieldValue}}" ng-required="field.required" ng-disabled="field.disabled">
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<input type="password" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" value="{{field.fieldValue}}" ng-required="field.required" ng-disabled="field.disabled">
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<div ng-repeat="option in field.field_options" class="row-fluid">
|
||||
<label>
|
||||
<input type="radio" value="{{option.option_value}}" ng-model="field.fieldValue" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<input type="radio" value="{{option.option_value}}" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled"/>
|
||||
<span ng-bind="option.option_title"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<textarea type="text" ng-model="field.fieldValue" value="{{field.fieldValue}}" ng-required="field.required" ng-disabled="field.disabled"></textarea>
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<textarea type="text" ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" value="{{field.fieldValue}}" ng-required="field.required" ng-disabled="field.disabled"></textarea>
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="textfield field row">
|
||||
<div class="col-xs-2 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-4 field-input">
|
||||
<div class="col-xs-5 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-7 field-input">
|
||||
<input type="text"
|
||||
ng-model="field.fieldValue"
|
||||
ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }"
|
||||
value="field.fieldValue"
|
||||
ng-required="field.required"
|
||||
ng-disabled="field.disabled" changeFocus focus-up-id="focusUpButton" focus-down-id="focusDownButton">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form class="config-form container">
|
||||
<div class="config-form container">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 container">
|
||||
<div class="row">
|
||||
|
@ -145,24 +145,45 @@
|
|||
|
||||
<div class="row field">
|
||||
<div class="field-title col-sm-6">
|
||||
<h5>Publish Form?</h5>
|
||||
<h5>Form Status</h5>
|
||||
</div>
|
||||
|
||||
<div class="field-input col-sm-6">
|
||||
|
||||
<label>
|
||||
<input type="radio" data-ng-value="true" ng-model="form.isLive" ng-required="true" />
|
||||
<span>Yes</span>
|
||||
<input type="radio" data-ng-value="true" ng-model="form.isLive" ng-required="true" style="background-color:#33CC00;"/>
|
||||
<span>Public</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="radio" data-ng-value="false" ng-model="form.isLive" ng-required="true" />
|
||||
<span>No</span>
|
||||
<span>Private</span>
|
||||
</label>
|
||||
|
||||
<!-- <span class="required-error" ng-show="field.required && !field.fieldValue">* required</span> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="row field">
|
||||
<div class="col-xs-7 field-title">{{field.title}} </div>
|
||||
<div class="col-xs-5 field-input">
|
||||
<select ng-model="field.fieldValue" ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled">
|
||||
<option ng-repeat="option in field.field_options"
|
||||
ng-selected="option.option_value == field.fieldValue"
|
||||
value="{{option.option_id}}">
|
||||
{{option.option_title}}
|
||||
</option>
|
||||
</select>
|
||||
<span class="required-error" ng-show="field.required && !field.fieldValue">* required</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<button class="btn btn-primary btn-large" type="button" ng-click="createOrUpdate()"><i class="icon-arrow-left icon-white"></i> Save Changes</button>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<button class="btn btn-primary" type="button" ng-click="resetForm()"><i class="icon-eye-open icon-white"></i> Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,4 +1,4 @@
|
|||
<div class="row">
|
||||
<form class="row" name="fieldForm" form-locator auto-save-form="update()" form="form" novalidation>
|
||||
<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>
|
||||
<button type="submit" class="btn" ng-click="addNewField()">
|
||||
|
@ -6,9 +6,10 @@
|
|||
</button> -->
|
||||
<div class="row add-field-title">
|
||||
<h3 class="col-xs-12">Add New Field</h3>
|
||||
<span ng-if="form.$dirty && form.$valid" class="help-block">Updating ...</span>
|
||||
</div>
|
||||
<div class="panel-group row">
|
||||
<div class="col-xs-6" ng-repeat="type in addField.types">
|
||||
<div class="col-xs-6" ng-repeat="type in addField.types" on-finish-render>
|
||||
<div class="panel panel-default" style="background-color:#f5f5f5;">
|
||||
<div class="panel-heading" ng-click="addNewField(type.name)" style="cursor: pointer; font-size:14px;">
|
||||
<span class="pull-left">
|
||||
|
@ -27,7 +28,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-10">
|
||||
<accordion close-others="accordion.oneAtATime">
|
||||
<accordion-group ng-repeat="field in form.form_fields" is-open="accordion[$index].isOpen" >
|
||||
<accordion-group ng-repeat="field in form.form_fields" is-open="accordion[$index].isOpen" on-finish-render="setFormValid()">
|
||||
|
||||
<accordion-heading>
|
||||
<span class="pull-left" ng-switch="field.fieldType">
|
||||
|
@ -45,12 +46,12 @@
|
|||
<!-- <button class="btn btn-danger pull-right" type="button" ng-click="deleteField(field.client_id)"><i class="icon-trash icon-white"></i> Delete</button> -->
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h5>Preview</h5>
|
||||
<h4>Preview</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<ul class="col-xs-8 container" style="list-style:none;">
|
||||
<field-directive field="field">
|
||||
<ul class="col-xs-4 container" style="list-style:none;border:2px lightgray solid;">
|
||||
<field-directive field="field" required="">
|
||||
</field-directive>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -61,18 +62,17 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-2">Field Title:</div>
|
||||
<div class="col-xs-4"><input type="text" ng-model="field.title" value="{{field.title}}"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-2">Field Default Value:</div>
|
||||
<div class="col-xs-4"><input type="text" ng-model="field.fieldValue" value="{{field.fieldValue}}"></div>
|
||||
<div class="col-xs-4"><input type="text" ng-model="field.title" value="{{field.title}}" required></div>
|
||||
</div>
|
||||
<br><br>
|
||||
<hr>
|
||||
<div class="row" ng-show="showAddOptions(field)">
|
||||
<div class="col-xs-2">Field Options:</div>
|
||||
<div class="col-xs-6">
|
||||
<div ng-repeat="option in field.field_options">
|
||||
<input type="text" ng-model="option.option_title" value="{{option.option_title}}">
|
||||
<a class="btn btn-danger btn-mini right" type="button" ng-click="deleteOption(field, option)"><i class="icon-minus icon-white"></i></a>
|
||||
<div class="col-xs-6 container">
|
||||
<div ng-repeat="option in field.field_options" class="row">
|
||||
<input type="text" name="{{option.option_title}}" ng-model="option.option_title" value="{{option.option_title}}" class="col-xs-4">
|
||||
|
||||
<a class="btn btn-danger btn-mini right" type="button" ng-click="deleteOption(field, option)" class="col-xs-3"><i class="fa fa-trash-o"></i></a>
|
||||
<span class="label label-inverse">Value: {{ option.option_value }}</span>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-small" type="button" ng-click="addOption(field)"><i class="icon-plus icon-white"></i> Add Option</button>
|
||||
|
@ -125,7 +125,7 @@
|
|||
</div>
|
||||
<div class="col-xs-1" style="padding:0 5px;" >
|
||||
<div class="panel-group tool-panel text-center">
|
||||
<div class="panel panel-default" ng-repeat="field in form.form_fields" ng-mouseenter="hover(field)" ng-mouseleave="hover(field)">
|
||||
<div class="panel panel-default" ng-repeat="field in form.form_fields">
|
||||
<div class="panel-heading" style="padding: 10px 10px; height: 37px;" ng-click="deleteField(field.$$hashKey)">
|
||||
<span class="text-center">
|
||||
<a href="" class="fa fa-trash-o"></a>
|
||||
|
@ -136,7 +136,7 @@
|
|||
</div>
|
||||
<div class="col-xs-1" style="padding:0 5px;">
|
||||
<div class="panel-group tool-panel text-center">
|
||||
<div class="panel panel-default" ng-repeat="field in form.form_fields" ng-mouseenter="hover(field)" ng-mouseleave="hover(field)">
|
||||
<div class="panel panel-default" ng-repeat="field in form.form_fields">
|
||||
<div class="panel-heading" style="padding: 10px 10px; height: 37px;" ng-click="duplicateField(field, $index)">
|
||||
<span class="text-center">
|
||||
<a href="" class="fa fa-files-o"></a>
|
||||
|
@ -147,4 +147,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
|
@ -6,9 +6,9 @@
|
|||
<div class="col-xs-3">
|
||||
<small class=" pull-right">
|
||||
<a class="btn btn-default" href="/#!/forms/{{form._id}}">
|
||||
View <span ng-show="form.isLive">Live</span> <span ng-hide="form.isLive">Preview</span> Form
|
||||
<span ng-show="form.isLive">View Live</span> <span ng-hide="form.isLive">Preview</span> Form
|
||||
<i class="status-light status-light-on fa fa-dot-circle-o" ng-show="form.isLive"></i>
|
||||
<i class="status-light status-light-off fa fa-circle-o" ng-hide="form.isLive"></i>
|
||||
<i class="status-light status-light-off fa fa-dot-circle-o" ng-hide="form.isLive"></i>
|
||||
<!-- <i class="fa fa-sign-out"></i> -->
|
||||
</a>
|
||||
</small>
|
||||
|
|
|
@ -20,8 +20,8 @@ angular.module('users')
|
|||
return service.currentUser;
|
||||
}
|
||||
else if ($window.user){
|
||||
console.log('Using cached current user.');
|
||||
console.log($window.user);
|
||||
// console.log('Using cached current user.');
|
||||
// console.log($window.user);
|
||||
service.currentUser = $window.user;
|
||||
return service.currentUser;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue