Class: CollectionObjectObservationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CollectionObjectObservationsController
- Defined in:
- app/controllers/collection_object_observations_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#collection_object_observation_params ⇒ Object
private
Never trust parameters from the scary internet, only allow the white list through.
-
#create ⇒ Object
POST /collection_object_observations POST /collection_object_observations.json.
-
#destroy ⇒ Object
DELETE /collection_object_observations/1 DELETE /collection_object_observations/1.json.
-
#download ⇒ Object
GET /collection_object_observations/download.
-
#edit ⇒ Object
GET /collection_object_observations/1/edit.
-
#index ⇒ Object
GET /collection_object_observations GET /collection_object_observations.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /collection_object_observations/new.
- #search ⇒ Object
-
#set_collection_object_observation ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /collection_object_observations/1 GET /collection_object_observations/1.json.
-
#update ⇒ Object
PATCH/PUT /collection_object_observations/1 PATCH/PUT /collection_object_observations/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_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, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#autocomplete ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/collection_object_observations_controller.rb', line 76 def autocomplete @collection_object_observations = CollectionObjectObservation.find_for_autocomplete(params.merge(project_id: sessions_current_project_id)) data = @collection_object_observations.collect do |t| {id: t.id, label: t.data, response_values: { params[:method] => t.id }, label_html: t.data } end render json: data end |
#collection_object_observation_params ⇒ Object (private)
Never trust parameters from the scary internet, only allow the white list through.
114 115 116 |
# File 'app/controllers/collection_object_observations_controller.rb', line 114 def collection_object_observation_params params.require(:collection_object_observation).permit(:data) end |
#create ⇒ Object
POST /collection_object_observations POST /collection_object_observations.json
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/collection_object_observations_controller.rb', line 30 def create @collection_object_observation = CollectionObjectObservation.new(collection_object_observation_params) respond_to do |format| if @collection_object_observation.save format.html { redirect_to @collection_object_observation, notice: 'Collection object observation was successfully created.' } format.json { render :show, status: :created, location: @collection_object_observation } else format.html { render :new } format.json { render json: @collection_object_observation.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /collection_object_observations/1 DELETE /collection_object_observations/1.json
62 63 64 65 66 67 68 69 |
# File 'app/controllers/collection_object_observations_controller.rb', line 62 def destroy @collection_object_observation.destroy! respond_to do |format| format.html { redirect_to collection_object_observations_url, notice: 'Collection object observation was successfully destroyed.' } format.json { head :no_content } end end |
#download ⇒ Object
GET /collection_object_observations/download
101 102 103 104 105 |
# File 'app/controllers/collection_object_observations_controller.rb', line 101 def download send_data(Export::CSV.generate_csv(CollectionObjectObservation.where(project_id: sessions_current_project_id)), type: 'text', filename: "collection_object_observations_#{DateTime.now}.tsv") end |
#edit ⇒ Object
GET /collection_object_observations/1/edit
25 26 |
# File 'app/controllers/collection_object_observations_controller.rb', line 25 def edit end |
#index ⇒ Object
GET /collection_object_observations GET /collection_object_observations.json
8 9 10 11 12 |
# File 'app/controllers/collection_object_observations_controller.rb', line 8 def index @recent_objects = CollectionObjectObservation.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
71 72 73 74 |
# File 'app/controllers/collection_object_observations_controller.rb', line 71 def list @collection_object_observations = CollectionObjectObservation.with_project_id(sessions_current_project_id) .order(:id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /collection_object_observations/new
20 21 22 |
# File 'app/controllers/collection_object_observations_controller.rb', line 20 def new @collection_object_observation = CollectionObjectObservation.new end |
#search ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'app/controllers/collection_object_observations_controller.rb', line 91 def search if params[:id].blank? redirect_to collection_object_observations_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to collection_object_observation_path(params[:id]) end end |
#set_collection_object_observation ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
109 110 111 |
# File 'app/controllers/collection_object_observations_controller.rb', line 109 def set_collection_object_observation @collection_object_observation = CollectionObjectObservation.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /collection_object_observations/1 GET /collection_object_observations/1.json
16 17 |
# File 'app/controllers/collection_object_observations_controller.rb', line 16 def show end |
#update ⇒ Object
PATCH/PUT /collection_object_observations/1 PATCH/PUT /collection_object_observations/1.json
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/collection_object_observations_controller.rb', line 47 def update respond_to do |format| if @collection_object_observation.update(collection_object_observation_params) format.html { redirect_to @collection_object_observation, notice: 'Collection object observation was successfully updated.' } format.json { render :show, status: :ok, location: @collection_object_observation } else format.html { render :edit } format.json { render json: @collection_object_observation.errors, status: :unprocessable_entity } end end end |