Class: ObservationMatricesController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/observation_matrices_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

#polymorphic_filter_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

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) autocomplete



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/observation_matrices_controller.rb', line 71

def autocomplete
  @observation_matrices = ObservationMatrix.where(project_id: sessions_current_project_id).where('name like ?', "#{params[:term]}%")
  data                  = @observation_matrices.collect do |t|
    {id:              t.id,
     label:           t.name, 
     gid: t.to_global_id.to_s,
     response_values: {
       params[:method] => t.id
     },
     label_html:      t.name 
    }
  end
  render :json => data
end

- (Object) create

POST /observation_matrices POST /observation_matrices.json



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/observation_matrices_controller.rb', line 33

def create
  @observation_matrix = ObservationMatrix.new(observation_matrix_params)

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

- (Object) destroy

DELETE /observation_matrices/1 DELETE /observation_matrices/1.json



63
64
65
66
67
68
69
# File 'app/controllers/observation_matrices_controller.rb', line 63

def destroy
  @observation_matrix.destroy
  respond_to do |format|
    format.html { redirect_to observation_matrices_url, notice: 'Matrix was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /observation_matrices/1/edit



28
29
# File 'app/controllers/observation_matrices_controller.rb', line 28

def edit
end

- (Object) index

GET /observation_matrices GET /observation_matrices.json



8
9
10
11
# File 'app/controllers/observation_matrices_controller.rb', line 8

def index
  @recent_objects = ObservationMatrix.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



18
19
20
# File 'app/controllers/observation_matrices_controller.rb', line 18

def list
  @observation_matrices = ObservationMatrix.with_project_id(sessions_current_project_id).page(params[:page])
end

- (Object) new

GET /observation_matrices/new



23
24
25
# File 'app/controllers/observation_matrices_controller.rb', line 23

def new
  @observation_matrix = ObservationMatrix.new
end

- (Object) observation_matrix_params (private)



106
107
108
# File 'app/controllers/observation_matrices_controller.rb', line 106

def observation_matrix_params
  params.require(:observation_matrix).permit(:name)
end

- (Object) row

GET /observation_matrices/:id/row.json?otu_id=1



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

def row
  @descriptors = @observation_matrix.descriptors
  @otu = Otu.find(params[:otu_id])
end

- (Object) search



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

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

- (Object) set_matrix (private)



102
103
104
# File 'app/controllers/observation_matrices_controller.rb', line 102

def set_matrix
  @observation_matrix = ObservationMatrix.find(params[:id])
end

- (Object) show

GET /observation_matrices/1 GET /observation_matrices/1.json



15
16
# File 'app/controllers/observation_matrices_controller.rb', line 15

def show
end

- (Object) update

PATCH/PUT /observation_matrices/1 PATCH/PUT /observation_matrices/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/observation_matrices_controller.rb', line 49

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