Class: DocumentationController

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

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) create

POST /documentation POST /documentation.json



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/documentation_controller.rb', line 38

def create
  @documentation = Documentation.new(documentation_params)

  respond_to do |format|
    if @documentation.save
      format.html { redirect_to url_for(@documentation.metamorphosize),
                                notice: 'Documentation was successfully created.' }
      format.json { render action: 'show', status: :created, location: @documentation }
    else
      format.html { render action: 'new' }
      format.json { render json: @documentation.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /documentation/1 DELETE /documentation/1.json



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

def destroy
  @documentation.destroy
  respond_to do |format|
    format.html { redirect_to documentation_index_url, notice: 'Documentation was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) documentation_params (private)



96
97
98
99
100
101
# File 'app/controllers/documentation_controller.rb', line 96

def documentation_params
  params.require(:documentation).permit(
    :documentation_object_id, :documentation_object_type, :document_id, :annotated_global_entity, :position,
    document_attributes: [:document_file]
  )
end

- (Object) edit

GET /documentation/1/edit



33
34
# File 'app/controllers/documentation_controller.rb', line 33

def edit
end

- (Object) index

GET /documentation GET /documentation.json



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

def index
  respond_to do |format|
    format.html {
      @recent_objects = Documentation.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    }
    format.json {
      @documenation = Documentation.where(project_id: sessions_current_project_id).where(
        Queries::Annotator::polymorphic_params(params, Documentation)
      )
    }
  end
end

- (Object) list



78
79
80
# File 'app/controllers/documentation_controller.rb', line 78

def list
  @documentation = Documentation.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10)
end

- (Object) new

GET /documentation/new



28
29
30
# File 'app/controllers/documentation_controller.rb', line 28

def new
  @documentation = Documentation.new
end

- (Object) search



82
83
84
85
86
87
88
# File 'app/controllers/documentation_controller.rb', line 82

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

- (Object) set_documentation (private)



92
93
94
# File 'app/controllers/documentation_controller.rb', line 92

def set_documentation
  @documentation = Documentation.find(params[:id])
end

- (Object) show

GET /documentation/1 GET /documentation/1.json



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

def show
end

- (Object) update

PATCH/PUT /documentation/1 PATCH/PUT /documentation/1.json



55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/documentation_controller.rb', line 55

def update
  respond_to do |format|
    if @documentation.update(documentation_params)
      format.html { redirect_to url_for(@documentation.metamorphosize),
                                notice: 'Documentation was successfully updated.' }
      format.json { render :show, status: :ok, location: @documentation }
    else
      format.html { render :edit }
      format.json { render json: @documentation.errors, status: :unprocessable_entity }
    end
  end
end