ActionController::RoutingError (No route matches [GET] "/pt/office/connect_to"):
This file contains 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
<% @title = 'Adicionar paciente' %> | |
<%= render 'doctor/connexions/new_connexion_request_form' %> | |
<script type="text/javascript"> | |
set_modal_form('<%= @title %>', "<%= modal_form_submit_button() %>", '<%= t 'buttons.close' %>') | |
</script> |
This file contains 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
<%= semantic_form_for(@connexion_request, :url => doctor_create_connexion_request_url(), remote: true, html: {id: 'modal_form', class: 'form-horizontal'}) do |f| %> | |
<%= f.semantic_errors *f.object.errors.keys %> | |
<%= f.inputs do %> | |
<%= f.input :name, required: false, placeholder: true, hint: true, input_html: {class: ''} %> | |
<%= f.input :email, required: true, placeholder: true, hint: true, input_html: {class: ''} %> | |
<%= f.input :comments, required: false, placeholder: true, hint: true, input_html: {class: 'input-block-level'} %> | |
<% end %> | |
<% end %> | |
<script>$('form#modal_form').validate();</script> |
This file contains 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
# encoding: utf-8 | |
class Doctor::ConnexionsController < ConnexionsController | |
before_filter :authenticate_doctor! | |
before_filter :check_doctor_validation, except: ['index'] | |
# match 'office/connect_to' => 'doctor/connexions#new_connexion_request', as: :doctor_new_connexion_request | |
def new_connexion_request | |
@connexion_request = @user.connexion_requests.new() | |
@connexion_request.comments = I18n.t(:doctor_invitation_text, doctor_name: @user.name, product_name: PRODUCT_NAME) | |
render 'doctor/connexions/_new_connexion_request', layout: false | |
end | |
def create_connexion_request | |
@error = true | |
@patient = false | |
@patient = (Patient.find_by_email(params[:connexion_request][:email].downcase) || false) if params[:connexion_request].has_key?(:email) | |
# request to existent patient user | |
if @patient | |
@connexion_request = @user.connexion_requests.new(params[:connexion_request]) | |
# check if connexion exists? | |
if (connexion_exists = @user.connexions.where(patient_id: @patient).exists?) | |
flash[:alert] = "Já existe uma ligação com #{@patient.name}." | |
# check if request exists? | |
elsif (request_exists = ConnexionRequest.accepted_or_pending_request_exists?(@user, @patient)) | |
flash[:alert] = "Já existe um pedido de ligação pendente ou aceite com #{@patient.name}." | |
# this request does not exists, is not accepted or pending, or connexion doesn't exist yet | |
else | |
@connexion_request.invitee = @patient | |
@connexion_request.status = 0 | |
if @connexion_request.save | |
flash[:notice] = t(:connexion_successfully_created, name: @connexion_request.invitee.name) | |
else | |
return | |
end | |
end | |
# request by email | |
elsif params[:connexion_request].has_key?(:email) | |
email = params[:connexion_request][:email].downcase | |
@connexion_request = @user.connexion_requests.new(params[:connexion_request]) | |
# check if request exists? | |
if (request_exists = ConnexionRequest.accepted_or_pending_request_exists?(@user, email, true)) | |
flash[:alert] = "Já existe um pedido de ligação pendente para o email #{email}." | |
# this request does not exists, is not accepted or pending, or connexion doesn't exist yet | |
else | |
@connexion_request.status = 0 | |
if @connexion_request.save | |
flash[:notice] = t(:connexion_successfully_created, name: "#{@connexion_request.name} #{@connexion_request.email}") | |
else | |
return | |
end | |
end | |
# unknown parameters | |
else | |
@error = true | |
flash[:notice] = t(:error) | |
end | |
render js: %(window.location.href='#{doctor_connexions_url()}') and return | |
end | |
# def destroy_connexion | |
# @connexion = @user.connexions.find_by_patient_id(params[:id]) || false | |
# if @connexion | |
# @patient_id = params[:id] | |
# @connexion.destroy | |
# @flash_message = t(:connexion_destroyed, name: @connexion.patient.name) | |
# end | |
# end | |
def view_request_form | |
@connexion = @user.connexions.find_by_id(params[:id]) || false | |
render @connexion, layout: false | |
end | |
#get "office/connexions/patient/:connexion_id" => 'doctor/connexions#view_patient_profile', as: :view_patient_profile | |
def view_patient_profile | |
@connexion = @user.connexions.find_by_id(params[:connexion_id]) || false | |
if @connexion | |
@doctor_note = @doctor.doctor_notes.find_or_create_by_connexion_id(@connexion.id) | |
@patient = @connexion.patient | |
@documents = @patient.documents | |
else | |
flash[:alert] = t(:patient_not_found) | |
redirect_to doctor_connexions_url | |
end | |
end | |
end |
This file contains 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
<% @title = 'Adicionar paciente' %> | |
$('#modal .modal-body').html("<%= j(render 'doctor/connexions/new_connexion_request_form') %>"); | |
set_modal_form('<%= @title %>', "<%= modal_form_submit_button() %>", '<%= t 'buttons.close' %>'); |
This file contains 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
function set_modals() { | |
$("a[data-target=#modal]").click(function(ev) { | |
ev.preventDefault(); | |
var target = $(this).attr("href"); | |
$("#modal .modal-body").addClass('loader'); | |
$("#modal .modal-body").html(''); | |
$("#modal .modal-header h3").html(''); | |
$('#modal .modal-footer').html(''); | |
// load the url and show modal on success | |
$("#modal .modal-body").load(target, function() { | |
$("#modal .modal-body").removeClass('loader'); | |
$("#modal").modal("show"); | |
}); | |
}); | |
}; | |
function set_modal_form(title, submit_button_html, close_text) { | |
$('#modal .modal-header h3').html(title); | |
$('#modal .modal-footer').html(submit_button_html); | |
$('#modal .modal-footer').append('<button class="btn" data-dismiss="modal" aria-hidden="true" id="close_modal">'+close_text+'</button>'); | |
$('#modal_submit_button').click(function(){ | |
$(this).addClass('disabled'); | |
$(this).html('<span class="icon-spinner icon-spin "></span>'); | |
$('#close_modal').remove(); | |
$('#modal_form').submit(); | |
}); | |
} | |
function set_documents_modal_form(title, submit_button_html, close_text) { | |
$('#modal .modal-header h3').html(title); | |
$('#modal .modal-footer').html(submit_button_html); | |
$('#modal .modal-footer').append('<button class="btn" data-dismiss="modal" aria-hidden="true" id="close_modal">'+close_text+'</button>'); | |
$('#modal_submit_button').addClass('disabled'); | |
$('#modal_submit_button').click(function(){ | |
if ($('#modal_form').valid()) { | |
if ($('#files-uploader').fineUploader("getInProgress") > 0) { | |
modal_flash_alert('alert', "Aguarde pelo final do carregamento dos ficheiros."); | |
return false; | |
}; | |
if ($('#modal_form').find('.attachment_in_form').length > 0) { | |
$(this).attr("disabled", true); | |
$(this).addClass('disabled'); | |
$(this).html('<span class="icon-spinner icon-spin "></span>'); | |
$('#close_modal').remove(); | |
$('#modal_form').submit(); | |
return true; | |
} else { | |
modal_flash_alert('alert', "Adicione os ficheiros prentendidos"); | |
return false; | |
} | |
} | |
}); | |
} | |
function set_close_footer(title, close_text) { | |
$('#modal .modal-header h3').html(title); | |
$('#modal .modal-footer').html('<button class="btn" data-dismiss="modal" aria-hidden="true">'+close_text+'</button>'); | |
} |
This file contains 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
# connexions | |
get 'office/connections' => 'doctor/connexions#index', as: :doctor_connexions | |
match 'office/connect_to' => 'doctor/connexions#new_connexion_request', as: :doctor_new_connexion_request, via: [:put, :post] | |
post 'office/create_connection_request' => 'doctor/connexions#create_connexion_request', as: :doctor_create_connexion_request | |
post 'office/accept_connection_request/:id' => 'doctor/connexions#accept_connexion_request', as: :doctor_accept_connexion_request | |
post 'office/reject_connection_request/:id' => 'doctor/connexions#reject_connexion_request', as: :doctor_reject_connexion_request | |
delete 'office/remove_connection/:id' => 'doctor/connexions#destroy_connexion', as: :doctor_delete_connexion | |
get 'office/request/:id' => 'doctor/connexions#view_request_form', as: :view_request_from_patient | |
post 'office/remind_connection_request/:id' => 'doctor/connexions#remind_connexion_request', as: :doctor_remind_connexion_request | |
post 'office/cancel_connection_request/:id' => 'doctor/connexions#cancel_connexion_request', as: :doctor_cancel_connexion_request | |
get "office/connections/patient/:connexion_id" => 'doctor/connexions#view_patient_profile', as: :view_patient_profile | |
# notes | |
get "office/notes/edit/:id" => 'doctor/doctor_notes#edit', as: :edit_doctor_note | |
match "office/notes/edit/:id" => 'doctor/doctor_notes#update', as: :update_doctor_note, via: [:put, :post] | |
delete "office/note/:id" => 'doctor/doctor_notes#destroy', as: :destroy_doctor_note |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment