easy_data_tables 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -2
- data/app/models/easy_data_tables/custom_column.rb +28 -0
- data/app/models/easy_data_tables/data_table.rb +4 -1
- data/lib/easy_data_tables/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5627113db6291d15f2cd3c24e60d9f8fbdc4fd010fcb98fb78a41d4f583a353f
|
4
|
+
data.tar.gz: be1c52504a7902993e9468e0a410354314e83789e0e306e3973c2f94f2fb215d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8094df890508f7c882f8dda0908e4bc613fc55c7a0d803d2401c15630aec548c2dca733fb64eda4580d968037ee231b9c227de4a66a75dc490b0d11b6326544
|
7
|
+
data.tar.gz: 4627da4b54eeadf845010a3965db6d00096f3afa5466ff2e5c344730b4d5a0a4a2efd65fdd870e688157d977af85cb6ddd21ab4c85379c2f7ddb970e093f11c0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,7 +35,7 @@ to your `application.scss`
|
|
35
35
|
|
36
36
|
#### Columns
|
37
37
|
|
38
|
-
Columns are an array of hashes. There are
|
38
|
+
Columns are an array of hashes. There are three types of columns: 'normal', 'custom' and 'combined'
|
39
39
|
|
40
40
|
Normal column hashes accept the following keys:
|
41
41
|
|
@@ -46,6 +46,11 @@ Normal column hashes accept the following keys:
|
|
46
46
|
- **agregate_function**: Array of symbols OR symbol, **required** => aggregate function to run (e.g. [:average, :expense] OR :count)
|
47
47
|
- **column_type**: string => will inform the type of column to use
|
48
48
|
|
49
|
+
Custom column hashes accept the following keys:
|
50
|
+
- **label**: string, default: '' => will inform the label of the column on the table
|
51
|
+
- **values**: Hash, keys must coincide with the rows of the table, values are the content that will appear in each cell
|
52
|
+
- **column_type**: string => must be '**custom**'
|
53
|
+
|
49
54
|
Cobmbined column hashes accept the following keys:
|
50
55
|
|
51
56
|
- **label**: string, default: '' => will inform the label of the column on the table
|
@@ -156,4 +161,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
156
161
|
## Changelog
|
157
162
|
|
158
163
|
### v 0.2.0
|
159
|
-
- added possibility of downloading the table as a csv (both formated and unformated)
|
164
|
+
- added possibility of downloading the table as a csv (both formated and unformated)
|
165
|
+
|
166
|
+
### v 0.2.0
|
167
|
+
- added possibility of creating custom tables
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EasyDataTables
|
4
|
+
# column where each value is a custom column
|
5
|
+
class CustomColumn < Column
|
6
|
+
def initialize(args = {})
|
7
|
+
super(args)
|
8
|
+
@values = args[:values]
|
9
|
+
@partial = args[:partial] || ''
|
10
|
+
end
|
11
|
+
|
12
|
+
def formated_data_at(row)
|
13
|
+
@values[row]
|
14
|
+
end
|
15
|
+
|
16
|
+
def data_at(_row)
|
17
|
+
''
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def construct_values; end
|
23
|
+
|
24
|
+
def helpers
|
25
|
+
ActionController::Base.helpers
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -28,8 +28,11 @@ module EasyDataTables
|
|
28
28
|
|
29
29
|
def convert_columns(columns)
|
30
30
|
columns.map! do |col|
|
31
|
-
|
31
|
+
case col[:column_type]
|
32
|
+
when 'combined'
|
32
33
|
CombinedColumn.new(col)
|
34
|
+
when 'custom'
|
35
|
+
CustomColumn.new(col)
|
33
36
|
else
|
34
37
|
Column.new(col.merge(grouping: @grouping))
|
35
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_data_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Curell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create fast tables based on the models of your db
|
14
14
|
email:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- app/helpers/easy_data_tables/table_helper.rb
|
31
31
|
- app/models/easy_data_tables/column.rb
|
32
32
|
- app/models/easy_data_tables/combined_column.rb
|
33
|
+
- app/models/easy_data_tables/custom_column.rb
|
33
34
|
- app/models/easy_data_tables/data_table.rb
|
34
35
|
- app/views/easy_data_tables/_data_table.html.erb
|
35
36
|
- app/views/easy_data_tables/_download_links.html.erb
|