Class: ProtocolRelationshipsController

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

POST /protocol_relationships POST /protocol_relationships.json



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/protocol_relationships_controller.rb', line 50

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

- (Object) destroy

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



80
81
82
83
84
85
86
# File 'app/controllers/protocol_relationships_controller.rb', line 80

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

- (Object) edit

GET /protocol_relationships/1/edit



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

def edit
end

- (Object) index

GET /protocol_relationships GET /protocol_relationships.json



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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 = ProtocolRelationship.where(project_id: sessions_current_project_id).where(
        polymorphic_filter_params(
          'protocol_relationship_object', ProtocolRelationship.related_foreign_keys  )
      )
    }
  end
end

- (Object) list



44
45
46
# File 'app/controllers/protocol_relationships_controller.rb', line 44

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

- (Object) new

GET /protocol_relationships/new



30
31
32
33
34
35
36
37
38
# File 'app/controllers/protocol_relationships_controller.rb', line 30

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

- (Object) protocol_relationship_params (private)



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

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

- (Object) search



88
89
90
91
92
93
94
# File 'app/controllers/protocol_relationships_controller.rb', line 88

def search
  if params[:id].blank?
    redirect_to protocol_relationships_path, notice: '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

- (Object) set_protocol_relationship (private)



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

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

- (Object) show

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



26
27
# File 'app/controllers/protocol_relationships_controller.rb', line 26

def show
end

- (Object) update

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



66
67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/protocol_relationships_controller.rb', line 66

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