simple-datatable 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 5f568f1a7e3f5f96f01d92ee18a26ae60a6e6ea7d2f59f472f683199160a58b8
4
- data.tar.gz: 23577023127b68cbaf1ec89b78a0290f6fcd524f03fa44ec8ae6904d60e7a467
3
+ metadata.gz: ac0671db4d33ba215dc786dfcf3041729065a45e2960a5fb1c348640f512230b
4
+ data.tar.gz: 3f9a4d3f7ed75a0449205ff59bef8060cd6d6446c32a42dfb181a2f7a6a0ac67
5
5
  SHA512:
6
- metadata.gz: 8721b06b947fa709765e2937b65105174fd5652ff1c70c8bb499f2aab1ce9e27a55d31b531455af6a6abe8eb170d474c130b7e35f9cd09a112244ac78045d10f
7
- data.tar.gz: 3f46b454fbad88cf7550fe72e9d28a249f13b43559de74a53d9d65701eb68764a528e983ed8c2f27c5a85717b222a2e827920bd71749f42983013c83a17adecc
6
+ metadata.gz: 7ae9fb46c1f3b21ab8d099db4927056ad659bd2ad1fcd7ea92c3d9219416cac4092a86ea9dafb97982374b8608283a845616ed1a7290d0e06ce5d524748230ae
7
+ data.tar.gz: a0a4ea2292663121f72417012fe320a02cf5d71b5a4bb0215d922469761dc245ec90938b6c1498bd53ddf12d65717afe6fe71815ce4918bbaa25679fbf290f51
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple-datatable.gemspec
4
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Datatable
1
+ # Simple Datatable
2
2
  [![GitHub version](https://badge.fury.io/gh/apptec-cl%2Fdatatable.svg)](https://badge.fury.io/gh/apptec-cl%2Fdatatable)
3
3
 
4
4
  ## Description
@@ -73,4 +73,4 @@ Automatically we are created a folder with the structure of the tables ```app/d
73
73
  2. Create your feature branch (`git checkout -b my-new-feature`)
74
74
  3. Commit your changes (`git commit -am 'Add some feature'`)
75
75
  4. Push to the branch (`git push origin my-new-feature`)
76
- 5. Create a new Pull Request
76
+ 5. Create a new Pull Request
@@ -4,7 +4,7 @@ module Datatable
4
4
 
5
5
  def initialize(name)
6
6
  @name = name
7
- @dirname = 'datatables'
7
+ @dirname = 'app/datatables'
8
8
  end
9
9
 
10
10
  def up
@@ -27,17 +27,24 @@ module Datatable
27
27
  def create_principal
28
28
  result = generate_template('application_datatable.erb')
29
29
  puts result
30
- File.open("datatables/application_datatable.rb", 'w') { |file| file.write(result) }
30
+ File.open("#{@dirname}/application_datatable.rb", 'w') { |file| file.write(result) }
31
31
  puts "Created principal class application_datatable.rb"
32
32
  end
33
33
 
34
34
  def create_file
35
35
  result = generate_template('template_datatable.erb')
36
36
  puts result
37
- File.open("datatables/#{@name.downcase}_datatable.rb", 'w') { |file| file.write(result) }
37
+ File.open("#{@dirname}/#{@name.downcase}_datatable.rb", 'w') { |file| file.write(result) }
38
38
  puts "Created new file #{@name}_datatable.rb in folder datatables"
39
39
  end
40
40
 
41
+ def copy_datatable_js
42
+ result = generate_template('datatable.coffee')
43
+ puts result
44
+ File.open("app/assets/stylesheets/datatable.coffee", 'w') { |file| file.write(result) }
45
+ puts "Created new file datatable.coffee in folder :app/assets/stylesheets/"
46
+ end
47
+
41
48
  def generate_template name_template
42
49
  ERB.new(File.read("#{templates}/#{name_template}"), nil, '-').result(binding)
43
50
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = %q{simple-datatable}
3
- spec.version = "0.0.1"
3
+ spec.version = "0.0.2"
4
4
  spec.date = %q{2019-11-24}
5
5
  spec.summary = %q{awesome_gem is the best datatable Rails Gem}
6
6
  spec.authors = ["DevTeam AppTec"]
@@ -9,10 +9,11 @@ Gem::Specification.new do |spec|
9
9
  spec.homepage = "https://github.com/apptec-cl/simple-datatable"
10
10
  spec.license = "MIT"
11
11
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
12
- spec.bindir = "exe"
12
+ spec.bindir = 'exe'
13
13
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
- spec.require_paths = ["lib", "templates"]
15
- spec.add_development_dependency "bundler", "~> 1.7"
16
- spec.add_development_dependency "rake", "~> 10.0"
14
+ spec.require_paths = ['lib', 'templates']
15
+ spec.add_development_dependency 'bundler', '~> 1.7'
16
+ spec.add_development_dependency 'rake', '~> 10.0'
17
17
  spec.add_development_dependency 'rspec'
18
+ spec.add_development_dependency 'will_paginate', '~> 3.1.0'
18
19
  end
@@ -1,2 +1,5 @@
1
+ require 'datatable'
2
+ require 'datatable/application'
3
+
1
4
  class ApplicationDatatable < Datatable::Application
2
5
  end
@@ -0,0 +1,79 @@
1
+ document.addEventListener 'turbolinks:load', ->
2
+ $('.filter-datatable-tabs').on 'click', ->
3
+ filter = $(this).data('id')
4
+ table = $(this).closest('.datatable-container').find('.datatable_table')
5
+ if table.find('.status_cell').length > 0
6
+ position = table.find('.status_cell').prop('cellIndex')
7
+ #table.DataTable().ajax.reload
8
+ table.DataTable().column( position ).search( filter ).draw()
9
+ if table.find('.fee_status').length > 0
10
+ #table.DataTable().ajax.reload
11
+ table.DataTable().column(0).search( filter ).draw()
12
+ if $('.datatable_table').length > 0
13
+ $('.datatable_table').each () ->
14
+ if !$.fn.DataTable.isDataTable( "#"+$(this).prop("id") )
15
+ set_datatable($(this))
16
+ set_datatable = (data)->
17
+ if !$.fn.DataTable.isDataTable( "#"+data.prop("id") )
18
+ table = $("#"+data.prop("id"))
19
+ datatable_table = table.DataTable({
20
+ pagingType: "full_numbers"
21
+ processing: true
22
+ stateSave: true
23
+ serverSide: true
24
+ responsive: true
25
+ ajax:
26
+ url: table.data('source')
27
+ type: 'GET'
28
+ language:
29
+ 'sProcessing': 'Procesando...'
30
+ 'sLengthMenu': 'Mostrar _MENU_ registros'
31
+ 'sZeroRecords': 'No se encontraron resultados'
32
+ 'sEmptyTable': 'Ningún dato disponible en esta tabla'
33
+ 'sInfo': 'Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros'
34
+ 'sInfoEmpty': 'Mostrando registros del 0 al 0 de un total de 0 registros'
35
+ 'sInfoFiltered': ''
36
+ 'sInfoPostFix': ''
37
+ 'sSearch': 'Buscar:'
38
+ 'sUrl': ''
39
+ 'sInfoThousands': ','
40
+ 'sLoadingRecords': 'Cargando...'
41
+ 'oPaginate':
42
+ 'sFirst': 'Primero'
43
+ 'sLast': 'Último'
44
+ 'sNext': 'Siguiente'
45
+ 'sPrevious': 'Anterior'
46
+ 'oAria':
47
+ 'sSortAscending': ': Activar para ordenar la columna de manera ascendente'
48
+ 'sSortDescending': ': Activar para ordenar la columna de manera descendente'
49
+ })
50
+ switch(data.prop("id"))
51
+ when "customer_datatable"
52
+ yadcf.init(datatable_table, [
53
+ {
54
+ column_number: 0
55
+ filter_type: "text"
56
+ filter_default_label: "Escribir Nombre"
57
+ filter_container_id: "filter_1"
58
+ }
59
+ {
60
+ column_number: 1
61
+ filter_type: "text"
62
+ filter_default_label: "Escribir RUT"
63
+ filter_container_id: "filter_2"
64
+ }
65
+ {
66
+ column_number: 2
67
+ filter_type: "none"
68
+ filter_container_id: "filter_3"
69
+ }
70
+ ])
71
+ filter = table.closest('.datatable-container').find('.filter-datatable-tabs').first().data('id')
72
+ position = table.find('.status_cell').prop('cellIndex')
73
+ if filter
74
+ datatable_table.column( position ).search( filter ).draw()
75
+ document.addEventListener "turbolinks:before-cache", ->
76
+ if $('.datatable_table').length > 0
77
+ $('.datatable_table').each () ->
78
+ datatable = $("#"+$(this).prop("id")).DataTable()
79
+ datatable.destroy()
@@ -1,4 +1,4 @@
1
- class <%= @name.capitalize %>_Datatable < ApplicationDatatable
1
+ class <%= @name.capitalize %>Datatable < ApplicationDatatable
2
2
  private
3
3
  def data
4
4
  dimension.map do |dimension|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-datatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DevTeam AppTec
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: will_paginate
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
55
69
  description:
56
70
  email:
57
71
  - soporte@apptec.cl
@@ -60,6 +74,7 @@ executables:
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
77
+ - Gemfile
63
78
  - README.md
64
79
  - exe/datatable
65
80
  - lib/datatable.rb
@@ -68,6 +83,7 @@ files:
68
83
  - lib/datatable/runner.rb
69
84
  - simple-datatable.gemspec
70
85
  - templates/application_datatable.erb
86
+ - templates/datatable.coffee
71
87
  - templates/template_datatable.erb
72
88
  homepage: https://github.com/apptec-cl/simple-datatable
73
89
  licenses: