Class: OriginRelationshipsController

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

#annotator_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, #whitelist_constantize

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
94
# File 'app/controllers/origin_relationships_controller.rb', line 79

def autocomplete
  @origin_relationships = origin_relationship.where(project_id: sessions_current_project_id).where('origin_relationship ILIKE ?', "#{params[:term]}%")

  data = @origin_relationships.collect do |t|
    {id:              t.id,
     label:           t.origin_relationship,
     gid:             t.to_global_id.to_s,
     response_values: {
       params[:method] => t.id
     },
     label_html:      t.origin_relationship
    }
  end

  render json: data
end

- (Object) create

POST /origin_relationships POST /origin_relationships.json



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

def create
  @origin_relationship = OriginRelationship.new(origin_relationship_params)

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

- (Object) destroy

DELETE /origin_relationships/1 DELETE /origin_relationships/1.json



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

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

- (Object) edit

GET /origin_relationships/1/edit



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

def edit
end

- (Object) index

GET /origin_relationships GET /origin_relationships.json



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

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

- (Object) list



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

def list
  @origin_relationships = OriginRelationship.with_project_id(sessions_current_project_id).page(params[:page])
end

- (Object) new

GET /origin_relationships/new



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

def new
  @origin_relationship = OriginRelationship.new
end

- (Object) origin_relationship_params (private)

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



104
105
106
# File 'app/controllers/origin_relationships_controller.rb', line 104

def origin_relationship_params
  params.require(:origin_relationship).permit(:old_object_id, :old_object_type, :new_object_id, :new_object_type, :position, :created_by_id, :updated_by_id, :project_id)
end

- (Object) search



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

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

- (Object) set_origin_relationship (private)

Use callbacks to share common setup or constraints between actions.



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

def set_origin_relationship
  @origin_relationship = OriginRelationship.find(params[:id])
end

- (Object) show

GET /origin_relationships/1 GET /origin_relationships/1.json



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

def show
end

- (Object) update

PATCH/PUT /origin_relationships/1 PATCH/PUT /origin_relationships/1.json



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

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