translation_center 1.6.5 → 1.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,3 +45,6 @@
45
45
  top: -14px !important;
46
46
  }
47
47
 
48
+ input#search_keys, input#translations{
49
+ width: 110px;
50
+ }
@@ -3,6 +3,7 @@ require_dependency "translation_center/application_controller"
3
3
  module TranslationCenter
4
4
  class TranslationsController < ApplicationController
5
5
  before_filter :can_admin?, only: [ :destroy, :accept, :unaccept ]
6
+ before_filter :set_page_number, only: [:search]
6
7
 
7
8
  # POST /translations/1/vote
8
9
  def vote
@@ -56,5 +57,16 @@ module TranslationCenter
56
57
  end
57
58
  end
58
59
 
60
+ def search
61
+ @result = Translation.where('value LIKE ?', "%#{params[:translation_value]}%")
62
+ @translations = @result.offset(Translation::NUMBER_PER_PAGE * (@page - 1)).limit(Translation::NUMBER_PER_PAGE)
63
+ @total_pages = (@result.count / (Translation::NUMBER_PER_PAGE * 1.0)).ceil
64
+
65
+ respond_to do |format|
66
+ format.html
67
+ format.js
68
+ end
69
+ end
70
+
59
71
  end
60
72
  end
@@ -6,6 +6,7 @@ module TranslationCenter
6
6
  serialize :value
7
7
 
8
8
  CHANGES_PER_PAGE = 5
9
+ NUMBER_PER_PAGE = 15
9
10
 
10
11
  belongs_to :translation_key
11
12
  belongs_to :translator, polymorphic: true
@@ -56,6 +56,8 @@
56
56
  %li.divider-vertical
57
57
  %form.navbar-search
58
58
  %input#search_keys.search-query{placeholder: t('translation_center.search_keys'), type: "text", autocomplete: :off}
59
+ %form.navbar-search{action: search_translations_path}
60
+ %input#translations.search-query{placeholder: t('translation_center.search_translations'), type: "text", autocomplete: :off, name: :translation_value, value: params[:translation_value]}
59
61
 
60
62
  %ul.nav.pull-right
61
63
  %li
@@ -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'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=1"
37
+ = link_to t('pagination.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'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@page - 1}"
40
+ = link_to t('pagination.prev'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@page - 1}"
41
41
  |
42
- = link_to t('.next'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@page + 1}"
42
+ = link_to t('pagination.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'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@total_pages}"
45
+ = link_to t('pagination.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
@@ -0,0 +1,27 @@
1
+ %h2= t('translation_center.center.search.title', value: params[:translation_value])
2
+
3
+ .pagination
4
+
5
+ - if @page != 1
6
+ = link_to t('pagination.first'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=1"
7
+ |
8
+ = link_to t('pagination.prev'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}&page=#{@page - 1}"
9
+ |
10
+
11
+ - if @total_pages != 1 && @page != @total_pages
12
+
13
+ = link_to t('pagination.next'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}&page=#{@page + 1}"
14
+ - if @page != @total_pages
15
+ |
16
+ = link_to t('pagination.last'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@total_pages}"
17
+ = @page
18
+ = t('.of')
19
+ = @total_pages
20
+
21
+
22
+ %div
23
+ - translations.each do |translation|
24
+ %a.category{ href: translation_key_path(id: translation.key, lang_to: translation.lang), title: translation.key.name }
25
+ .category_name
26
+ = truncate(translation.key.name, length: 35)
27
+
@@ -0,0 +1,2 @@
1
+ #translations_search_result
2
+ = render 'search_results', translations: @translations
@@ -0,0 +1 @@
1
+ $('#translations_search_result').html("#{escape_javascript(render 'search_results', translations: @translations)}")
data/config/routes.rb CHANGED
@@ -5,6 +5,9 @@ TranslationCenter::Engine.routes.draw do
5
5
  post :unvote
6
6
  post :accept
7
7
  post :unaccept
8
+ collection do
9
+ get :search
10
+ end
8
11
  end
9
12
 
10
13
  resources :translation_keys, except: :create do
@@ -1,5 +1,10 @@
1
1
  en:
2
2
  translation_center:
3
+ pagination:
4
+ next: Next
5
+ first: First
6
+ prev: Prev.
7
+ last: Last
3
8
  actions:
4
9
  are_you_sure: "Are you sure ?"
5
10
  back_to_app: "Back To App"
@@ -36,8 +41,11 @@ en:
36
41
  these_actions_will_affect_existing_data: "These actions will affect existing data"
37
42
  translated: Translated
38
43
  untranslated: Untranslated
44
+ search:
45
+ title: "Keys with translations that contain '%{value}'"
39
46
  dashboard: Dashboard
40
- search_keys: "Search Keys"
47
+ search_keys: "Keys"
48
+ search_translations: "Translations"
41
49
  translate_to: "Translate To"
42
50
  translation_center: "Translation Center"
43
51
  translation_keys:
@@ -1,3 +1,3 @@
1
1
  module TranslationCenter
2
- VERSION = "1.6.5"
2
+ VERSION = "1.6.6"
3
3
  end
@@ -296,7 +296,7 @@ en:
296
296
  translated: Translated
297
297
  untranslated: Untranslated
298
298
  dashboard: Dashboard
299
- search_keys: "Search Keys"
299
+ search_keys: "Keys"
300
300
  translate_to: "Translate To"
301
301
  translation_center: "Translation Center"
302
302
  translation_keys: