Class: ObservationMatrixColumnItemsController

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

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate, #whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) batch_create

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



85
86
87
88
89
90
91
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 85

def batch_create
  if @loan_items = ObservationMatrixColumnItem.batch_create(batch_params)
    render :index
  else
    render json: {success: false}
  end 
end

- (Object) batch_params (private)



95
96
97
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 95

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

- (Object) create

POST /observation_matrix_column_items POST /observation_matrix_column_items.json



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 41

def create
  @observation_matrix_column_item = ObservationMatrixColumnItem.new(observation_matrix_column_item_params)

  respond_to do |format|
    if @observation_matrix_column_item.save
      format.html { redirect_to url_for(@observation_matrix_column_item.metamorphosize),
                    notice: 'Matrix column item was successfully created.' }
      format.json { render :show, status: :created, location: @observation_matrix_column_item.metamorphosize }
    else
      format.html { render :new }
      format.json { render json: @observation_matrix_column_item.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /observation_matrix_column_items/1 DELETE /observation_matrix_column_items/1.json



73
74
75
76
77
78
79
80
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 73

def destroy
  @observation_matrix_column_item.destroy!
  respond_to do |format|
    format.html { redirect_to observation_matrix_column_items_url,
                  notice: 'Matrix column item was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /observation_matrix_column_items/1/edit



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

def edit
end

- (Object) filter_params (private)



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

def filter_params
  params.permit(:observation_matrix_id, :descriptor_id, :type)
end

- (Object) index

GET /observation_matrix_column_items GET /observation_matrix_column_items.json



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 7

def index
  respond_to do |format|
    format.html do
      @recent_objects = ObservationMatrixColumnItem.recent_from_project_id(sessions_current_project_id)
        .order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      @observation_matrix_column_items = ObservationMatrixColumnItem.where(filter_params).with_project_id(sessions_current_project_id)
    }
  end
end

- (Object) list



25
26
27
28
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 25

def list
  @observation_matrix_column_items = ObservationMatrixColumnItem.with_project_id(sessions_current_project_id)
    .page(params[:page])
end

- (Object) new

GET /observation_matrix_column_items/new



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

def new
  @observation_matrix_column_item = ObservationMatrixColumnItem.new
end

- (Object) observation_matrix_column_item_params (private)



107
108
109
110
111
112
113
114
115
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 107

def observation_matrix_column_item_params
  params.require(:observation_matrix_column_item).permit(
    :controlled_vocabulary_term_id,
    :observation_matrix_id,
    :type,
    :descriptor_id,
    :keyword_id, 
    :position)
end

- (Object) set_observation_matrix_column_item (private)



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

def set_observation_matrix_column_item
  @observation_matrix_column_item = ObservationMatrixColumnItem.find(params[:id])
end

- (Object) show

GET /observation_matrix_column_items/1 GET /observation_matrix_column_items/1.json



22
23
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 22

def show
end

- (Object) update

PATCH/PUT /observation_matrix_column_items/1 PATCH/PUT /observation_matrix_column_items/1.json



58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/observation_matrix_column_items_controller.rb', line 58

def update
  respond_to do |format|
    if @observation_matrix_column_item.update(observation_matrix_column_item_params)
      format.html { redirect_to url_for(@observation_matrix_column_item.metamorphosize),
                    notice: 'Matrix column item was successfully updated.' }
      format.json { render :show, status: :ok, location: @observation_matrix_column_item }
    else
      format.html { render :edit }
      format.json { render json: @observation_matrix_column_item.errors, status: :unprocessable_entity }
    end
  end
end