Class: LabelsController

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

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

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

#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs

Methods included from Api::Intercept

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#createObject

POST /labels POST /labels.json



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

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.metamorphosize }
    else
      format.html { render :new }
      format.json { render json: @label.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

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



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

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

#editObject

GET /labels/1/edit



34
35
# File 'app/controllers/labels_controller.rb', line 34

def edit
end

#filter_paramsObject (private)



87
88
89
# File 'app/controllers/labels_controller.rb', line 87

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

#indexObject

GET /labels GET /labels.json



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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)
      .page(params[:page])
      .per(params[:per])
    }
  end
end

#label_paramsObject (private)



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

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

#listObject



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

def list
  @labels = Label.where(project_id: sessions_current_project_id).page(params[:page])
end

#newObject

GET /labels/new



29
30
31
# File 'app/controllers/labels_controller.rb', line 29

def new
  @label = Label.new
end

#set_labelObject (private)



83
84
85
# File 'app/controllers/labels_controller.rb', line 83

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

#showObject

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



25
26
# File 'app/controllers/labels_controller.rb', line 25

def show
end

#updateObject

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



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

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.metamorphosize }
    else
      format.html { render :edit }
      format.json { render json: @label.errors, status: :unprocessable_entity }
    end
  end
end