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
@ -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.qactive = true;
|
||||||
$rootScope.uactive = false;
|
$rootScope.uactive = false;
|
||||||
$scope.survey = Survey.get({ surveyId: $routeParams.surveyId });
|
$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() {
|
$scope.editSurvey = function() {
|
||||||
this.survey.edit = true;
|
this.survey.edit = true;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,8 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
||||||
<button type="button" class="btn btn-danger" ng-click="deleteSurvey()">Supprimer</button>
|
<button type="button" class="btn btn-danger" ng-if="survey.id" ng-click="deleteSurvey()">Supprimer</button>
|
||||||
|
<button type="button" class="btn btn-secondary" ng-if="survey.id" ng-click="duplicateSurvey()">Dupliquer avec ces nouveaux paramètres</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user