Able to duplicate existing survey
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
000ac334cc
commit
f3fd0be2b8
2 changed files with 19 additions and 2 deletions
|
@ -280,7 +280,7 @@ angular.module("AtsebaytApp")
|
|||
}
|
||||
})
|
||||
|
||||
.controller("SurveyController", function($scope, $rootScope, Survey, $routeParams, $location) {
|
||||
.controller("SurveyController", function($scope, $rootScope, Survey, SurveyQuest, $routeParams, $location) {
|
||||
$rootScope.qactive = true;
|
||||
$rootScope.uactive = false;
|
||||
$scope.survey = Survey.get({ surveyId: $routeParams.surveyId });
|
||||
|
@ -300,6 +300,22 @@ angular.module("AtsebaytApp")
|
|||
}
|
||||
}
|
||||
|
||||
$scope.duplicateSurvey = function() {
|
||||
var bakSurveyId = this.survey.id;
|
||||
delete this.survey.id;
|
||||
this.survey.$save(function() {
|
||||
// Now recopy questions
|
||||
var questions = SurveyQuest.query({ surveyId: bakSurveyId });
|
||||
questions.$promise.then(function (questions) {
|
||||
questions.forEach(function (question) {
|
||||
delete question.id
|
||||
question.$save({ surveyId: $scope.survey.id });
|
||||
})
|
||||
$location.url("surveys/" + $scope.survey.id);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editSurvey = function() {
|
||||
this.survey.edit = true;
|
||||
}
|
||||
|
|
Reference in a new issue