Class: TranslationCenter::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/translation_center/categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#translation_langs_filters

Instance Method Details

#category_paramsObject



57
58
59
# File 'app/controllers/translation_center/categories_controller.rb', line 57

def category_params
  params.permit!
end

#destroyObject

DELETE /categories/1 DELETE /categories/1.json



47
48
49
50
51
52
53
54
55
# File 'app/controllers/translation_center/categories_controller.rb', line 47

def destroy
  @category = Category.find(category_params[:id])
  @category.destroy
  
  respond_to do |format|
    format.html { redirect_to categories_url }
    format.json { head :no_content }
  end
end

#indexObject

GET /categories GET /categories.json



10
11
12
13
14
15
16
17
# File 'app/controllers/translation_center/categories_controller.rb', line 10

def index
  @categories = Category.all
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @categories }
  end
end

#more_keysObject

GET /categories/1/more_keys.js



36
37
38
39
40
41
42
# File 'app/controllers/translation_center/categories_controller.rb', line 36

def more_keys
  @category = Category.find(category_params[:category_id])
  @keys = @category.send("#{session[:current_filter]}_keys", session[:lang_to]).offset(@page - 1).limit(TranslationKey::PER_PAGE)
  respond_to do |format|
    format.js { render 'keys' }
  end
end

#showObject

GET /categories/1 GET /categories/1.json



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/translation_center/categories_controller.rb', line 21

def show
  @category = Category.find(category_params[:id])
  session[:current_filter] = category_params[:filter] || session[:current_filter]
  @keys = @category.send("#{session[:current_filter]}_keys", session[:lang_to]).offset(@page - 1).limit(TranslationKey::PER_PAGE)
  @untranslated_keys_count = @category.untranslated_keys(session[:lang_to]).count
  @translated_keys_count = @category.translated_keys(session[:lang_to]).count
  @pending_keys_count = @category.pending_keys(session[:lang_to]).count
  @all_keys_count = @untranslated_keys_count + @translated_keys_count + @pending_keys_count
  respond_to do |format|
    format.html # show.html.erb
    format.js
  end
end