translation_center 1.5.6 → 1.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,15 +23,15 @@ module TranslationCenter
23
23
  end
24
24
 
25
25
  def dashboard
26
+ params[:page] ||= 1
27
+ @page = params[:page].to_i
26
28
  @stats = TranslationKey.langs_stats
27
29
  @langs = @stats.keys
28
30
  # to be used for meta search
29
31
  @search = Audited::Adapters::ActiveRecord::Audit.search(params[:search])
30
32
  #TODO perpage constant should be put somewhere else
31
- @translations_changes = Translation.recent_changes.page(params[:page]).limit(5)
32
- params[:page] ||= 1
33
- @page = params[:page].to_i
34
- @total_pages = Translation.recent_changes.count / 5
33
+ @translations_changes = Translation.recent_changes.offset(Translation::CHANGES_PER_PAGE * (@page - 1)).limit(Translation::CHANGES_PER_PAGE)
34
+ @total_pages = (Translation.recent_changes.count / (Translation::CHANGES_PER_PAGE * 1.0)).ceil
35
35
 
36
36
  respond_to do |format|
37
37
  format.html
@@ -40,10 +40,11 @@ module TranslationCenter
40
40
  end
41
41
 
42
42
  def search_activity
43
- @translations_changes = Translation.recent_changes(params[:search]).page(params[:page]).limit(5)
44
43
  params[:page] ||= 1
45
44
  @page = params[:page].to_i
46
- @total_pages = Translation.recent_changes(params[:search]).count / 5
45
+
46
+ @translations_changes = Translation.recent_changes(params[:search]).offset(Translation::CHANGES_PER_PAGE * (@page - 1)).limit(Translation::CHANGES_PER_PAGE)
47
+ @total_pages = (Translation.recent_changes(params[:search]).count / (Translation::CHANGES_PER_PAGE * 1.0)).ceil
47
48
 
48
49
  respond_to do |format|
49
50
  format.js
@@ -6,6 +6,8 @@ module TranslationCenter
6
6
  # serialize as we could store arrays
7
7
  serialize :value
8
8
 
9
+ CHANGES_PER_PAGE = 5
10
+
9
11
  belongs_to :translation_key
10
12
  belongs_to :translator, polymorphic: true
11
13
 
@@ -34,15 +34,15 @@
34
34
  = distance_of_time_in_words_to_now change.created_at
35
35
  = t('.ago')
36
36
  .pagination
37
- = link_to t('.first'), dashboard_path(page: 1)
37
+ = link_to t('.first'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=1"
38
38
  - if @page != 1
39
39
  |
40
- = link_to t('.prev'), dashboard_path(page: @page - 1)
40
+ = link_to t('.prev'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@page - 1}"
41
41
  |
42
- = link_to t('.next'), dashboard_path(page: @page + 1)
42
+ = link_to t('.next'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@page + 1}"
43
43
  - if @page != @total_pages
44
44
  |
45
- = link_to t('.last'), dashboard_path(page: @total_pages)
45
+ = link_to t('.last'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@total_pages}"
46
46
  = @page
47
47
  = t('.of')
48
48
  = @total_pages
@@ -51,7 +51,7 @@
51
51
  %h1
52
52
  = t('.activity')
53
53
  .span12
54
-
54
+
55
55
  = form_for @search, url: :search_activity, html: { method: :get, id: :search_form, class: 'pull-left form-search' } do |f|
56
56
  = f.text_field 'auditable_TranslationCenter::Translation_type_translation_key_name_matches', class: 'search_field input-medium', placeholder: 'KEY'
57
57
 
@@ -4,11 +4,12 @@ require 'haml'
4
4
  require 'haml-rails'
5
5
  require 'acts_as_votable'
6
6
  require 'ya2yaml'
7
- require 'meta_search'
8
7
  require 'font-awesome-rails'
9
8
  require 'audited-activerecord'
10
9
 
11
10
  module TranslationCenter
11
+ require 'meta_search'
12
+
12
13
  class Engine < ::Rails::Engine
13
14
  isolate_namespace TranslationCenter
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module TranslationCenter
2
- VERSION = "1.5.6"
2
+ VERSION = "1.5.7"
3
3
  end