Class: CharacterStatesController

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

#annotationsObject

TODO: remove GET /character_states/annotations.json



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

def annotations
  @object = @character_state
  render '/shared/data/all/annotations'
end

#autocompleteObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/character_states_controller.rb', line 67

def autocomplete
  @character_states = CharacterState.find_for_autocomplete(params).where(project_id: sessions_current_project_id)

  data = @character_states.collect do |t|
    label = helpers.expanded_character_state_tag(t)
    {id: t.id,
     label:,
     response_values: {
       params[:method] => t.id
     },
     label_html: label 
    }
  end
  render json: data
end

#character_state_paramsObject (private)



100
101
102
# File 'app/controllers/character_states_controller.rb', line 100

def character_state_params
  params.require(:character_state).permit(:name, :key_name, :description_name, :label, :descriptor_id, :position)
end

#createObject

POST /character_states POST /character_states.json



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/character_states_controller.rb', line 29

def create
  @character_state = CharacterState.new(character_state_params)

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

#destroyObject

DELETE /character_states/1 DELETE /character_states/1.json



59
60
61
62
63
64
65
# File 'app/controllers/character_states_controller.rb', line 59

def destroy
  @character_state.destroy
  respond_to do |format|
    format.html { redirect_to character_states_url, notice: 'Character state was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /character_states/1/edit



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

def edit
end

#indexObject

GET /character_states GET /character_states.json



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

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

#listObject



84
85
86
# File 'app/controllers/character_states_controller.rb', line 84

def list
  @character_states = CharacterState.with_project_id(sessions_current_project_id).page(params[:page])
end

#newObject

GET /character_states/new



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

def new
  @character_state = CharacterState.new
end

#set_character_stateObject (private)



96
97
98
# File 'app/controllers/character_states_controller.rb', line 96

def set_character_state
  @character_state = CharacterState.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /character_states/1 GET /character_states/1.json



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

def show
end

#updateObject

PATCH/PUT /character_states/1 PATCH/PUT /character_states/1.json



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

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