Class: Tasks::Accessions::Breakdown::BufferedDataController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#collection_object_paramsObject (protected)



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 36

def collection_object_params
  params.require(:collection_object).permit(
    :buffered_collecting_event, # :buffered_other_labels, :buffered_determinations, :total,
    collecting_event_attributes: [:id, :verbatim_locality, :geographic_area_id,
                                  identifiers_attributes:
                                  [:id, :namespace_id, :identifier, :type, :_destroy]],
  # tags_attributes: [:id, :keyword_id, :_destroy],
    # taxon_determinations_attributes: [:id, :otu_id, :_destroy],
    # notes_attributes: [:id, :text, :_destroy]
  )
end

#indexObject

GET /tasks/accession/breakdown/buffered_data/:id



7
8
9
10
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 7

def index
  @collection_object.collecting_event = CollectingEvent.new if @collection_object.collecting_event.nil?
  @collection_object.collecting_event.identifiers.build(type: 'Identifier::Local::AccessionCode')
end

#set_collection_objectObject (protected)



48
49
50
51
52
53
54
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 48

def set_collection_object
  # collection object that has SqedDepiction
  @collection_object = CollectionObject.where(project_id: sessions_current_project_id).find(params[:id])
  @result = Vendor::SqedToTaxonworks::Result.new(
    depiction_id: @collection_object.depictions.first.id,
  )
end

#set_sqed_depictionObject (protected)



56
57
58
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 56

def set_sqed_depiction
  @sqed_depiction = SqedDepiction.where(project_id: sessions_current_project_id).find(params[:id])
end

#thumb_navigatorObject



12
13
14
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 12

def thumb_navigator
  render partial: '/tasks/accessions/breakdown/buffered_data/thumb_navigator', locals: { sqed_depiction: SqedDepiction.find(params[:id])  }
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 16

def update
  @collection_object.update(collection_object_params)
  @collection_object.valid?
  flash[:notice] = 'Collection object was' + (@collection_object.valid? ? '' : ' NOT') + ' successfully updated.' + (@collection_object.valid? ? '' : @collection_object.errors.full_messages.join('; '))

  respond_to do |format|
    if params[:commit] == 'Save changes'
      format.html { redirect_to collection_object_buffered_data_breakdown_task_path(@collection_object) }
    elsif params[:commit] == 'Save and next'
      if @collection_object.valid?
        format.html { redirect_to collection_object_buffered_data_breakdown_task_path(@result.sqed_depiction.next_collection_object)  }
      else
        format.html { redirect_to collection_object_buffered_data_breakdown_task_path(@collection_object) }
      end
    end
  end
end