fixed bugs in listForms duplication

This commit is contained in:
David Baldwynn 2017-11-19 21:31:26 -08:00
parent 9d040e9672
commit 66409c15d8
2 changed files with 7 additions and 8 deletions

View file

@ -489,13 +489,7 @@ exports.list = function(req, res) {
for(var i=0; i<forms.length; i++){
forms[i] = helpers.removeSensitiveModelData('private_form', forms[i]);
currIndex = result_ids.indexOf(forms[i]._id+'')
console.log("forms[i]: ")
console.log(forms[i]);
console.log(result_ids);
console.log("currIndex: "+currIndex);
currIndex = result_ids.indexOf(forms[i]._id)
if(currIndex > -1){
forms[i].submissionNum = results[currIndex].responses;
} else {

View file

@ -69,10 +69,15 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
$scope.duplicateForm = function(form_index){
var form = _.cloneDeep($scope.myforms[form_index]);
delete form._id;
delete form.id;
form.title += ' copy';
$http.post('/forms', {form: form})
.then(function(resp_data, status, headers){
$scope.myforms.splice(form_index+1, 0, resp_data.data);
var result_form = resp_data.data;
result_form.submissionNum = 0;
$scope.myforms.splice(form_index+1, 0, result_form);
}, function(errorResponse){
console.error(errorResponse);
if(errorResponse === null){