effective_datatables 4.4.6 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f51c05dbf844ec08e797fc26723a9e680b7b01
4
- data.tar.gz: f1c9c9e23fb8199df78cf2d5059d4d520fe42c77
3
+ metadata.gz: 5a53e65ef62ff9d0a782a0080f6a9deadd22b609
4
+ data.tar.gz: ac4e5578e12e9bef11b5093bff3fee1c7443a67d
5
5
  SHA512:
6
- metadata.gz: c0fc7e3f321ebb3c873ecdba4d4cba89d2590a449b5591ed42a7ac3a72a937e87d40c3f33ba00baac6d1221538aee48964ac9f9d1af3e9397ea8188b8f530874
7
- data.tar.gz: 098d5a6eee6e134b024c9fd7ec588353071f0b94a4a7c7b62cfdb26e0f8cf03b40bbe7b7de67e753f5915b3c8bcd9e08b4eb5ff27d6eaaf2c46d7185eb8ef3bc
6
+ metadata.gz: 039ca9d10af887b4949882b743cfc60f76e4247374595f80400c2b43850892be2149d51b0fc66e357029006100d8f9734e347840bd61d76c3eaaa142092e56cf
7
+ data.tar.gz: f7f922a6ec951c3f20b83c1b478f5cc580136c35dfc9d9c8a06fb4dd4947a2f7f25da6525c6fd87e2ff673bb649f3f125a594798daa8231e1348042cb4d25a0f
@@ -0,0 +1,33 @@
1
+ /**
2
+ * English - this is the default DataTables ships with
3
+ * @name English
4
+ * @anchor English
5
+ * @author <a href="http://www.sprymedia.co.uk/">Allan Jardine</a>
6
+ */
7
+
8
+ {
9
+ "sEmptyTable": "No data available in table",
10
+ "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
11
+ "sInfoEmpty": "Showing 0 to 0 of 0 entries",
12
+ "sInfoFiltered": "(filtered from _MAX_ total entries)",
13
+ "sInfoPostFix": "",
14
+ "sInfoThousands": ",",
15
+ "sLengthMenu": "&nbsp;with _MENU_ per page",
16
+ "sLoadingRecords": "Loading...",
17
+ "sProcessing": "Processing...",
18
+ "sSearch": "Search:",
19
+ "sZeroRecords": "No matching records found",
20
+ "oPaginate": {
21
+ "sFirst": "First",
22
+ "sLast": "Last",
23
+ "sNext": "Next",
24
+ "sPrevious": "Previous"
25
+ },
26
+ "oAria": {
27
+ "sSortAscending": ": activate to sort column ascending",
28
+ "sSortDescending": ": activate to sort column descending"
29
+ },
30
+ "buttons": {
31
+ "colvis": "Show / Hide"
32
+ }
33
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Spanish translation
3
+ * @name Spanish
4
+ * @anchor Spanish
5
+ * @author Giovanni Ariza, Aristobulo Gomez and Roberto Poo
6
+ */
7
+
8
+ {
9
+ "sProcessing": "Procesando...",
10
+ "sLengthMenu": "Mostrar _MENU_ registros",
11
+ "sZeroRecords": "No se encontraron resultados",
12
+ "sEmptyTable": "Ningún dato disponible en esta tabla =(",
13
+ "sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
14
+ "sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
15
+ "sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
16
+ "sLengthMenu": "&nbsp; con _MENU_ por página",
17
+ "sInfoPostFix": "",
18
+ "sSearch": "Buscar:",
19
+ "sUrl": "",
20
+ "sInfoThousands": ",",
21
+ "sLoadingRecords": "Cargando...",
22
+ "oPaginate": {
23
+ "sFirst": "Primero",
24
+ "sLast": "Último",
25
+ "sNext": "Siguiente",
26
+ "sPrevious": "Anterior"
27
+ },
28
+ "oAria": {
29
+ "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
30
+ "sSortDescending": ": Activar para ordenar la columna de manera descendente"
31
+ },
32
+ "buttons": {
33
+ "copy": "Copiar",
34
+ "colvis": "Mostrar/Ocultar"
35
+ }
36
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Dutch translation
3
+ * @name Dutch
4
+ * @anchor Dutch
5
+ * @author <a href="http://www.blikgooien.nl/">Erwin Kerk</a> and <i>ashwin</i>
6
+ */
7
+
8
+ {
9
+ "sProcessing": "Bezig...",
10
+ "sLengthMenu": "_MENU_ resultaten weergeven",
11
+ "sZeroRecords": "Geen resultaten gevonden",
12
+ "sInfo": "_START_ tot _END_ van _TOTAL_ resultaten",
13
+ "sInfoEmpty": "Geen resultaten om weer te geven",
14
+ "sInfoFiltered": " (gefilterd uit _MAX_ resultaten)",
15
+ "sInfoPostFix": "",
16
+ "sSearch": "Zoeken:",
17
+ "sEmptyTable": "Geen resultaten aanwezig in de tabel",
18
+ "sInfoThousands": ".",
19
+ "sLoadingRecords": "Een moment geduld aub - bezig met laden...",
20
+ "oPaginate": {
21
+ "sFirst": "Eerste",
22
+ "sLast": "Laatste",
23
+ "sNext": "Volgende",
24
+ "sPrevious": "Vorige"
25
+ },
26
+ "oAria": {
27
+ "sSortAscending": ": activeer om kolom oplopend te sorteren",
28
+ "sSortDescending": ": activeer om kolom aflopend te sorteren"
29
+ }
30
+ }
@@ -0,0 +1,12 @@
1
+ # Get the translations from:
2
+ # https://github.com/DataTables/Plugins/tree/master/i18n
3
+
4
+ require 'i18n_data'
5
+
6
+ (Dir['*'] - ['renamer.rb']).each do |f|
7
+ code = I18nData.language_code(File.basename(f, ".*"))
8
+
9
+ next if code.nil?
10
+
11
+ File.rename(f, code.downcase + '.lang')
12
+ end
@@ -14,7 +14,6 @@ initializeDataTables = (target) ->
14
14
  buttons: [
15
15
  {
16
16
  extend: 'colvis',
17
- text: 'Show / Hide',
18
17
  postfixButtons: [
19
18
  { extend: 'colvisGroup', text: 'Show all', show: ':hidden', className: 'buttons-colvisGroup-first'},
20
19
  { extend: 'colvisGroup', text: 'Show none', hide: ':visible'}
@@ -49,7 +48,7 @@ initializeDataTables = (target) ->
49
48
  deferRender: true
50
49
  displayStart: datatable.data('display-start')
51
50
  iDisplayLength: datatable.data('display-length')
52
- language: { 'lengthMenu': '&nbsp;with _MENU_ per page'}
51
+ language: datatable.data('language')
53
52
  lengthMenu: [[5, 10, 25, 50, 100, 250, 500, 9999999], ['5', '10', '25', '50', '100', '250', '500', 'All']]
54
53
  order: datatable.data('display-order')
55
54
  processing: true
@@ -1,6 +1,5 @@
1
1
  # These are expected to be called by a developer. They are part of the datatables DSL.
2
2
  module EffectiveDatatablesHelper
3
-
4
3
  def render_datatable(datatable, input_js: {}, buttons: true, charts: true, entries: true, filters: true, inline: false, pagination: true, search: true, simple: false, sort: true)
5
4
  raise 'expected datatable to be present' unless datatable
6
5
  raise 'expected input_js to be a Hash' unless input_js.kind_of?(Hash)
@@ -50,6 +49,7 @@ module EffectiveDatatablesHelper
50
49
  'display-records' => datatable.to_json[:recordsFiltered],
51
50
  'display-start' => datatable.display_start,
52
51
  'inline' => inline.to_s,
52
+ 'language' => EffectiveDatatables.language(I18n.locale),
53
53
  'options' => input_js.to_json,
54
54
  'reset' => (datatable_reset(datatable) if search),
55
55
  'reorder' => datatable_reorder(datatable),
@@ -57,7 +57,7 @@ module EffectiveDatatablesHelper
57
57
  'simple' => simple.to_s,
58
58
  'spinner' => icon('spinner'), # effective_bootstrap
59
59
  'source' => effective_datatables.datatable_path(datatable, {format: 'json'}),
60
- 'total-records' => datatable.to_json[:recordsTotal]
60
+ 'total-records' => datatable.to_json[:recordsTotal],
61
61
  }
62
62
  }
63
63
 
@@ -30,29 +30,29 @@ module EffectiveDatatablesPrivateHelper
30
30
  end
31
31
 
32
32
  def datatable_reset(datatable)
33
- link_to(content_tag(:span, 'Reset'), '#', class: 'btn btn-link btn-sm buttons-reset-search')
33
+ link_to(content_tag(:span, t('effective_datatables.reset')), '#', class: 'btn btn-link btn-sm buttons-reset-search')
34
34
  end
35
35
 
36
36
  def datatable_reorder(datatable)
37
37
  return unless datatable.reorder? && EffectiveDatatables.authorized?(self, :update, datatable.collection_class)
38
- link_to(content_tag(:span, 'Reorder'), '#', class: 'btn btn-link btn-sm buttons-reorder', disabled: true)
38
+ link_to(content_tag(:span, t('effective_datatables.reorder')), '#', class: 'btn btn-link btn-sm buttons-reorder', disabled: true)
39
39
  end
40
40
 
41
41
  def datatable_new_resource_button(datatable, name, column)
42
42
  return unless column[:inline] && (column[:actions][:new] != false) && (datatable.resource.actions.include?(:new) rescue false)
43
43
 
44
- actions = {'New' => { action: :new, class: ['btn', column[:btn_class].presence].compact.join(' '), 'data-remote': true } }
44
+ actions = {t('effective_datatables.new') => { action: :new, class: ['btn', column[:btn_class].presence].compact.join(' '), 'data-remote': true } }
45
45
  render_resource_actions(datatable.resource.klass, actions: actions, effective_resource: datatable.resource) # Will only work if permitted
46
46
  end
47
47
 
48
48
  def datatable_label_tag(datatable, name, opts)
49
49
  case opts[:as]
50
50
  when :actions
51
- content_tag(:span, 'Actions', style: 'display: none;')
51
+ content_tag(:span, t('effective_datatables.actions'), style: 'display: none;')
52
52
  when :bulk_actions
53
- content_tag(:span, 'Bulk Actions', style: 'display: none;')
53
+ content_tag(:span, t('effective_datatables.bulk_actions'), style: 'display: none;')
54
54
  when :reorder
55
- content_tag(:span, 'Reorder', style: 'display: none;')
55
+ content_tag(:span, t('effective_datatables.reorder'), style: 'display: none;')
56
56
  else
57
57
  content_tag(:span, opts[:label].presence)
58
58
  end
@@ -73,10 +73,7 @@ module Effective
73
73
 
74
74
  (view.render_resource_actions(value, atts) || '')
75
75
  when :boolean
76
- case value
77
- when true ; 'Yes'
78
- when false ; 'No'
79
- end
76
+ view.t("effective_datatables.boolean_#{value}")
80
77
  when :currency
81
78
  view.number_to_currency(value)
82
79
  when :date
@@ -9,6 +9,6 @@
9
9
 
10
10
  .form-group.col-auto
11
11
  - if datatable._filters_form_required?
12
- = form.save 'Apply', 'data-disable-with': 'Applying...'
12
+ = form.save t('effective_datatables.apply'), 'data-disable-with': t('effective_datatables.applying')
13
13
  - else
14
- = link_to 'Apply', '#', class: 'btn btn-primary btn-effective-datatables-filters', 'data-apply-effective-datatables-filters': true
14
+ = link_to t('effective_datatables.apply'), '#', class: 'btn btn-primary btn-effective-datatables-filters', 'data-apply-effective-datatables-filters': true
@@ -0,0 +1,12 @@
1
+ ---
2
+ en:
3
+ effective_datatables:
4
+ apply: Apply
5
+ reset: Reset
6
+ reorder: Reorder
7
+ new: New
8
+ actions: Actions
9
+ bulk_actions: Bulk Actions
10
+ applying: Applying...
11
+ boolean_true: 'Yes'
12
+ boolean_false: 'No'
@@ -0,0 +1,12 @@
1
+ ---
2
+ es:
3
+ effective_datatables:
4
+ apply: Filtrar
5
+ reset: Reiniciar
6
+ reorder: Reordenar
7
+ new: Nuevo
8
+ actions: Acciones
9
+ bulk_actions: Acciones en masa
10
+ applying: Filtrando...
11
+ boolean_true: 'Sí'
12
+ boolean_false: 'No'
@@ -0,0 +1,12 @@
1
+ ---
2
+ nl:
3
+ effective_datatables:
4
+ apply: Toepassen
5
+ reset: Reset
6
+ reorder: Opnieuw ordenen
7
+ new: Nieuwe
8
+ actions: Acties
9
+ bulk_actions: Bulkacties
10
+ applying: Toepassen...
11
+ boolean_true: 'Ja'
12
+ boolean_false: 'Nee'
@@ -4,6 +4,8 @@ require 'effective_datatables/engine'
4
4
  require 'effective_datatables/version'
5
5
 
6
6
  module EffectiveDatatables
7
+ AVAILABLE_LOCALES = %w(en es nl)
8
+
7
9
  mattr_accessor :authorization_method
8
10
 
9
11
  mattr_accessor :default_length
@@ -47,4 +49,17 @@ module EffectiveDatatables
47
49
  klass.try(:new) || raise('unable to find datatable')
48
50
  end
49
51
 
52
+ # Locale is coming from view. I think it can be dynamic.
53
+ # We currently support: en, es, nl
54
+ def self.language(locale)
55
+ @_languages ||= {}
56
+
57
+ locale = :en unless AVAILABLE_LOCALES.include?(locale.to_s)
58
+
59
+ @_languages[locale] ||= begin
60
+ path = Gem::Specification.find_by_name('effective_datatables').gem_dir + "/app/assets/javascripts/dataTables/locales/#{locale}.lang"
61
+ JSON.parse(File.read(path)).to_json
62
+ end
63
+ end
64
+
50
65
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.4.6'.freeze
2
+ VERSION = '4.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.6
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -101,6 +101,10 @@ files:
101
101
  - app/assets/javascripts/dataTables/buttons/dataTables.buttons.js
102
102
  - app/assets/javascripts/dataTables/dataTables.bootstrap4.js
103
103
  - app/assets/javascripts/dataTables/jquery.dataTables.js
104
+ - app/assets/javascripts/dataTables/locales/en.lang
105
+ - app/assets/javascripts/dataTables/locales/es.lang
106
+ - app/assets/javascripts/dataTables/locales/nl.lang
107
+ - app/assets/javascripts/dataTables/locales/renamer.rb
104
108
  - app/assets/javascripts/dataTables/responsive/dataTables.responsive.js
105
109
  - app/assets/javascripts/dataTables/responsive/responsive.bootstrap4.js
106
110
  - app/assets/javascripts/dataTables/rowReorder/dataTables.rowReorder.js
@@ -161,6 +165,9 @@ files:
161
165
  - app/views/effective/datatables/index.html.haml
162
166
  - app/views/effective/style_guide/_effective_datatables.html.haml
163
167
  - config/effective_datatables.rb
168
+ - config/locales/en.yml
169
+ - config/locales/es.yml
170
+ - config/locales/nl.yml
164
171
  - config/routes.rb
165
172
  - lib/effective_datatables.rb
166
173
  - lib/effective_datatables/engine.rb