Class: ObservationMatrixRowItemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ObservationMatrixRowItemsController
- Defined in:
- app/controllers/observation_matrix_row_items_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#batch_create ⇒ Object
POST /observation_matrix_row_items/batch_create?batch_type=tags&observation_matrix_id=123&keyword_id=456&klass=Otu POST /observation_matrix_row_items/batch_create?batch_type=pinboard&observation_matrix_id=123&klass=Otu.
- #batch_params ⇒ Object private
-
#create ⇒ Object
POST /observation_matrix_row_items.json.
-
#destroy ⇒ Object
DELETE /observation_matrix_row_items/1 DELETE /observation_matrix_row_items/1.json.
-
#edit ⇒ Object
GET /observation_matrix_row_items/1/edit.
- #filter_params ⇒ Object private
-
#index ⇒ Object
GET /observation_matrix_row_items GET /observation_matrix_row_items.json.
- #list ⇒ Object
- #observation_matrix_row_item_params ⇒ Object private
- #set_observation_matrix_row_item ⇒ Object private
-
#show ⇒ Object
GET /observation_matrix_row_items/1 GET /observation_matrix_row_items/1.json.
-
#update ⇒ Object
PATCH/PUT /observation_matrix_row_items/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
#batch_create ⇒ Object
POST /observation_matrix_row_items/batch_create?batch_type=tags&observation_matrix_id=123&keyword_id=456&klass=Otu POST /observation_matrix_row_items/batch_create?batch_type=pinboard&observation_matrix_id=123&klass=Otu
77 78 79 80 81 82 83 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 77 def batch_create if @loan_items = ObservationMatrixRowItem.batch_create(batch_params) render :index else render json: {success: false} end end |
#batch_params ⇒ Object (private)
87 88 89 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 87 def batch_params params.permit(:batch_type, :observation_matrix_id, :keyword_id, :klass).to_h.symbolize_keys.merge(project_id: sessions_current_project_id, user_id: sessions_current_user_id) end |
#create ⇒ Object
POST /observation_matrix_row_items.json
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 37 def create @observation_matrix_row_item = ObservationMatrixRowItem.new(observation_matrix_row_item_params) respond_to do |format| if @observation_matrix_row_item.save format.json { render :show, status: :created, location: @observation_matrix_row_item. } else format.json { render json: @observation_matrix_row_item.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /observation_matrix_row_items/1 DELETE /observation_matrix_row_items/1.json
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 61 def destroy @observation_matrix_row_item.destroy respond_to do |format| if @observation_matrix_row_item.destroyed? format.html { redirect_to observation_matrix_row_items_url, notice: 'Matrix row item was successfully destroyed.' } format.json { head :no_content } else format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Observation matrix row item was not destroyed, ' + @observation_matrix_row_item.errors..join('; '))} format.json {render json: @observation_matrix_row_item.errors, status: :unprocessable_entity} end end end |
#edit ⇒ Object
GET /observation_matrix_row_items/1/edit
32 33 34 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 32 def edit redirect_to new_matrix_task_path(@observation_matrix_row_item.observation_matrix) and return end |
#filter_params ⇒ Object (private)
91 92 93 94 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 91 def filter_params params.permit( :observation_matrix_id, :otu_id, :controlled_vocabulary_term_id, :collection_object_id, :type, :taxon_name_id, :observation_object_id, :observation_object_type) end |
#index ⇒ Object
GET /observation_matrix_row_items GET /observation_matrix_row_items.json
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 8 def index respond_to do |format| format.html do @recent_objects = ObservationMatrixRowItem.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @observation_matrix_row_items = ObservationMatrixRowItem.where(filter_params).with_project_id(sessions_current_project_id) } end end |
#list ⇒ Object
26 27 28 29 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 26 def list @observation_matrix_row_items = ObservationMatrixRowItem.with_project_id(sessions_current_project_id) .page(params[:page]) end |
#observation_matrix_row_item_params ⇒ Object (private)
100 101 102 103 104 105 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 100 def observation_matrix_row_item_params params.require(:observation_matrix_row_item).permit( :observation_matrix_id, :type, :observation_object_type, :observation_object_id, :type, :position) end |
#set_observation_matrix_row_item ⇒ Object (private)
96 97 98 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 96 def set_observation_matrix_row_item @observation_matrix_row_item = ObservationMatrixRowItem.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /observation_matrix_row_items/1 GET /observation_matrix_row_items/1.json
23 24 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 23 def show end |
#update ⇒ Object
PATCH/PUT /observation_matrix_row_items/1.json
49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 49 def update respond_to do |format| if @observation_matrix_row_item.update(observation_matrix_row_item_params) format.json { render :show, status: :ok, location: @observation_matrix_row_item. } else format.json { render json: @observation_matrix_row_item.errors, status: :unprocessable_entity } end end end |