Class: BiologicalAssociationsGraphsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/biological_associations_graphs_controller.rb

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#cumulative_gb_per_year, #cumulative_projects_created_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #sound_cumulative_gb_per_year, #sound_gb_per_year, #taxonworks_classification, #week_in_review_graphs

Methods included from Api::Intercept

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#api_indexObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'app/controllers/biological_associations_graphs_controller.rb', line 111

def api_index
  q = ::Queries::BiologicalAssociationsGraph::Filter.new(params.merge!(api: true)).all
    .where(project_id: sessions_current_project_id)
    .order('biological_associations_graphs.id')

  respond_to do |format|
    format.json {
      @biological_associations_graphs = q.page(params[:page]).per(params[:per])
      render '/biological_associations_graphs/api/v1/index'
    }

    # format.csv {
    #   @biological_associations = q
    #   send_data Export::CSV.generate_csv(
    #     @biological_associations,
    #     exclude_columns: %w{updated_by_id created_by_id project_id},
    #   ), type: 'text',
    #  filename: "biological_associations_#{DateTime.now}.tsv"
    # }

    # format.globi {
    #   if q.page(params[:page]).per(params[:per]).count < 1001
    #     send_data Export::CSV::Globi.csv(q.page(params[:page]).per(params[:per])),
    #       type: 'text',
    #       filename: "biological_associations_globi_#{DateTime.now}.tsv"
    #   else
    #     render json: { msg: 'At present this format is only allowed for 1000 or less records.' }, status: :unprocessable_entity
    #   end
    # }
  end
end

#api_showObject



107
108
109
# File 'app/controllers/biological_associations_graphs_controller.rb', line 107

def api_show
  render '/biological_associations_graphs/api/v1/show'
end

#autocompleteObject



84
85
86
87
88
89
# File 'app/controllers/biological_associations_graphs_controller.rb', line 84

def autocomplete
  @biological_associations_graphs = Queries::BiologicalAssociationsGraph::Autocomplete.new(
    params.require(:term),
    project_id: sessions_current_project_id
  ).autocomplete
end

#biological_associations_graph_paramsObject (private)



149
150
151
152
153
154
155
156
# File 'app/controllers/biological_associations_graphs_controller.rb', line 149

def biological_associations_graph_params
  params.require(:biological_associations_graph).permit(
    :name,
    :layout,
    origin_citation_attributes: [:id, :_destroy, :source_id, :pages] ,
    biological_associations_biological_associations_graphs_attributes: [:id, :_destroy, :biological_association_id]
  )
end

#createObject

POST /biological_associations_graphs POST /biological_associations_graphs.json



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/biological_associations_graphs_controller.rb', line 46

def create
  @biological_associations_graph = BiologicalAssociationsGraph.new(biological_associations_graph_params)

  respond_to do |format|
    if @biological_associations_graph.save
      format.html { redirect_to @biological_associations_graph, notice: 'Biological associations graph was successfully created.' }
      format.json { render :show, status: :created, location: @biological_associations_graph }
    else
      format.html { render :new }
      format.json { render json: @biological_associations_graph.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /biological_associations_graphs/1 DELETE /biological_associations_graphs/1.json



76
77
78
79
80
81
82
# File 'app/controllers/biological_associations_graphs_controller.rb', line 76

def destroy
  @biological_associations_graph.destroy
  respond_to do |format|
    format.html { redirect_to biological_associations_graphs_url, notice: 'Biological associations graph was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /biological_associations_graphs/1/edit



36
37
38
# File 'app/controllers/biological_associations_graphs_controller.rb', line 36

def edit
#    @biological_associations_graph.souce = Source.new if !@taxon_name.source
end

#indexObject

GET /biological_associations_graphs GET /biological_associations_graphs.json



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/biological_associations_graphs_controller.rb', line 11

def index
  respond_to do |format|
    format.html do
      @recent_objects = BiologicalAssociationsGraph.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      @biological_associations_graphs = ::Queries::BiologicalAssociationsGraph::Filter.new(params).all
        .page(params[:page])
        .per(params[:per])
    }
  end
end

#listObject



40
41
42
# File 'app/controllers/biological_associations_graphs_controller.rb', line 40

def list
  @biological_associations_graphs = BiologicalAssociationsGraph.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10)
end


100
101
# File 'app/controllers/biological_associations_graphs_controller.rb', line 100

def navigation
end

#newObject

GET /biological_associations_graphs/new



31
32
33
# File 'app/controllers/biological_associations_graphs_controller.rb', line 31

def new
  @biological_associations_graph = BiologicalAssociationsGraph.new(origin_citation: Citation.new)
end

#searchObject

TODO: remove!



92
93
94
95
96
97
98
# File 'app/controllers/biological_associations_graphs_controller.rb', line 92

def search
  if params[:id].blank?
    redirect_to biological_associations_graphs_path, alert: 'You must select an item from the list with a click or tab press before clicking show.'
  else
    redirect_to biological_associations_graph_path(params[:id])
  end
end

#select_optionsObject



103
104
105
# File 'app/controllers/biological_associations_graphs_controller.rb', line 103

def select_options
  @biological_associations_graphs = BiologicalAssociationsGraph.select_optimized(sessions_current_user_id, sessions_current_project_id, params.require(:target))
end

#set_biological_associations_graphObject (private)



145
146
147
# File 'app/controllers/biological_associations_graphs_controller.rb', line 145

def set_biological_associations_graph
  @biological_associations_graph = BiologicalAssociationsGraph.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /biological_associations_graphs/1 GET /biological_associations_graphs/1.json



27
28
# File 'app/controllers/biological_associations_graphs_controller.rb', line 27

def show
end

#updateObject

PATCH/PUT /biological_associations_graphs/1 PATCH/PUT /biological_associations_graphs/1.json



62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/biological_associations_graphs_controller.rb', line 62

def update
  respond_to do |format|
    if @biological_associations_graph.update(biological_associations_graph_params)
      format.html { redirect_to @biological_associations_graph, notice: 'Biological associations graph was successfully updated.' }
      format.json { render :show, status: :ok, location: @biological_associations_graph }
    else
      format.html { render :edit }
      format.json { render json: @biological_associations_graph.errors, status: :unprocessable_entity }
    end
  end
end