tramway-export 0.1.0.1 → 0.1.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: c8a28bffa99e723823389b97dc255132840d45082e6cd1983a76e2c28f678196
4
- data.tar.gz: 107fa809104440a7c3fb9528dbd21750b5e62fac72eba2da8bc1237c8df89202
3
+ metadata.gz: f81d260bc4a950883e9aa07590b826cd222c640d314bd2126032f95e2a0f2d90
4
+ data.tar.gz: f24f5e6c3ce21b57026ef7cfb92e700414151b311406bdfe79d78b5a8b6f5df0
5
5
  SHA512:
6
- metadata.gz: 2caa6491848f3f0398295f35d80f03d621b8ca02fab4b8847132ea63948fb4f571917391b694ca67dea210a0cf254217ada1e226f34362e59342b216eb7f489f
7
- data.tar.gz: 71e40c79c77e859c0d3848c26e76426116dae437e05147e5f19c53aa8a78d9e42a2866698c793283f7be2025dfb99aa3039b9f162af1d9425caa63b273f20111
6
+ metadata.gz: '095b3def7d0dff5635ff436b9ae49a2fca7c29846aa3adc944825ba968c83814cf3faca6fd63dddd373d5d6e383dc194ff12a10e4729e68d4705ef12192dfb6e'
7
+ data.tar.gz: f9a708408a6e9b37d2cb86272b6ecdc088d2f0e3031077384bfd45ed03ea4969cb4e69767272fcde2d621c59ecbc9ad1b5b4fa4575994cfa8a7caddfb13e5fc0
data/README.md CHANGED
@@ -1,26 +1,63 @@
1
1
  # Tramway::Export
2
- Short description and motivation.
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ Plugin for tramway-admin gem. Provides exporting collections to Excel files.
6
4
 
7
- ## Installation
8
- Add this line to your application's Gemfile:
5
+ ## Installation & Usage
6
+
7
+ #### 1. Add this line to your application's Gemfile:
9
8
 
10
9
  ```ruby
10
+ gem 'tramway-admin'
11
11
  gem 'tramway-export'
12
12
  ```
13
13
 
14
- And then execute:
14
+ ##### 2. And then execute:
15
15
  ```bash
16
16
  $ bundle
17
17
  ```
18
18
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install tramway-export
19
+ #### 3. Add exportable models to tramway initializer
20
+
21
+ *config/initializers/tramway.rb*
22
+
23
+ ```ruby
24
+ Tramway::Export.set_exportable_models YourModel, project: :your_project_name
22
25
  ```
23
26
 
27
+ #### 4. Create decorator that describes, how your model should be exported. You need to create exactly decorator name `app/decorators/#{your_model_name}_xlsx_decorator.rb`
28
+
29
+
30
+ *app/decorators/your_model_xlsx_decorator.rb*
31
+
32
+ ```ruby
33
+ class YourModelXlsxDecorator < Tramway::Export::Xlsx::ApplicationDecorator
34
+ class << self
35
+ def columns
36
+ %i[column1 column2 column3] # here array of strings or symbols with columns names. It'll be used as headers in Excel file
37
+ end
38
+
39
+ def filename
40
+ `your_file_name.xlsx`
41
+ end
42
+ end
43
+
44
+ def column1
45
+ # getting value
46
+ end
47
+
48
+ def column2
49
+ # getting value
50
+ end
51
+
52
+ def column3
53
+ # getting value
54
+ end
55
+ end
56
+ ```
57
+
58
+ #### 5. Restart your server and visit index page of models in your admin panel
59
+
60
+
24
61
  ## Contributing
25
62
  Contribution directions go here.
26
63
 
@@ -1,4 +1,4 @@
1
- - if Tramway::Export.exportable_model? model_class, project: @application_engine
1
+ - if Tramway::Export.exportable_model? model_class, project: (@application_engine || @application.name)
2
2
  - model_name = model_class.name.underscore
3
3
  - id = "export-#{model_name}"
4
4
  .btn-group{ role: :group }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Export
5
- VERSION = '0.1.0.1'
5
+ VERSION = '0.1.0.2'
6
6
  end
7
7
  end
@@ -13,6 +13,7 @@ module Tramway
13
13
 
14
14
  def exportable_model?(model_class, project:)
15
15
  return false unless project.present?
16
+
16
17
  @exportable_models[project.to_sym]&.include? model_class
17
18
  end
18
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-11 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xls_exporter