Class: ContainersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ContainersController
- Defined in:
- app/controllers/containers_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
- #container_params ⇒ Object private
- #container_types ⇒ Object
-
#create ⇒ Object
POST /containers POST /containers.json.
-
#destroy ⇒ Object
DELETE /containers/1 DELETE /containers/1.json.
-
#edit ⇒ Object
GET /containers/1/edit.
-
#for ⇒ Object
GET /containers/for/global_id.
-
#index ⇒ Object
GET /containers GET /containers.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /containers/new.
- #search ⇒ Object
- #set_container ⇒ Object private
-
#show ⇒ Object
GET /containers/1 GET /containers/1.json.
-
#update ⇒ Object
PATCH/PUT /containers/1 PATCH/PUT /containers/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
103 104 105 106 107 108 |
# File 'app/controllers/containers_controller.rb', line 103 def autocomplete @containers = Queries::Container::Autocomplete.new( params.require(:term), project_id: sessions_current_project_id ).autocomplete end |
#container_params ⇒ Object (private)
119 120 121 |
# File 'app/controllers/containers_controller.rb', line 119 def container_params params.require(:container).permit(:parent_id, :type, :name, :disposition, :size_x, :size_y, :size_z, :empty_container) end |
#container_types ⇒ Object
110 111 112 |
# File 'app/controllers/containers_controller.rb', line 110 def container_types render json: helpers.container_types end |
#create ⇒ Object
POST /containers POST /containers.json
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/containers_controller.rb', line 53 def create @container = Container.new(container_params) respond_to do |format| if @container.save format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container was successfully created.')} format.json { render :show, status: :created, location: @container. } else format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container was NOT successfully created.')} format.json { render json: @container.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /containers/1 DELETE /containers/1.json
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/containers_controller.rb', line 82 def destroy @container.destroy respond_to do |format| if @container.destroyed? format.html { destroy_redirect @container, notice: 'Container was successfully destroyed.' } format.json { head :no_content } else format.html { destroy_redirect @container, notice: 'Container was not destroyed, ' + @container.errors..join('; ') } format.json { render json: @container.errors, status: :unprocessable_entity } end end end |
#edit ⇒ Object
GET /containers/1/edit
44 45 |
# File 'app/controllers/containers_controller.rb', line 44 def edit end |
#for ⇒ Object
GET /containers/for/global_id
30 31 32 33 34 35 36 |
# File 'app/controllers/containers_controller.rb', line 30 def for object = GlobalID::Locator.locate(params.require(:global_id)) @container = object.respond_to?(:containable?) ? object.container : nil render(json: { 'message' => 'Record not found' }, status: :unauthorized) if !object.is_community? && object.project_id != sessions_current_project_id render(json: { success: false}, status: :not_found) and return if @container.nil? render :show end |
#index ⇒ Object
GET /containers GET /containers.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/containers_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = Container.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @containers = ::Queries::Container::Filter.new(params) .all .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
47 48 49 |
# File 'app/controllers/containers_controller.rb', line 47 def list @containers = Container.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /containers/new
39 40 41 |
# File 'app/controllers/containers_controller.rb', line 39 def new @container = Container.new end |
#search ⇒ Object
95 96 97 98 99 100 101 |
# File 'app/controllers/containers_controller.rb', line 95 def search if params[:id].blank? redirect_to containers_path, alert: '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 |
#set_container ⇒ Object (private)
115 116 117 |
# File 'app/controllers/containers_controller.rb', line 115 def set_container @container = Container.with_project_id(sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /containers/1 GET /containers/1.json
26 27 |
# File 'app/controllers/containers_controller.rb', line 26 def show end |
#update ⇒ Object
PATCH/PUT /containers/1 PATCH/PUT /containers/1.json
68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/containers_controller.rb', line 68 def update respond_to do |format| if @container.update(container_params) format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container was successfully updated.')} format.json { render :show, status: :ok, location: @container. } else format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container was NOT successfully updated.')} format.json { render json: @container.errors, status: :unprocessable_entity } end end end |