administrate-field-carrierwave 0.1.3 → 0.2.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: af36aa6b9abf53210f6f589bcd40f372a3277dbd
4
- data.tar.gz: 2bdca84c4a360a806e70ca1498553a6902b802c3
3
+ metadata.gz: 5d5d9d04c3c2b5ca77b2bb6123e1f1c5bf1f057e
4
+ data.tar.gz: e5950ce55632aa0d85d112bd5041b28d76848342
5
5
  SHA512:
6
- metadata.gz: 810b3b1caf26fa5f6b04b8c6eec5353fd1776ea8ba9b2796fb57efca2f12c3114c80ad79434b75aacc7f40b5c47523e9de570a960176c4d258cb673a41c52113
7
- data.tar.gz: 4896b07347a5870101a68cfaf8cff3f07948a93f298b4e87787fdd6331a5c305b4432432548310e1d616280c70ced01c64d190a539be130654fd7e14ff45e6f6
6
+ metadata.gz: 5bc3fbae7f728a7c6f4de8c737a5b2652979ba8f0e4e4fbb45da4dc3438f994ea3b16d9b5188ab4da717a0afdc329355b846c3894d67201b0909fbb3169aaf58
7
+ data.tar.gz: fd7184c9aa2439e8c7a425199434f4051a61a39dec826e34d88beaa2bf0da2b8bd139f1f521dddd3f97f0612bfa1a43984b543c3fc3e47e56fa8786562eb14e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.2.0](https://github.com/zooppa/administrate-field-carrierwave/tree/v0.2.0) (2017-06-06)
4
+ [Full Changelog](https://github.com/zooppa/administrate-field-carrierwave/compare/v0.1.3...v0.2.0)
5
+
6
+ * Add ability to show image on index
7
+
3
8
  ## [v0.1.3](https://github.com/zooppa/administrate-field-carrierwave/tree/v0.1.3) (2017-04-03)
4
9
  [Full Changelog](https://github.com/zooppa/administrate-field-carrierwave/compare/v0.1.2...v0.1.3)
5
10
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ A plugin to upload and preview Carrierwave attachments in [Administrate].
9
9
  Add it to your `Gemfile`:
10
10
 
11
11
  ```ruby
12
- gem 'administrate-field-carrierwave', '~> 0.1.3'
12
+ gem 'administrate-field-carrierwave', '~> 0.2.0'
13
13
  ```
14
14
 
15
15
  Run:
@@ -22,7 +22,11 @@ Add to your `FooDashboard`:
22
22
 
23
23
  ```ruby
24
24
  ATTRIBUTE_TYPES = {
25
- bar: Field::Carrierwave.with_options(image: :standard, multiple: true)
25
+ bar: Field::Carrierwave.with_options(
26
+ image: :standard,
27
+ multiple: true,
28
+ image_on_index: true
29
+ )
26
30
  }.freeze
27
31
  ```
28
32
 
@@ -38,12 +42,15 @@ end
38
42
  ### Options
39
43
 
40
44
  * `image` (default: `nil`): a [version] that will be displayed in an `<img>` element.
45
+ * `image_on_index` (default: `false`): whether or not to show the image itself on the index list view. The default behavior (when false) is to display a "View" link that opens the image in a new tab/window when clicked.
41
46
  * `multiple` (default: `false`): allows uploading of multiple files. **ATTENTION 🚨**: [requires CarrierWave’s `master` branch](https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads). Uploaded files will replace the current ones – if present – and not add to them.
42
47
 
43
48
  ## About
44
49
 
45
50
  `Administrate::Field::Carrierwave` is maintained by [z.productions].
46
51
 
52
+ See also the list of [contributors](https://github.com/zooppa/administrate-field-carrierwave/contributors) who participated in this project.
53
+
47
54
  [Administrate]: https://github.com/thoughtbot/administrate
48
55
  [version]: https://github.com/carrierwaveuploader/carrierwave#adding-versions
49
56
  [z.productions]: https://www.z.productions/
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'administrate-field-carrierwave'
5
- gem.version = '0.1.3'
5
+ gem.version = '0.2.0'
6
6
  gem.authors = ['Michele Gerarduzzi']
7
7
  gem.email = ['michele.gerarduzzi@gmail.com']
8
8
  gem.homepage = 'https://github.com/zooppa/administrate-field-carrierwave'
@@ -14,7 +14,11 @@ opens in a new window/tab, or the total number of attached files
14
14
  <% if field.multiple? %>
15
15
  <%= pluralize(field.files.size, field.attribute.to_s.humanize.downcase) %>
16
16
  <% elsif field.file.present? %>
17
- <%= link_to 'View', field.file.url, title: field.file.filename, target: '_blank' %>
17
+ <% if field.image_on_index %>
18
+ <%= render 'fields/carrierwave/preview', file: field.file, field: field %>
19
+ <% else %>
20
+ <%= link_to 'View', field.file.url, title: field.file.filename, target: '_blank' %>
21
+ <% end %>
18
22
  <% else %>
19
23
  -
20
24
  <% end %>
@@ -22,7 +22,7 @@ for this attribute
22
22
  <span>No file(s) uploaded yet</span>
23
23
  <% end %>
24
24
  <% else %>
25
- <% if field.image.present? %>
25
+ <% if field.image.present? && field.data.model.persisted? %>
26
26
  <%= render 'fields/carrierwave/preview', file: field.file, field: field %>
27
27
  <% elsif field.file.present? %>
28
28
  <%= render 'fields/carrierwave/file', file: field.file %>
@@ -10,6 +10,10 @@ module Administrate
10
10
  options.fetch(:image, nil)
11
11
  end
12
12
 
13
+ def image_on_index
14
+ options.fetch(:image_on_index, false)
15
+ end
16
+
13
17
  def multiple?
14
18
  options.fetch(:multiple, false)
15
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-carrierwave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michele Gerarduzzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate