Class: Tasks::Accessions::Breakdown::SqedDepictionController

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

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) collection_object_params (protected)



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

def collection_object_params
  params.require(:collection_object).permit(
    :buffered_collecting_event, :buffered_other_labels, :buffered_determinations, :total,
    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/depiction/:id



8
9
10
11
12
13
14
15
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 8

def index
  @result = SqedToTaxonworks::Result.new(
    depiction_id: @sqed_depiction.depiction.id,
    namespace_id: params[:namespace_id]
  )

  @identifier_prototype = Identifier.prototype_identifier(sessions_current_project_id, sessions_current_user_id)
end

- (Object) set_sqed_depiction (protected)



47
48
49
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 47

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

- (Object) todo_map



30
31
32
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 30

def todo_map
  @sqed_depictions = SqedDepiction.with_project_id(sessions_current_project_id).order(:id).page(params[:page]).per(100)
end

- (Object) update



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 17

def update
  if @sqed_depiction.depiction.depiction_object.update(collection_object_params)
    flash[:notice] = 'Successfully updated'
  else
    flash[:alert] = 'Failed to update! ' + @sqed_depiction.depiction.depiction_object.errors.full_messages.join("; ").html_safe
  end

  next_sqed_depiction = (params[:commit] == 'Save and next [n]' ? @sqed_depiction.next_without_data : @sqed_depiction )
  namespace_id = (params[:lock_namespace] ? params[:collection_object][:identifiers_attributes]["0"][:namespace_id] : nil)

  redirect_to sqed_depiction_breakdown_task_path(next_sqed_depiction, namespace_id)
end