simple-datatable 0.0.4 → 0.0.5

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: ac634866e44a749fdf82120c334ba9cc615347bf1efa00b5ca029cc9266a9f40
4
- data.tar.gz: 9ccf944a3df32336426c263a6e60fef057ffb172c02a383202ec7218e8bc71e3
3
+ metadata.gz: 3ae017add1485f1d27addbb38987d6248ebdf6b3f34300ca4eec66b67cce04fe
4
+ data.tar.gz: b15f26ee3c907bb0c9018749d4783864dbb7fafbef006ce652819292cc509644
5
5
  SHA512:
6
- metadata.gz: 48d3867149fcbaa342c8a541f39c93c558996db05e91f7706d3a93c751e38a525251692474454701bdf9dbbb6c69b5a39996e76a7eab2ef8edeffb78e72d06f0
7
- data.tar.gz: b14831cb95f6ba8622d29a99db187b618e8482bc5165aa064df149e269ea348cd68c743e3dedfbc9bc2d405e4f8e9bd2e66a774c6de59a415cff321fc194067e
6
+ metadata.gz: d841027417996a1b12e8bcff666b66a77694b20c532a92797b52017409f34594914aed6883a069cea143ca697ff0e4ebe43b9c7cc3ea17c7769edb702681c223
7
+ data.tar.gz: 9522b5a65d164bfbebcc1dcdb4b2167238bea34743fbfd782ed03348771a62a4a8107a502ddd0121071eade82ed39aec2fa3d45fb4d1ff3ca82320be9890718d
data/README.md CHANGED
@@ -50,20 +50,83 @@ in your file ```application.js```
50
50
  add gem
51
51
 
52
52
  ```
53
- gem 'datatable', :git => 'git@github.com:apptec-cl/datatable.git'
53
+ gem 'simple-datatable'
54
54
 
55
55
  ```
56
56
 
57
- Generate model with structure datatables, open your terminal and write:
57
+ It also depends on:
58
+
58
59
 
59
60
  ```
60
- $ datatable g model_name
61
+ gem 'will_paginate', '~> 3.1.0'
62
+
61
63
  ```
62
64
 
63
65
  Automatically we are created a folder with the structure of the tables ```app/datatables```.
64
66
 
65
67
  ## Usage
66
68
 
69
+
70
+ Generate model with structure datatables, open your terminal and write:
71
+
72
+ ```
73
+ $ datatable g model_name
74
+ ```
75
+
76
+
77
+ Example Controller:
78
+
79
+ ```
80
+ # Query with data
81
+ @clients = Client.all
82
+
83
+ # Format table
84
+ data = %w[clients.id clients.name clients.lastname clients.address]
85
+ respond_to do |format|
86
+ format.html
87
+ format.json { render json: ClientsDatatable.new(view_context, @clients, data) }
88
+ end
89
+
90
+ ```
91
+
92
+ View:
93
+
94
+ ```
95
+ <table id="datatable" class="table datatable_table table-hover" role="grid" data-source="<%= clients_path(format: :json) %>" cellspacing="0">
96
+ <thead>
97
+ <tr>
98
+ <th>ID</th>
99
+ <th>Name</th>
100
+ <th>Last Name</th>
101
+ <th>Address</th>
102
+ </tr>
103
+ </thead>
104
+
105
+ <tbody>
106
+ <!-- leave blank -->
107
+ </tbody>
108
+ </table>
109
+ ```
110
+
111
+ Folder datatable:
112
+
113
+ ```
114
+ class ClientsDatatable < ApplicationDatatable
115
+ private
116
+ def data
117
+ dimension.map do |dimension|
118
+ [
119
+ # Add your attributes
120
+ dimension.id,
121
+ dimension.name,
122
+ dimension.lastname,
123
+ dimension.address,
124
+ ]
125
+ end
126
+ end
127
+ end
128
+ ```
129
+
67
130
  ### Quickstart
68
131
 
69
132
 
@@ -4,6 +4,8 @@ module Datatable
4
4
  include Rails.application.routes.url_helpers
5
5
  include ActionView::Helpers::TagHelper
6
6
  include ActionView::Helpers::NumberHelper
7
+ include ActionView::Helpers::SanitizeHelper
8
+
7
9
  delegate :params, :h, :link_to, :image_tag, :current_user, to: :@view
8
10
 
9
11
  def initialize(view, model, items, order_items=nil, pre_filter=false, filter='')
@@ -22,7 +24,7 @@ module Datatable
22
24
  sEcho: params[:draw].to_i,
23
25
  iTotalRecords: @model.count,
24
26
  iTotalDisplayRecords: dimension.total_entries,
25
- aaData: data
27
+ aaData: sanitize_data(data)
26
28
  }
27
29
  end
28
30
 
@@ -95,5 +97,15 @@ module Datatable
95
97
  asset = asset.get_asset
96
98
  end
97
99
 
100
+ def sanitize_data data
101
+ # sanitize data, when the persistent (or stored) Cross-site scripting vulnerability
102
+ data.each do |row|
103
+ row.each_with_index do |attribute, index|
104
+ row[index] = sanitize(row[index]) if row[index].is_a? String
105
+ end
106
+ end
107
+ data
108
+ end
109
+
98
110
  end
99
111
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = %q{simple-datatable}
3
- spec.version = "0.0.4"
3
+ spec.version = "0.0.5"
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"]
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DevTeam AppTec