Skip to content

Commit

Permalink
Merge branch '2023061605-fixed-api-for-mobile' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
kirykr committed Aug 18, 2023
2 parents 95b999d + 7d1d26d commit bb15e06
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/api/v1/case_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class CaseNotesController < Api::V1::BaseApiController

before_action :find_client

def show
case_note = CaseNote.find(params[:id])
render json: case_note
end

def create
case_note = @client.case_notes.new(case_note_params)
case_note.assessment = @client.assessments.custom_latest_record
Expand Down
11 changes: 10 additions & 1 deletion app/serializers/case_note_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
class CaseNoteSerializer < ActiveModel::Serializer
attributes :id, :attendee, :meeting_date, :interaction_type, :note, :client_id, :assessment_id, :case_note_domain_groups, :selected_domain_group_ids, :attachments, :draft, :created_at, :updated_at
attributes :id, :attendee, :meeting_date, :interaction_type, :note, :client_id, :assessment_id, :case_note_domain_groups,
:selected_domain_group_ids, :attachments, :draft, :tasks, :created_at, :updated_at


private

def case_note_domain_groups
ActiveModel::ArraySerializer.new(object.case_note_domain_groups, each_serializer: CaseNoteDomainGroupSerializer)
end

def tasks
tasks = Task.completed.where(case_note_id: object.id)
[*object.tasks, *tasks]
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
resources :clients, except: [:edit, :new] do
get :listing, on: :collection
resources :assessments, only: [:create, :update, :destroy, :delete]
resources :case_notes, only: [:create, :update, :destroy, :delete_attachment] do
resources :case_notes, only: [:show, :create, :update, :destroy, :delete_attachment] do
delete 'attachments/:file_index', action: :delete_attachment, on: :member
end
resources :custom_field_properties, only: [:create, :update, :destroy]
Expand Down

0 comments on commit bb15e06

Please sign in to comment.