Sha256: 265268fd06dc1f4fdb519fb8b567a5aa71112efd50e6f1a24297ff3282aa3e0a

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"

module Renalware
  module HD
    class MDMPatientsController < Renalware::MDMPatientsController
      def index
        filter_form = form_object_class.new(filter_form_params)

        query = HD::MDMPatientsQuery.new(
          params: filter_form.ransacked_parameters.merge(query_params).with_indifferent_access
        )

        render_index(filter_form: filter_form,
                     query: query,
                     page_title: t(".page_title"),
                     view_proc: ->(patient) { patient_hd_mdm_path(patient) },
                     patient_presenter_class: HD::PatientPresenter)
      end

      private

      # Permit all attributes on the filter form object. Slightly messy
      def filter_form_params
        params.fetch(:filter, {}).permit(form_object_class.permittable_attributes)
      end

      def form_object_class
        Renalware::HD::MDMPatientsForm
      end

      # Ransack params use for column sorting
      def query_params
        params.fetch(:q, {}).permit(:s)
      end

      def render_index(filter_form:, **args)
        presenter = build_presenter(params: params, **args)
        authorize presenter.patients
        render(
          :index,
          locals: { presenter: presenter, filter_form: filter_form }
        )
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
renalware-core-2.0.67 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.64 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.63 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.62 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.61 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.60 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.58 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.57 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.56 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.55 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.54 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.53 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.52 app/controllers/renalware/hd/mdm_patients_controller.rb