Class: ProtocolsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ProtocolsController
- Defined in:
- app/controllers/protocols_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#create ⇒ Object
POST /protocols POST /protocols.json.
-
#destroy ⇒ Object
DELETE /protocols/1 DELETE /protocols/1.json.
-
#edit ⇒ Object
GET /protocols/1/edit.
-
#index ⇒ Object
GET /protocols GET /protocols.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /protocols/new.
- #protocol_params ⇒ Object private
- #search ⇒ Object
- #select_options ⇒ Object
- #set_protocol ⇒ Object private
-
#show ⇒ Object
GET /protocols/1 GET /protocols/1.json.
-
#update ⇒ Object
PATCH/PUT /protocols/1 PATCH/PUT /protocols/1.jsoned by Vsauce.
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
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/protocols_controller.rb', line 86 def autocomplete @protocols = Protocol.where(project_id: sessions_current_project_id).where('name ILIKE ?', "#{params[:term]}%").order(:name) data = @protocols.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 |
#create ⇒ Object
POST /protocols POST /protocols.json
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/protocols_controller.rb', line 40 def create @protocol = Protocol.new(protocol_params) respond_to do |format| if @protocol.save format.html { redirect_to @protocol, notice: 'Protocol was successfully created.' } format.json { render :show, status: :created, location: @protocol } else format.html { render :new } format.json { render json: @protocol.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /protocols/1 DELETE /protocols/1.json
70 71 72 73 74 75 76 |
# File 'app/controllers/protocols_controller.rb', line 70 def destroy @protocol.destroy respond_to do |format| format.html { redirect_to protocols_url, notice: 'Protocol was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /protocols/1/edit
31 32 |
# File 'app/controllers/protocols_controller.rb', line 31 def edit end |
#index ⇒ Object
GET /protocols GET /protocols.json
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/protocols_controller.rb', line 8 def index @recent_objects = Protocol.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) respond_to do |format| format.html { render '/shared/data/all/index' } format.json { @protocols = Protocol.where(project_id: sessions_current_project_id).order(:name).all } end end |
#list ⇒ Object
34 35 36 |
# File 'app/controllers/protocols_controller.rb', line 34 def list @protocols = Protocol.with_project_id(sessions_current_project_id).page(params[:page]) end |
#new ⇒ Object
GET /protocols/new
26 27 28 |
# File 'app/controllers/protocols_controller.rb', line 26 def new @protocol = Protocol.new end |
#protocol_params ⇒ Object (private)
114 115 116 |
# File 'app/controllers/protocols_controller.rb', line 114 def protocol_params params.require(:protocol).permit(:name, :short_name, :description) end |
#search ⇒ Object
78 79 80 81 82 83 84 |
# File 'app/controllers/protocols_controller.rb', line 78 def search if params[:id].blank? redirect_to protocols_path, notice: 'You must select an item from the list with a click or tab press before clicking show' else redirect_to protocol_path(params[:id]) end end |
#select_options ⇒ Object
104 105 106 |
# File 'app/controllers/protocols_controller.rb', line 104 def @protocols = Protocol.select_optimized(sessions_current_user_id, sessions_current_project_id, params.require(:klass)) end |
#set_protocol ⇒ Object (private)
110 111 112 |
# File 'app/controllers/protocols_controller.rb', line 110 def set_protocol @protocol = Protocol.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /protocols/1 GET /protocols/1.json
22 23 |
# File 'app/controllers/protocols_controller.rb', line 22 def show end |
#update ⇒ Object
PATCH/PUT /protocols/1 PATCH/PUT /protocols/1.jsoned by Vsauce
56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/protocols_controller.rb', line 56 def update respond_to do |format| if @protocol.update(protocol_params) format.html { redirect_to @protocol, notice: 'Protocol was successfully updated.' } format.json { render :show, status: :ok, location: @protocol } else format.html { render :edit } format.json { render json: @protocol.errors, status: :unprocessable_entity } end end end |