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

#collection_object_paramsObject (protected)



59
60
61
62
63
64
65
66
67
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 59

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

#indexObject

GET /tasks/accession/breakdown/depiction/:id # id is a collection_object_id !!



24
25
26
27
28
29
30
31
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 24

def index
  @result = Vendor::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

#set_sqed_depictionObject (protected)



69
70
71
72
73
74
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 69

def set_sqed_depiction
  @sqed_depiction = SqedDepiction.where(project_id: sessions_current_project_id).find(params[:id])
  @sqed_depiction.update_column(:in_progress, Time.now)
  # TODO: Run jobs in background with admin task.
  # @sqed_depiction.preprocess
end

#todo_mapObject

/tasks/accessions/breakdown/sqed_depiction/todo_map



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 8

def todo_map
  SqedDepiction.clear_stale_progress

  @sqed_depictions = ::Queries::SqedDepiction::Filter.new(params).all
    .where(project_id: sessions_current_project_id)
    .order(:id)
    .page(params[:page])
    .per(params[:per])

  respond_to do |format|
    format.html {}
    format.json {}
  end
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 33

def update
  next_sqed_depiction = @sqed_depiction

  if @sqed_depiction.depiction.depiction_object.update(collection_object_params)
    flash[:notice] = 'Successfully updated'

    next_sqed_depiction =
      case params[:commit]
      when 'Save and next w/out data [n]'
        @sqed_depiction.next_without_data(true) # true handles stale settings
      when 'Save and next'
        @sqed_depiction.nearby_sqed_depictions(0, 1, true)[:after].first # true handles stale settings
      else
        @sqed_depiction
      end
  else
    flash[:alert] = 'Failed to update! ' + @sqed_depiction.depiction.depiction_object.errors.full_messages.join('; ').html_safe
  end

  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