Class: ProtocolRelationshipsController

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

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

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

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#createObject

POST /protocol_relationships POST /protocol_relationships.json



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

def create
  @protocol_relationship = ProtocolRelationship.new(protocol_relationship_params)

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

#destroyObject

DELETE /protocol_relationships/1 DELETE /protocol_relationships/1.json



77
78
79
80
81
82
83
# File 'app/controllers/protocol_relationships_controller.rb', line 77

def destroy
  @protocol_relationship.destroy
  respond_to do |format|
    format.html { redirect_to protocol_relationships_url, notice: 'Protocol relationship was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /protocol_relationships/1/edit



38
39
# File 'app/controllers/protocol_relationships_controller.rb', line 38

def edit
end

#indexObject

GET /protocol_relationships GET /protocol_relationships.json



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

def index
  respond_to do |format|
    format.html {
      @recent_objects = ProtocolRelationship.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    }
    format.json {
      @protocol_relationships = ::Queries::ProtocolRelationship::Filter.new(params).all.where(project_id: sessions_current_project_id).
      page(params[:page]).per(params[:per] || 500)
    }
  end
end

#listObject



41
42
43
# File 'app/controllers/protocol_relationships_controller.rb', line 41

def list
  @protocol_relationships = ProtocolRelationship.with_project_id(sessions_current_project_id).page(params[:page])
end

#newObject

GET /protocol_relationships/new



27
28
29
30
31
32
33
34
35
# File 'app/controllers/protocol_relationships_controller.rb', line 27

def new
  @protocol_relationship = ProtocolRelationship.new

  if !Protocol.with_project_id(sessions_current_project_id).any?
    redirect_to new_protocol_path, notice: 'Create a protocol or two first.' and return
  end
  @protocol_relationship= ProtocolRelationship.new(protocol_relationship_params)

end

#protocol_relationship_paramsObject (private)



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

def protocol_relationship_params
  params.require(:protocol_relationship).permit(:protocol_id, :protocol_relationship_object_id, :protocol_relationship_object_type, :annotated_global_entity)
end

#searchObject



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

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

#set_protocol_relationshipObject (private)



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

def set_protocol_relationship
  @protocol_relationship = ProtocolRelationship.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /protocol_relationships/1 GET /protocol_relationships/1.json



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

def show
end

#updateObject

PATCH/PUT /protocol_relationships/1 PATCH/PUT /protocol_relationships/1.json



63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/protocol_relationships_controller.rb', line 63

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