Sha256: 24bdc37ebcf933f7ea73a0b406769dcf4133cda35500e68746eb611dab4342ba

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 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(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

    # GET /categories/1/more_keys.js
    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

  
    # DELETE /categories/1
    # DELETE /categories/1.json
    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

    def category_params
      params.permit!
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
afalkear_translation_center-1.8.2 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-1.8.1 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-1.8.0 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-1.7.9 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-1.7.8 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-0.0.0 app/controllers/translation_center/categories_controller.rb
afalkear_translation_center-1.7.7 app/controllers/translation_center/categories_controller.rb