rails_pivot_table_js 0.0.1 → 0.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ab6610f8c40135924fe563109b12f548a2adb1
|
4
|
+
data.tar.gz: 974aeaa7542298afcbfbb3ff04ecd29a3be02c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf77f8ab5bed586c653d3b9383f85db46432664e1fc4d733ff02b650695bffabab2dff33f85935a8301c63fdbf18c519642a6653b68d6b0098c15e4e044eab2c
|
7
|
+
data.tar.gz: cf942ab1b33cc044e22166361f8ac8380dbbcdd689c15c14e78b8b1e3c6a9db63c07d4dcafd9016d714b79ae096018804c184471c09e873490586908eb46f68a
|
data/README.rdoc
CHANGED
@@ -1,3 +1,86 @@
|
|
1
|
-
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/rails_pivot_table_js.svg)](https://badge.fury.io/rb/rails_pivot_table_js)
|
2
2
|
|
3
|
-
|
3
|
+
# RailsPivotTableJs
|
4
|
+
|
5
|
+
The `rails_pivot_table_js` gem provides a helper to display a pivot_table using the open source pivot_table.js (http://nicolas.kruchten.com/pivottable/examples/)
|
6
|
+
|
7
|
+
## Features
|
8
|
+
* Encaplsulates all pivottable.js scripts and css
|
9
|
+
* provide a helper to display the pivot_table
|
10
|
+
* TODO: Saved Configs, scoped by contexts, to persist pivot configurations for tlater retrieval
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rails_pivot_table_js'
|
19
|
+
```
|
20
|
+
|
21
|
+
Execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install rails_pivot_table_js
|
28
|
+
|
29
|
+
|
30
|
+
For while we don't need to change this file.
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
First, in your model, genrate the desired data as annra of hashes, then convert it to JSON
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
def pivot_data
|
38
|
+
rows = []
|
39
|
+
self.documentos.each do |nfe|
|
40
|
+
rows << {
|
41
|
+
'Emitente' => nfe.estabelecimento.nome,
|
42
|
+
'Emitente CNPJ' => nfe.estabelecimento.cnpj,
|
43
|
+
'Mês Emissão' => nfe.nf_data_emissao.strftime('%y-%m'),
|
44
|
+
'Valor' => nfe.nf_valor
|
45
|
+
}
|
46
|
+
end
|
47
|
+
rows.to_json
|
48
|
+
end
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
In your controoler, define the data and defaul_config
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
@pivot_dara = cliente.pivot_data
|
56
|
+
@pivot_columns = {
|
57
|
+
cols: ['Emitente'],
|
58
|
+
rows: ['Mês Emissão']
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
62
|
+
In yout view, call the helper with the data
|
63
|
+
```ruby
|
64
|
+
%hr
|
65
|
+
%h3 Indicadores de Documentos Recebidos
|
66
|
+
= show_pivot_table @pivot_data, @pivot_columns
|
67
|
+
|
68
|
+
```
|
69
|
+
|
70
|
+
All done! Enjoy the pivot table!
|
71
|
+
|
72
|
+
|
73
|
+
## i18n Support
|
74
|
+
|
75
|
+
This gem was built using i18n translation supports, and has bult-in support for English (en) and Brazilian Portuguese (pt-BR). If you want to translate to your specific language, add a new locale file in your `config/locales` and translate the values to your language. You can get one of the locales of this project to make it easier to translate to your language.
|
76
|
+
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
1. Fork it ( https://github.com/davidbrusius/ransack_advanced_search/fork )
|
81
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
84
|
+
5. Create a new Pull Request
|
85
|
+
|
86
|
+
This project uses MIT-LICENSE.
|
@@ -10,4 +10,8 @@
|
|
10
10
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
|
-
//=
|
13
|
+
//= require rails_pivot_table_js/pivot
|
14
|
+
//= require rails_pivot_table_js/nrecopivottableext.js
|
15
|
+
//= require rails_pivot_table_js/gchart_renderers
|
16
|
+
//= require rails_pivot_table_js/d3_renderers
|
17
|
+
//= require rails_pivot_table_js/pivot.pt
|
@@ -29,14 +29,14 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
|
32
|
-
$(function(){
|
32
|
+
$(document).ready(function(){
|
33
33
|
|
34
34
|
var entregas = #{pivot_data};
|
35
35
|
|
36
36
|
//Suporte aos gráficos
|
37
37
|
//google.load("visualization", "1", {packages:["corechart", "charteditor"]});
|
38
38
|
var default_config = #{pivot_columns.to_json};
|
39
|
-
var last_config = JSON.parse(getCookie("
|
39
|
+
var last_config = JSON.parse(getCookie("pivot_config"));
|
40
40
|
var config = last_config || default_config;
|
41
41
|
config['onRefresh'] = pivotSaveConfig;
|
42
42
|
|