Sha256: 6eb8e2cdc4d01b57fcd60271e41cc4f472577ea70e808f9358007350e19c6cd8

Contents?: true

Size: 1.83 KB

Versions: 17

Compression:

Stored size: 1.83 KB

Contents

require_dependency "translation_center/application_controller"

module TranslationCenter
  class CategoriesController < ApplicationController
    before_filter :can_admin?, only: [ :destroy ]
    before_filter :set_page_number, except: :destroy

    # GET /categories
    # GET /categories.json
    def index
      @categories = Category.all
  
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @categories }
      end
    end
  
    # GET /categories/1
    # GET /categories/1.json
    def show
      @category = Category.find(params[:id])
      session[:current_filter] = 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

    # GET /categories/1/more_keys.js
    def more_keys
      @category = Category.find(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

  
    # DELETE /categories/1
    # DELETE /categories/1.json
    def destroy
      @category = Category.find(params[:id])
      @category.destroy
  
      respond_to do |format|
        format.html { redirect_to categories_url }
        format.json { head :no_content }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
translation_center-2.0.1 app/controllers/translation_center/categories_controller.rb
translation_center-1.7.2 app/controllers/translation_center/categories_controller.rb
translation_center-1.7.1 app/controllers/translation_center/categories_controller.rb
translation_center-1.7.0 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.10 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.9 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.8 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.7 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.6 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.5 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.4 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.3 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.2 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.1 app/controllers/translation_center/categories_controller.rb
translation_center-1.6.0 app/controllers/translation_center/categories_controller.rb
translation_center-1.5.9 app/controllers/translation_center/categories_controller.rb
translation_center-1.5.8 app/controllers/translation_center/categories_controller.rb