Created
January 27, 2017 10:04
-
-
Save salami-art/5cd54bde89004fc0c77cdb56a57f0214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Here we manage the action of creating a new question. | |
# | |
angular.module('mymodule_light').controller "QuestionsNewCtrl", ['$scope', '$modal', '$http', 'current_session', ($scope, $modal, $http, current_session)-> | |
$scope.question = | |
description: "" | |
$scope.ask = (question)-> | |
current_session.options.prevent_redirect = true | |
unless current_session.present() | |
$modal.open("login.patient_form") # $('#login_choices_modal').modal('show') | |
current_session.onLogin((user, location, options)-> | |
$modal.closeAll() | |
$scope.ask(question) | |
,0) | |
else | |
$scope.processingQuestion = true | |
data = { question: question } | |
# CREATING A NEW QUESTION | |
$http.post("/api/v1/risposte/", data).success( | |
(send_response)-> | |
window.location.href = "/congratulazioni-domanda-gratis" | |
).error( | |
(r)-> | |
console.error "Error while asking question... LOG: " + r | |
Flashing.setMessage("bad"," Error ( ... ) ." ) | |
) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment