Class: DocumentationController

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

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

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

#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form

Methods included from Api::Intercept

#intercept_api

Instance Method Details

#createObject

POST /documentation POST /documentation.json



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

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

#destroyObject

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



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

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

#documentation_paramsObject (private)



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

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

#editObject

GET /documentation/1/edit



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

def edit
end

#indexObject

GET /documentation GET /documentation.json



8
9
10
11
12
13
14
15
16
17
18
19
# 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 {
      @documentation = ::Queries::Documentation::Filter.new(params).all.where(project_id: sessions_current_project_id).
      page(params[:page]).per(params[:per] || 500)
    }
  end
end

#listObject



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

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

#newObject

GET /documentation/new



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

def new
  @documentation = Documentation.new
end

#searchObject



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

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

#set_documentationObject (private)



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

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

#showObject

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



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

def show
end

#updateObject

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



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

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