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++){ for(var i=0; i<forms.length; i++){
forms[i] = helpers.removeSensitiveModelData('private_form', forms[i]); forms[i] = helpers.removeSensitiveModelData('private_form', forms[i]);
currIndex = result_ids.indexOf(forms[i]._id+'') currIndex = result_ids.indexOf(forms[i]._id)
console.log("forms[i]: ")
console.log(forms[i]);
console.log(result_ids);
console.log("currIndex: "+currIndex);
if(currIndex > -1){ if(currIndex > -1){
forms[i].submissionNum = results[currIndex].responses; forms[i].submissionNum = results[currIndex].responses;
} else { } else {

View File

@ -69,10 +69,15 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
$scope.duplicateForm = function(form_index){ $scope.duplicateForm = function(form_index){
var form = _.cloneDeep($scope.myforms[form_index]); var form = _.cloneDeep($scope.myforms[form_index]);
delete form._id; delete form._id;
delete form.id;
form.title += ' copy';
$http.post('/forms', {form: form}) $http.post('/forms', {form: form})
.then(function(resp_data, status, headers){ .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){ }, function(errorResponse){
console.error(errorResponse); console.error(errorResponse);
if(errorResponse === null){ if(errorResponse === null){