Class: ContainersController

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/containers_controller.rb', line 79

def autocomplete
  @containers = Container.find_for_autocomplete(params.merge(project_id: sessions_current_project_id))

  data = @containers.collect do |t|
    {id: t.id,
     label: t.id, #  ApplicationController.helpers.container_tag(t),
     gid: t.to_global_id.to_s,
     response_values: {
         params[:method] => t.id
     },
     label_html: t.id #  ApplicationController.helpers.container_tag(t)  
    }
  end
  render :json => data
end

- (Object) container_params (private)

Never trust parameters from the scary internet, only allow the white list through.



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

def container_params
  params.require(:container).permit(:parent_id, :type, :name, :disposition, :size_x, :size_y, :size_z)
end

- (Object) create

POST /containers POST /containers.json



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

def create
  @container = Container.new(container_params)

  respond_to do |format|
    if @container.save
      format.html { redirect_to :back, notice: 'Container was successfully created.' }
      format.json { render json: @container, status: :created, location: @container }
    else
      format.html { redirect_to :back, notice: 'Container was NOT successfully created.' }
      format.json { render json: @container.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /containers/1 DELETE /containers/1.json



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

def destroy
  @container.destroy
  respond_to do |format|
    format.html { redirect_to :back, notice: 'Container was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /containers/1/edit



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

def edit
end

- (Object) index

GET /containers GET /containers.json



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

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

- (Object) list



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

def list
  @containers = Container.with_project_id($project_id).order(:id).page(params[:page]) #.per(10)
end

- (Object) new

GET /containers/new



19
20
21
# File 'app/controllers/containers_controller.rb', line 19

def new
  @container = Container.new
end

- (Object) search



71
72
73
74
75
76
77
# File 'app/controllers/containers_controller.rb', line 71

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

- (Object) set_container (private)

Use callbacks to share common setup or constraints between actions.



97
98
99
# File 'app/controllers/containers_controller.rb', line 97

def set_container
  @container = Container.with_project_id($project_id).find(params[:id])
end

- (Object) show

GET /containers/1 GET /containers/1.json



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

def show
end

- (Object) update

PATCH/PUT /containers/1 PATCH/PUT /containers/1.json



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

def update
  respond_to do |format|
    if @container.update(container_params)
      format.html { redirect_to :back, notice: 'Container was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { redirect_to :back, notice: 'Container was NOT successfully updated.' }
      format.json { render json: @container.errors, status: :unprocessable_entity }
    end
  end
end