Class: LabelsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/labels_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 /labels POST /labels.json



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/labels_controller.rb', line 45

def create
  @label = Label.new(label_params)

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

- (Object) destroy

DELETE /labels/1 DELETE /labels/1.json



75
76
77
78
79
80
81
# File 'app/controllers/labels_controller.rb', line 75

def destroy
  @label.destroy
  respond_to do |format|
    format.html { redirect_to labels_url, notice: 'Label was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /labels/1/edit



36
37
# File 'app/controllers/labels_controller.rb', line 36

def edit
end

- (Object) filter_params (private)



89
90
91
# File 'app/controllers/labels_controller.rb', line 89

def filter_params
  params.permit(:label_object_id, :label_object_type) 
end

- (Object) index

GET /labels GET /labels.json



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

def index
  respond_to do |format|
    format.html do
      @recent_objects = Label.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      @labels = Label.where(filter_params).with_project_id(sessions_current_project_id)
    }
  end
end

- (Object) label_params (private)



93
94
95
96
97
98
# File 'app/controllers/labels_controller.rb', line 93

def label_params
  params.require(:label).permit(
    :text, :total, :style, :is_copy_edited, :is_printed, :label_object_id, :label_object_type,
    :annotated_global_entity
  )
end

- (Object) list



20
21
22
23
# File 'app/controllers/labels_controller.rb', line 20

def list
  @labels = Label.with_project_id(sessions_current_project_id).page(params[:page])
  @recent_object = @label
end

- (Object) new

GET /labels/new



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

def new
  @label = Label.new
end

- (Object) set_label (private)



85
86
87
# File 'app/controllers/labels_controller.rb', line 85

def set_label
  @label = Label.find(params[:id])
end

- (Object) show

GET /labels/1 GET /labels/1.json



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

def show
end

- (Object) update

PATCH/PUT /labels/1 PATCH/PUT /labels/1.json



61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/labels_controller.rb', line 61

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