Sha256: 7b85f54e5f79afb1a3b91c4881ad5a9a7ee92f6a2fe5e095af671c84b1a909a1

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

require_dependency "renalware/hd/base_controller"

module Renalware
  module HD
    class PreferenceSetsController < BaseController
      before_action :load_patient

      def edit
        preference_set = PreferenceSet.for_patient(patient).first_or_initialize
        render locals: { patient: patient, preference_set: preference_set }
      end

      def update
        preference_set = PreferenceSet.for_patient(patient).first_or_initialize

        if preference_set.update_attributes(preference_set_params)
          redirect_to patient_hd_dashboard_path(patient),
            notice: t(".success", model_name: "HD preferences")
        else
          flash.now[:error] = t(".failed", model_name: "HD preferences")
          render :edit, locals: { patient: patient, preference_set: preference_set }
        end
      end

      private

      def attributes
        [
          :schedule_definition_id, :other_schedule,
          :hospital_unit_id, :entered_on, :notes
        ]
      end

      def preference_set_params
        params
          .require(:hd_preference_set)
          .permit(attributes)
          .merge(by: current_user)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
renalware-core-2.0.5 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.4 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.3 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.2 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.1 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc7 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc6 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc5 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc4 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc3 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.rc1 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.beta12 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.beta11 app/controllers/renalware/hd/preference_sets_controller.rb
renalware-core-2.0.0.pre.beta10 app/controllers/renalware/hd/preference_sets_controller.rb