Class: Administrate::Field::ActiveStorage
- Inherits:
-
Base
- Object
- Base
- Administrate::Field::ActiveStorage
- Defined in:
- lib/viniBaxter/field/active_storage.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
-
#attached? ⇒ Boolean
delegate :attached?, to: :data delegate :attachments, to: :data.
- #attachments ⇒ Object
- #blob_url(attachment) ⇒ Object
- #can_add_attachment? ⇒ Boolean
-
#destroy_path(field, attachment) ⇒ Object
this methode is no longer used ness to clean safety.
- #destroy_url ⇒ Object
- #destroyable? ⇒ Boolean
- #direct? ⇒ Boolean
- #drop_accepted_files? ⇒ Boolean
- #drop_js? ⇒ Boolean
- #drop_max_file? ⇒ Boolean
- #drop_max_file_size? ⇒ Boolean
- #index_display_count? ⇒ Boolean
- #many? ⇒ Boolean
-
#preview(attachment, options) ⇒ Object
work around since calling data.preview(options) returns “/images/<ActiveStorage::Preview>” which isnt the url.
- #show_drop_js_on_show? ⇒ Boolean
- #show_in_index? ⇒ Boolean
- #show_preview_size ⇒ Object
- #url(attachment) ⇒ Object
-
#url_only? ⇒ Boolean
theVariant.service.send(:path_for, theVariant.key) # Absolute path to variant file end.
- #variant(attachment, options) ⇒ Object
Instance Method Details
#attached? ⇒ Boolean
delegate :attached?, to: :data delegate :attachments, to: :data
114 115 116 |
# File 'lib/viniBaxter/field/active_storage.rb', line 114 def attached? data.present? && data.attached? end |
#attachments ⇒ Object
118 119 120 |
# File 'lib/viniBaxter/field/active_storage.rb', line 118 def data. if attached? end |
#blob_url(attachment) ⇒ Object
96 97 98 |
# File 'lib/viniBaxter/field/active_storage.rb', line 96 def blob_url() Rails.application.routes.url_helpers.rails_blob_path(, disposition: :attachment, only_path: true) end |
#can_add_attachment? ⇒ Boolean
100 101 102 |
# File 'lib/viniBaxter/field/active_storage.rb', line 100 def many? || .blank? end |
#destroy_path(field, attachment) ⇒ Object
this methode is no longer used ness to clean safety
105 106 107 108 109 110 |
# File 'lib/viniBaxter/field/active_storage.rb', line 105 def destroy_path(field, ) destroy_path_helper = .fetch(:destroy_path) record_id = field.data.record.id = .id Rails.application.routes.url_helpers.send(destroy_path_helper, { :record_id => record_id, :attachment_id => }) end |
#destroy_url ⇒ Object
70 71 72 |
# File 'lib/viniBaxter/field/active_storage.rb', line 70 def destroy_url .fetch(:destroy_url, nil) end |
#destroyable? ⇒ Boolean
24 25 26 |
# File 'lib/viniBaxter/field/active_storage.rb', line 24 def destroyable? .key?(:destroy_path) end |
#direct? ⇒ Boolean
46 47 48 |
# File 'lib/viniBaxter/field/active_storage.rb', line 46 def direct? .fetch(:direct_upload, false) end |
#drop_accepted_files? ⇒ Boolean
66 67 68 |
# File 'lib/viniBaxter/field/active_storage.rb', line 66 def drop_accepted_files? .fetch(:drop_accepted_files, ".jpeg,.jpg,.png,.gif,.svg") end |
#drop_js? ⇒ Boolean
50 51 52 |
# File 'lib/viniBaxter/field/active_storage.rb', line 50 def drop_js? .fetch(:drop_js, false) end |
#drop_max_file? ⇒ Boolean
58 59 60 |
# File 'lib/viniBaxter/field/active_storage.rb', line 58 def drop_max_file? .fetch(:drop_max_file, many? == true ? 10 : 1) end |
#drop_max_file_size? ⇒ Boolean
62 63 64 |
# File 'lib/viniBaxter/field/active_storage.rb', line 62 def drop_max_file_size? .fetch(:drop_max_file_size, 10) end |
#index_display_count? ⇒ Boolean
32 33 34 |
# File 'lib/viniBaxter/field/active_storage.rb', line 32 def index_display_count? .fetch(:index_display_count) { attached? && .count != 1 } end |
#many? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/viniBaxter/field/active_storage.rb', line 40 def many? # find a way to use instance_of # data.class.name == 'ActiveStorage::Attached::Many' data.is_a? ::ActiveStorage::Attached::Many end |
#preview(attachment, options) ⇒ Object
work around since calling data.preview(options) returns “/images/<ActiveStorage::Preview>” which isnt the url
84 85 86 |
# File 'lib/viniBaxter/field/active_storage.rb', line 84 def preview(, ) Rails.application.routes.url_helpers.rails_representation_path(.preview(), only_path: true) end |
#show_drop_js_on_show? ⇒ Boolean
54 55 56 |
# File 'lib/viniBaxter/field/active_storage.rb', line 54 def show_drop_js_on_show? .fetch(:show_drop_js_on_show, false) end |
#show_in_index? ⇒ Boolean
28 29 30 |
# File 'lib/viniBaxter/field/active_storage.rb', line 28 def show_in_index? .fetch(:show_in_index, false) end |
#show_preview_size ⇒ Object
36 37 38 |
# File 'lib/viniBaxter/field/active_storage.rb', line 36 def show_preview_size .fetch(:show_preview_size, [1080, 1920]) end |
#url(attachment) ⇒ Object
92 93 94 |
# File 'lib/viniBaxter/field/active_storage.rb', line 92 def url() Rails.application.routes.url_helpers.rails_blob_path(, only_path: true) end |
#url_only? ⇒ Boolean
theVariant.service.send(:path_for, theVariant.key) # Absolute path to variant file end
20 21 22 |
# File 'lib/viniBaxter/field/active_storage.rb', line 20 def url_only? .fetch(:url_only, false) end |
#variant(attachment, options) ⇒ Object
88 89 90 |
# File 'lib/viniBaxter/field/active_storage.rb', line 88 def variant(, ) Rails.application.routes.url_helpers.rails_representation_path(.variant(combine_options: ), only_path: true) end |