got delete modal working in list forms view

This commit is contained in:
David Baldwynn 2016-11-14 12:07:36 -08:00
parent 601dcd64e4
commit 090b38f12a
12 changed files with 176 additions and 63 deletions

View file

@ -116,7 +116,6 @@ exports.listSubmissions = function(req, res) {
exports.create = function(req, res) {
if(!req.body.form){
console.log(err);
return res.status(400).send({
message: "Invalid Input"
});

View file

@ -182,7 +182,7 @@ var FormSchema = new Schema({
}
},
font: String
}
},
}, formSchemaOptions);
/*

View file

@ -194,8 +194,8 @@ FormFieldSchema.pre('validate', function(next) {
//LogicJump Save
FormFieldSchema.pre('save', function(next) {
if(this.logicJump && this.logicJump.fieldA){
if(this.logicJump.jumpTo = '') delete this.logicJump.jumpTo;
if(this.logicJump && this.logicJump.fieldA) {
if(this.logicJump.jumpTo === '') delete this.logicJump.jumpTo;
}
next();
});

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

View file

@ -26,10 +26,10 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
//Admin Form View
ARE_YOU_SURE: 'Are you ABSOLUTELY sure?',
READ_WARNING: 'Unexpected bad things will happen if you dont read this!',
DELETE_WARNING1: 'This action CANNOT be undone.This will permanently delete the',
DELETE_WARNING2: 'form, form submissions and remove all associated pdfs.',
DELETE_CONFIRM: 'Please type in the name of the form to confirm',
I_UNDERSTAND: 'I understand the consequences, delete this form',
DELETE_WARNING1: 'This action CANNOT be undone. This will permanently delete the "',
DELETE_WARNING2: '" form and remove all associated form submissions.',
DELETE_CONFIRM: 'Please type in the name of the form to confirm.',
I_UNDERSTAND: 'I understand the consequences, delete this form.',
DELETE_FORM_SM: 'Delete',
DELETE_FORM_MD: 'Delete Form',
DELETE: 'Delete',

View file

@ -1,8 +1,8 @@
'use strict';
// Forms controller
angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http) {
angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$uibModal',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $uibModal) {
$scope = $rootScope;
$scope.forms = {};
@ -15,6 +15,41 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
}
};
/*
** DeleteModal Functions
*/
$scope.openDeleteModal = function(index){
$scope.deleteModal = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'deleteModalListForms.html',
controller: function($uibModalInstance, items, $scope) {
$scope.content = items;
$scope.cancel = $scope.cancelDeleteModal;
$scope.deleteForm = function() {
$scope.removeForm(items.formIndex);
}
},
resolve: {
items: function() {
return {
currFormTitle: $scope.myforms[index].title,
formIndex: index
};
}
}
});
};
$scope.cancelDeleteModal = function(){
if($scope.deleteModal){
$scope.deleteModal.dismiss('cancel');
}
};
// Return all user's Forms
$scope.findAll = function() {
Forms.query(function(_forms){
@ -86,6 +121,7 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
.success(function(data, status, headers){
//console.log('form deleted successfully');
$scope.myforms.splice(form_index, 1);
$scope.cancelDeleteModal();
}).error(function(error){
//console.log('ERROR: Form could not be deleted.');
console.error(error);

View file

@ -44,14 +44,11 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
/*
** Analytics Functions
*/
$scope.AverageTimeElapsed = (function(){
var totalTime = 0;
var numSubmissions = $scope.table.rows.length;
console.log("AverageTimeElapsed");
console.log($scope.table.rows);
for(var i=0; i<$scope.table.rows.length; i++){
totalTime += $scope.table.rows[i].timeElapsed;
}

View file

@ -15,14 +15,12 @@
{{ 'READ_WARNING' | translate }}
</div>
<p class="hidden-xs hidden-sm">
{{ 'DELETE_WARNING1' | translate }}<strong>{{myform.title}}</strong> {{ 'DELETE_WARNING2' | translate }}
{{ 'DELETE_WARNING1' | translate }} <strong>{{myform.title}}</strong> {{ 'DELETE_WARNING2' | translate }}
</p>
<p>{{ 'DELETE_CONFIRM' | translate }}</p>
</div>
<div class="modal-footer">
<p>
<input type="text" data-ng-model="deleteConfirm" class="input-block" autofocus required aria-label="Type in the name of the form to confirm that you want to delete this form.">
</p>
<input type="text" style="width:100%" data-ng-model="deleteConfirm" class="input-block" autofocus required aria-label="Type in the name of the form to confirm that you want to delete this form.">
<button type="submit" ng-click="removeCurrentForm()" class="btn btn-block btn-danger" ng-disabled="myform.title != deleteConfirm">
{{ 'I_UNDERSTAND' | translate }}
</button>
@ -53,11 +51,6 @@
</span>
<span ng-hide="myform.isLive">{{ 'PREVIEW' | translate }}</span>
</span>
<!--<span class="hidden-xs hidden-md hidden-lg">-->
<!--View-->
<!--<span ng-if="myform.isLive">{{ 'LIVE' | translate }}</span>-->
<!--<span ng-if="!myform.isLive">{{ 'PREVIEW' | translate }}</span>-->
<!--</span>-->
<i class="status-light status-light-on fa fa-dot-circle-o" ng-if="myform.isLive"></i>
<i class="status-light status-light-off fa fa-dot-circle-o" ng-if="!myform.isLive"></i>
</a>

View file

@ -2,6 +2,29 @@
<section class="overlay" ng-if="showCreateModal" ng-click="closeCreateModal()"></section>
<!-- Modal Delete Dialog Template -->
<script type="text/ng-template" id="deleteModalListForms.html">
<div class="modal-header">
<h2 class="modal-title hidden-md hidden-lg">{{ 'ARE_YOU_SURE' | translate }}</h2>
<h3 class="modal-title hidden-xs hidden-sm">{{ 'ARE_YOU_SURE' | translate }}</h3>
</div>
<div class="modal-body">
<div class="modal-body-alert">
{{ 'READ_WARNING' | translate }}
</div>
<p class="hidden-xs hidden-sm">
{{ 'DELETE_WARNING1' | translate }} <strong>{{content.currFormTitle}}</strong> {{ 'DELETE_WARNING2' | translate }}
</p>
<p>{{ 'DELETE_CONFIRM' | translate }}</p>
</div>
<div class="modal-footer">
<input type="text" style="width:100%" data-ng-model="deleteConfirm" class="input-block" autofocus required aria-label="Type in the name of the form to confirm that you want to delete this form.">
<button type="submit" ng-click="deleteForm" class="btn btn-block btn-danger" ng-disabled="content.currFormTitle != deleteConfirm">
{{ 'I_UNDERSTAND' | translate }}
</button>
</div>
</script>
<section data-ng-controller="ListFormsController as ctrl" data-ng-init="findAll()" class="container">
<br>
<div class="row">
@ -59,14 +82,14 @@
<div class="row">
<span class="pull-right">
<i style="cursor:pointer;" class="fa fa-trash-o" ng-click="removeForm($index)"></i>
<i style="cursor:pointer;" class="fa fa-trash-o" ng-click="openDeleteModal($index)"></i>
<i style="cursor:pointer;" class="fa fa-files-o" ng-click="duplicateForm($index)"></i>
</span>
</div>
<div class="row">
<a data-ng-href="#!/forms/{{form._id}}/admin/create"
class="title-row col-xs-12">
class="title-row col-xs-12" style="color: white;">
<h4 class="list-group-item-heading" data-ng-bind="form.title"></h4>
</a>
<div class="col-xs-12 responses-row">