administrate-field-csv 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +199 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +12 -0
- data/administrate-field-csv.gemspec +31 -0
- data/app/assets/stylesheets/administrate-field-csv/application.css +5 -0
- data/app/views/fields/csv/_field.html.erb +9 -0
- data/app/views/fields/csv/_form.html.erb +6 -0
- data/app/views/fields/csv/_index.html.erb +1 -0
- data/app/views/fields/csv/_show.html.erb +32 -0
- data/bitbucket-pipelines.yml +28 -0
- data/lib/administrate/field/csv.rb +64 -0
- data/vendor/assets/stylesheets/csv_field.scss +29 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4d0bc12f55975b3d35da5912592c74e8c1b404b4fbed86673a11e089adea35ae
|
|
4
|
+
data.tar.gz: c33ae11bc894d7ab91eadfdac5f0c311f233c782f75c25bd839982ce8e5ffbad
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a5c31d011e7c071a15691fb327068ca3ae5018fb166575070dd567e1c111ac77d8ac8db8c155f3531ea5fc11ed6fdfdfbf78e8757a5a49e6df0f1ca32843c4d0
|
|
7
|
+
data.tar.gz: bb83b65f4aa379d78223a74b862122f536247bfe801448599505a9339e5b7add408bcfd220f7571f1ce697d51774d4c69cf5f1f41b78c14e0b4dbb82ab7bf376
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
administrate-field-csv (0.1.0)
|
|
5
|
+
administrate (< 1.0.0)
|
|
6
|
+
rails (>= 4.2)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actioncable (7.0.4.2)
|
|
12
|
+
actionpack (= 7.0.4.2)
|
|
13
|
+
activesupport (= 7.0.4.2)
|
|
14
|
+
nio4r (~> 2.0)
|
|
15
|
+
websocket-driver (>= 0.6.1)
|
|
16
|
+
actionmailbox (7.0.4.2)
|
|
17
|
+
actionpack (= 7.0.4.2)
|
|
18
|
+
activejob (= 7.0.4.2)
|
|
19
|
+
activerecord (= 7.0.4.2)
|
|
20
|
+
activestorage (= 7.0.4.2)
|
|
21
|
+
activesupport (= 7.0.4.2)
|
|
22
|
+
mail (>= 2.7.1)
|
|
23
|
+
net-imap
|
|
24
|
+
net-pop
|
|
25
|
+
net-smtp
|
|
26
|
+
actionmailer (7.0.4.2)
|
|
27
|
+
actionpack (= 7.0.4.2)
|
|
28
|
+
actionview (= 7.0.4.2)
|
|
29
|
+
activejob (= 7.0.4.2)
|
|
30
|
+
activesupport (= 7.0.4.2)
|
|
31
|
+
mail (~> 2.5, >= 2.5.4)
|
|
32
|
+
net-imap
|
|
33
|
+
net-pop
|
|
34
|
+
net-smtp
|
|
35
|
+
rails-dom-testing (~> 2.0)
|
|
36
|
+
actionpack (7.0.4.2)
|
|
37
|
+
actionview (= 7.0.4.2)
|
|
38
|
+
activesupport (= 7.0.4.2)
|
|
39
|
+
rack (~> 2.0, >= 2.2.0)
|
|
40
|
+
rack-test (>= 0.6.3)
|
|
41
|
+
rails-dom-testing (~> 2.0)
|
|
42
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
43
|
+
actiontext (7.0.4.2)
|
|
44
|
+
actionpack (= 7.0.4.2)
|
|
45
|
+
activerecord (= 7.0.4.2)
|
|
46
|
+
activestorage (= 7.0.4.2)
|
|
47
|
+
activesupport (= 7.0.4.2)
|
|
48
|
+
globalid (>= 0.6.0)
|
|
49
|
+
nokogiri (>= 1.8.5)
|
|
50
|
+
actionview (7.0.4.2)
|
|
51
|
+
activesupport (= 7.0.4.2)
|
|
52
|
+
builder (~> 3.1)
|
|
53
|
+
erubi (~> 1.4)
|
|
54
|
+
rails-dom-testing (~> 2.0)
|
|
55
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
56
|
+
activejob (7.0.4.2)
|
|
57
|
+
activesupport (= 7.0.4.2)
|
|
58
|
+
globalid (>= 0.3.6)
|
|
59
|
+
activemodel (7.0.4.2)
|
|
60
|
+
activesupport (= 7.0.4.2)
|
|
61
|
+
activerecord (7.0.4.2)
|
|
62
|
+
activemodel (= 7.0.4.2)
|
|
63
|
+
activesupport (= 7.0.4.2)
|
|
64
|
+
activestorage (7.0.4.2)
|
|
65
|
+
actionpack (= 7.0.4.2)
|
|
66
|
+
activejob (= 7.0.4.2)
|
|
67
|
+
activerecord (= 7.0.4.2)
|
|
68
|
+
activesupport (= 7.0.4.2)
|
|
69
|
+
marcel (~> 1.0)
|
|
70
|
+
mini_mime (>= 1.1.0)
|
|
71
|
+
activesupport (7.0.4.2)
|
|
72
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
73
|
+
i18n (>= 1.6, < 2)
|
|
74
|
+
minitest (>= 5.1)
|
|
75
|
+
tzinfo (~> 2.0)
|
|
76
|
+
administrate (0.18.0)
|
|
77
|
+
actionpack (>= 5.0)
|
|
78
|
+
actionview (>= 5.0)
|
|
79
|
+
activerecord (>= 5.0)
|
|
80
|
+
jquery-rails (>= 4.0)
|
|
81
|
+
kaminari (>= 1.0)
|
|
82
|
+
sassc-rails (~> 2.1)
|
|
83
|
+
selectize-rails (~> 0.6)
|
|
84
|
+
builder (3.2.4)
|
|
85
|
+
concurrent-ruby (1.2.0)
|
|
86
|
+
crass (1.0.6)
|
|
87
|
+
date (3.3.3)
|
|
88
|
+
erubi (1.12.0)
|
|
89
|
+
ffi (1.15.5)
|
|
90
|
+
globalid (1.1.0)
|
|
91
|
+
activesupport (>= 5.0)
|
|
92
|
+
i18n (1.12.0)
|
|
93
|
+
concurrent-ruby (~> 1.0)
|
|
94
|
+
jquery-rails (4.5.1)
|
|
95
|
+
rails-dom-testing (>= 1, < 3)
|
|
96
|
+
railties (>= 4.2.0)
|
|
97
|
+
thor (>= 0.14, < 2.0)
|
|
98
|
+
kaminari (1.2.2)
|
|
99
|
+
activesupport (>= 4.1.0)
|
|
100
|
+
kaminari-actionview (= 1.2.2)
|
|
101
|
+
kaminari-activerecord (= 1.2.2)
|
|
102
|
+
kaminari-core (= 1.2.2)
|
|
103
|
+
kaminari-actionview (1.2.2)
|
|
104
|
+
actionview
|
|
105
|
+
kaminari-core (= 1.2.2)
|
|
106
|
+
kaminari-activerecord (1.2.2)
|
|
107
|
+
activerecord
|
|
108
|
+
kaminari-core (= 1.2.2)
|
|
109
|
+
kaminari-core (1.2.2)
|
|
110
|
+
loofah (2.19.1)
|
|
111
|
+
crass (~> 1.0.2)
|
|
112
|
+
nokogiri (>= 1.5.9)
|
|
113
|
+
mail (2.8.1)
|
|
114
|
+
mini_mime (>= 0.1.1)
|
|
115
|
+
net-imap
|
|
116
|
+
net-pop
|
|
117
|
+
net-smtp
|
|
118
|
+
marcel (1.0.2)
|
|
119
|
+
method_source (1.0.0)
|
|
120
|
+
mini_mime (1.1.2)
|
|
121
|
+
minitest (5.17.0)
|
|
122
|
+
net-imap (0.3.4)
|
|
123
|
+
date
|
|
124
|
+
net-protocol
|
|
125
|
+
net-pop (0.1.2)
|
|
126
|
+
net-protocol
|
|
127
|
+
net-protocol (0.2.1)
|
|
128
|
+
timeout
|
|
129
|
+
net-smtp (0.3.3)
|
|
130
|
+
net-protocol
|
|
131
|
+
nio4r (2.5.8)
|
|
132
|
+
nokogiri (1.14.1-x86_64-darwin)
|
|
133
|
+
racc (~> 1.4)
|
|
134
|
+
racc (1.6.2)
|
|
135
|
+
rack (2.2.6.2)
|
|
136
|
+
rack-test (2.0.2)
|
|
137
|
+
rack (>= 1.3)
|
|
138
|
+
rails (7.0.4.2)
|
|
139
|
+
actioncable (= 7.0.4.2)
|
|
140
|
+
actionmailbox (= 7.0.4.2)
|
|
141
|
+
actionmailer (= 7.0.4.2)
|
|
142
|
+
actionpack (= 7.0.4.2)
|
|
143
|
+
actiontext (= 7.0.4.2)
|
|
144
|
+
actionview (= 7.0.4.2)
|
|
145
|
+
activejob (= 7.0.4.2)
|
|
146
|
+
activemodel (= 7.0.4.2)
|
|
147
|
+
activerecord (= 7.0.4.2)
|
|
148
|
+
activestorage (= 7.0.4.2)
|
|
149
|
+
activesupport (= 7.0.4.2)
|
|
150
|
+
bundler (>= 1.15.0)
|
|
151
|
+
railties (= 7.0.4.2)
|
|
152
|
+
rails-dom-testing (2.0.3)
|
|
153
|
+
activesupport (>= 4.2.0)
|
|
154
|
+
nokogiri (>= 1.6)
|
|
155
|
+
rails-html-sanitizer (1.5.0)
|
|
156
|
+
loofah (~> 2.19, >= 2.19.1)
|
|
157
|
+
railties (7.0.4.2)
|
|
158
|
+
actionpack (= 7.0.4.2)
|
|
159
|
+
activesupport (= 7.0.4.2)
|
|
160
|
+
method_source
|
|
161
|
+
rake (>= 12.2)
|
|
162
|
+
thor (~> 1.0)
|
|
163
|
+
zeitwerk (~> 2.5)
|
|
164
|
+
rake (13.0.6)
|
|
165
|
+
sassc (2.4.0)
|
|
166
|
+
ffi (~> 1.9)
|
|
167
|
+
sassc-rails (2.1.2)
|
|
168
|
+
railties (>= 4.0.0)
|
|
169
|
+
sassc (>= 2.0)
|
|
170
|
+
sprockets (> 3.0)
|
|
171
|
+
sprockets-rails
|
|
172
|
+
tilt
|
|
173
|
+
selectize-rails (0.12.6)
|
|
174
|
+
sprockets (4.2.0)
|
|
175
|
+
concurrent-ruby (~> 1.0)
|
|
176
|
+
rack (>= 2.2.4, < 4)
|
|
177
|
+
sprockets-rails (3.4.2)
|
|
178
|
+
actionpack (>= 5.2)
|
|
179
|
+
activesupport (>= 5.2)
|
|
180
|
+
sprockets (>= 3.0.0)
|
|
181
|
+
thor (1.2.1)
|
|
182
|
+
tilt (2.0.11)
|
|
183
|
+
timeout (0.3.1)
|
|
184
|
+
tzinfo (2.0.6)
|
|
185
|
+
concurrent-ruby (~> 1.0)
|
|
186
|
+
websocket-driver (0.7.5)
|
|
187
|
+
websocket-extensions (>= 0.1.0)
|
|
188
|
+
websocket-extensions (0.1.5)
|
|
189
|
+
zeitwerk (2.6.6)
|
|
190
|
+
|
|
191
|
+
PLATFORMS
|
|
192
|
+
x86_64-darwin-20
|
|
193
|
+
|
|
194
|
+
DEPENDENCIES
|
|
195
|
+
administrate-field-csv!
|
|
196
|
+
minitest (~> 5.0)
|
|
197
|
+
|
|
198
|
+
BUNDLED WITH
|
|
199
|
+
2.3.5
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 James Stubblefield
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Administrate::Field::CSV
|
|
2
|
+
|
|
3
|
+
A custom [Administrate](https://github.com/thoughtbot/administrate) field to present Strings with CSV content in a table format on you show views.
|
|
4
|
+
This field uses truncated text for index views, and a text area for form views.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'administrate-field-csv'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle install
|
|
17
|
+
|
|
18
|
+
Add the below to your `app/assets/config/manifest.js` if your administrate configuration is using the asset pipeline.
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
//= link administrate-field-csv/application.css
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
ATTRIBUTE_TYPES = {
|
|
28
|
+
# ...
|
|
29
|
+
csv_text: Field::CSV.with_options(
|
|
30
|
+
headers: true,
|
|
31
|
+
col_sep: ',',
|
|
32
|
+
row_sep: "\r\n",
|
|
33
|
+
quote_char: '"',
|
|
34
|
+
return_headers: false,
|
|
35
|
+
truncate: 50,
|
|
36
|
+
blank_sign: "--"
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
All possible options for the field are shown above along with their default values. Refer to the ruby CSV documentation for details around the possible values for `headers`, `col_sep`, `row_sep`, `quote_char` and `return_headers`.
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
46
|
+
|
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `administrate-field-csv.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
Bug reports and pull requests are welcome on Bitbucket at [https://bitbucket.org/eightbitdevelopers/administrate-field-csv](https://bitbucket.org/eightbitdevelopers/administrate-field-csv).
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Gem::Specification.new do |spec|
|
|
2
|
+
spec.name = "administrate-field-csv"
|
|
3
|
+
spec.version = "0.1.0"
|
|
4
|
+
spec.authors = ["James Stubblefield"]
|
|
5
|
+
spec.email = ["james@eightbitstudios.com"]
|
|
6
|
+
|
|
7
|
+
spec.summary = "CSV field plugin for Administrate"
|
|
8
|
+
spec.description = spec.summary
|
|
9
|
+
spec.homepage = "https://bitbucket.org/eightbitdevelopers/administrate-field-csv"
|
|
10
|
+
spec.license = "MIT"
|
|
11
|
+
|
|
12
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
13
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
14
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/src/master/CHANGELOG.md"
|
|
15
|
+
|
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
18
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
19
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
20
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
spec.bindir = "exe"
|
|
24
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
|
+
|
|
27
|
+
spec.add_runtime_dependency "administrate", "< 1.0.0"
|
|
28
|
+
spec.add_runtime_dependency "rails", ">= 4.2"
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
31
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= field.truncate %>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<% if field.transform %>
|
|
2
|
+
<table class="csvtable">
|
|
3
|
+
<% if field.headers.any? %>
|
|
4
|
+
<thead>
|
|
5
|
+
<tr>
|
|
6
|
+
<% field.headers.each do |header| %>
|
|
7
|
+
<th class="cell-label"><%= header %></th>
|
|
8
|
+
<% end %>
|
|
9
|
+
</tr>
|
|
10
|
+
</thead>
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
13
|
+
<tbody>
|
|
14
|
+
<% field.transform.each do |row| %>
|
|
15
|
+
<tr>
|
|
16
|
+
<% row.each do |k,v| %>
|
|
17
|
+
<td class="cell-data cell-data--string">
|
|
18
|
+
<% if field.has_headers? %>
|
|
19
|
+
<%= v %>
|
|
20
|
+
<% else %>
|
|
21
|
+
<%= k %>
|
|
22
|
+
<% end %>
|
|
23
|
+
</td>
|
|
24
|
+
<% end %>
|
|
25
|
+
</tr>
|
|
26
|
+
<% end %>
|
|
27
|
+
</tbody>
|
|
28
|
+
</table>
|
|
29
|
+
|
|
30
|
+
<% else %>
|
|
31
|
+
<%= field.blank_sign %>
|
|
32
|
+
<% end %>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This is a sample build configuration for Ruby.
|
|
2
|
+
# Check our guides at https://confluence.atlassian.com/x/8r-5Mw for more examples.
|
|
3
|
+
# Only use spaces to indent your .yml configuration.
|
|
4
|
+
# -----
|
|
5
|
+
# You can specify a custom docker image from Docker Hub as your build environment.
|
|
6
|
+
image: ruby:3.1.2
|
|
7
|
+
|
|
8
|
+
definitions:
|
|
9
|
+
caches:
|
|
10
|
+
bundler: ./vendor
|
|
11
|
+
assets: tmp/cache/assets
|
|
12
|
+
steps:
|
|
13
|
+
- step: &build-and-test
|
|
14
|
+
name: Unit tests
|
|
15
|
+
caches:
|
|
16
|
+
- bundler
|
|
17
|
+
- assets
|
|
18
|
+
script:
|
|
19
|
+
- gem update --system
|
|
20
|
+
- gem install bundler -v 2.2.7
|
|
21
|
+
- bundle config set --local path 'vendor'
|
|
22
|
+
- bundle install
|
|
23
|
+
- bundle exec rake test
|
|
24
|
+
|
|
25
|
+
pipelines:
|
|
26
|
+
pull-requests:
|
|
27
|
+
'**':
|
|
28
|
+
- step: *build-and-test
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
require 'administrate/engine'
|
|
3
|
+
require 'administrate/field/text'
|
|
4
|
+
require 'csv'
|
|
5
|
+
|
|
6
|
+
module Administrate
|
|
7
|
+
module Field
|
|
8
|
+
class CSV < Administrate::Field::Base
|
|
9
|
+
|
|
10
|
+
def transform
|
|
11
|
+
return nil if data.blank?
|
|
12
|
+
|
|
13
|
+
@transform ||= ::CSV.new(data, **csv_args)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def rewind
|
|
17
|
+
return nil if data.blank?
|
|
18
|
+
|
|
19
|
+
transform.rewind
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def headers
|
|
23
|
+
return [] unless has_headers?
|
|
24
|
+
|
|
25
|
+
rewind
|
|
26
|
+
@headers ||= transform.first&.headers || []
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def has_headers?
|
|
30
|
+
options[:headers] == true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_partial_path(partial = page)
|
|
34
|
+
"/fields/csv/#{partial}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def blank_sign
|
|
38
|
+
options[:blank_sign] || '-'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def truncate
|
|
42
|
+
data.to_s.truncate(truncation_length)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def truncation_length
|
|
48
|
+
options.fetch(:truncate, 50)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def csv_args
|
|
52
|
+
args = %i[col_sep row_sep quote_char headers return_headers]
|
|
53
|
+
args.inject({}) { |res, arg| res.merge arg => options[arg] }.compact
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class Engine < ::Rails::Engine
|
|
57
|
+
Administrate::Engine.add_stylesheet 'administrate-field-csv/application'
|
|
58
|
+
engine_root = root
|
|
59
|
+
isolate_namespace Administrate
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.attribute-data--csv {
|
|
2
|
+
max-width: 100%;
|
|
3
|
+
max-height: 350px;
|
|
4
|
+
overflow: scroll;
|
|
5
|
+
word-break: normal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
table.csvtable {
|
|
9
|
+
width: 100%;
|
|
10
|
+
|
|
11
|
+
thead {
|
|
12
|
+
border-collapse: separate;
|
|
13
|
+
|
|
14
|
+
tr {
|
|
15
|
+
position: sticky;
|
|
16
|
+
top: 0;
|
|
17
|
+
border: none;
|
|
18
|
+
|
|
19
|
+
th {
|
|
20
|
+
background-color: #f6f7f7;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
padding-top: 0.7rem;
|
|
23
|
+
box-shadow: inset 0 1px 0 #dfe0e1, inset 0 -1px 0 #dfe0e1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: administrate-field-csv
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- James Stubblefield
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: administrate
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "<"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 1.0.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "<"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 1.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '4.2'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '4.2'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
description: CSV field plugin for Administrate
|
|
56
|
+
email:
|
|
57
|
+
- james@eightbitstudios.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- CHANGELOG.md
|
|
63
|
+
- Gemfile
|
|
64
|
+
- Gemfile.lock
|
|
65
|
+
- LICENSE.txt
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- administrate-field-csv.gemspec
|
|
69
|
+
- app/assets/stylesheets/administrate-field-csv/application.css
|
|
70
|
+
- app/views/fields/csv/_field.html.erb
|
|
71
|
+
- app/views/fields/csv/_form.html.erb
|
|
72
|
+
- app/views/fields/csv/_index.html.erb
|
|
73
|
+
- app/views/fields/csv/_show.html.erb
|
|
74
|
+
- bitbucket-pipelines.yml
|
|
75
|
+
- lib/administrate/field/csv.rb
|
|
76
|
+
- vendor/assets/stylesheets/csv_field.scss
|
|
77
|
+
homepage: https://bitbucket.org/eightbitdevelopers/administrate-field-csv
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
metadata:
|
|
81
|
+
homepage_uri: https://bitbucket.org/eightbitdevelopers/administrate-field-csv
|
|
82
|
+
source_code_uri: https://bitbucket.org/eightbitdevelopers/administrate-field-csv
|
|
83
|
+
changelog_uri: https://bitbucket.org/eightbitdevelopers/administrate-field-csv/src/master/CHANGELOG.md
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
98
|
+
requirements: []
|
|
99
|
+
rubygems_version: 3.3.3
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: CSV field plugin for Administrate
|
|
103
|
+
test_files: []
|