{:uriI"file://app/assets/javascripts/components/surveys/SurveyQuestionAnswersController.js?type=application/javascript&pipeline=self&id=bf0c407cc631566907fe1b88be2095d26250b5d96a45e6de96bfce581c6d2317:ET:load_pathI"app/assets/javascripts;T: filenameI"Qapp/assets/javascripts/components/surveys/SurveyQuestionAnswersController.js;T: nameI"7components/surveys/SurveyQuestionAnswersController;T:logical_pathI"?components/surveys/SurveyQuestionAnswersController.self.js;T:content_typeI"application/javascript;T: sourceI" function SurveyQuestionAnswersController($scope, $rootScope, $state, $location, $modal, $stateParams, ApiAdapter, Survey, Question, Answer) { $scope.headers = { 'Accept-Language': 'en' }; $scope.survey = null; Survey.get({ surveyId: $stateParams.surveyId }, {}).then( function(result) { $scope.survey = result; $scope.$apply() } ); $scope.question = null; $scope.answers = {}; $scope.$watch("headers['Accept-Language']", function(newValue, oldValue) { Question.get({ questionId: $stateParams.questionId }, {}).then( function(result) { $scope.question = result; $scope.$apply() } ); Answer.index({ questionId: $stateParams.questionId }, {}, { no_cache: true, headers: $scope.headers }).then( function(result) { $scope.answers = result; if(!$scope.$$phase) { $scope.$apply() } } ); }); $scope.answer_delete = function(self_href) { ApiAdapter.execute("delete_answer", self_href, {}, true ).then( function(response) { $state.go($state.current, {}, {reload: true}); } ); }; $scope.answer_edit = function(answer_id) { $modal.open({ size: 'lg', resolve: { answer: [function($stateParams, Api) { return Answer.get({answerId: answer_id}); }] }, controller: function($scope, $modalInstance, answer) { $scope.model = { id: answer.data.id, answer: { attributes: answer.data.attributes } }; $scope.onSubmit = function(data) { return ApiAdapter.execute("update_answer", { answerId: answer_id }, JSON.stringify(data), { no_cache: true, headers: { 'Accept-Language': data.language } }).then( function(response) { $state.go($state.current, {}, {reload: true}); $modalInstance.close(); return response; } ); }; $scope.cancel = function() { $modalInstance.close(); }; }, templateUrl: "/assets/components/surveys/AnswerModal.html" }); }; $scope.answer_new = function() { $modal.open({ size: 'lg', controller: function($scope, $modalInstance) { $scope.model = { answer: { attributes: { text: "" } } }; $scope.onSubmit = function(data) { return ApiAdapter.execute("create_answer", { questionId: $stateParams.questionId }, JSON.stringify(data), { no_cache: true, headers: { 'Accept-Language': data.language } }).then( function(response) { $state.go($state.current, {}, {reload: true}); $modalInstance.close(); return response; } ); }; $scope.cancel = function() { $modalInstance.close(); }; }, templateUrl: "/assets/components/surveys/AnswerModal.html" }); }; }; ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"_file-digest://app/assets/javascripts/components/surveys/SurveyQuestionAnswersController.js;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%D6_wT`1!J>HϷ9: lengthi :dependencies_digest"%}a:dJbt]I'Iv:idI"Ebf0c407cc631566907fe1b88be2095d26250b5d96a45e6de96bfce581c6d2317;F: mtimel+bIJV