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

- (Object) collection_object_params (protected)



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 39

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

- (Object) index

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



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

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

- (Object) set_collection_object (protected)



51
52
53
54
55
56
57
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 51

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

- (Object) set_sqed_depiction (protected)



59
60
61
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 59

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

- (Object) thumb_navigator



15
16
17
# File 'app/controllers/tasks/accessions/breakdown/buffered_data_controller.rb', line 15

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

- (Object) update



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

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