Module: UppyUploaderHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/uppy_uploader_helper.rb
Overview
View helper: uppy uploader.
Instance Method Summary collapse
-
#file_uploader(options = {}) ⇒ String
Helper method for general file uploads.
-
#image_uploader(options = {}) ⇒ String
Helper method for ImageKit image uploads (multiple images).
-
#large_file_uploader_s3(options = {}) ⇒ String
Helper method for large file uploads with S3 mode in existing uploader.
-
#lead_sketch_uploader(options = {}) ⇒ String
Helper method for lead form sketch uploads.
-
#public_warranty_card_uploader(options = {}) ⇒ String
Helper method for warranty-card uploads on the PUBLIC registration form.
-
#rma_image_uploader(rma, options = {}) ⇒ String
Helper method specifically for RMA image uploads.
-
#rma_image_uploader_s3(rma, options = {}) ⇒ String
Helper method for RMA image uploads with S3 mode in existing uploader.
-
#uppy_uploader(options = {}) ⇒ String
Helper method to render the uppy uploader with sensible defaults.
-
#video_uploader(options = {}) ⇒ String
Helper method for video uploads.
-
#warranty_card_uploader(warranty, options = {}) ⇒ String
Helper method for warranty-card uploads on CRM warranty pages.
Instance Method Details
#file_uploader(options = {}) ⇒ String
Helper method for general file uploads
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/helpers/uppy_uploader_helper.rb', line 148 def file_uploader( = {}) = { endpoint: upload_images_path, max_files: 5, max_file_size: 5 * 1024 * 1024, # 5MB allowed_file_types: ['*/*'], hidden_field_name: 'upload_ids', auto_proceed: false, height: 300, note: 'Images and PDFs only, up to 5MB each', submit_button_text: 'Upload Files', form_url: '#', form_method: :post, form_local: true, resource_name: 'upload' } uppy_uploader(.merge()) end |
#image_uploader(options = {}) ⇒ String
Helper method for ImageKit image uploads (multiple images)
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'app/helpers/uppy_uploader_helper.rb', line 239 def image_uploader( = {}) = { # CRM images endpoint only endpoint: upload_images_path, max_files: 10, max_file_size: 50 * 1024 * 1024, # 50MB allowed_file_types: ['image/*'], hidden_field_name: 'files[files_list]', auto_proceed: false, height: 400, note: 'Image files only, up to 10MB each', submit_button_text: 'Upload Images', form_url: { action: :create_multi }, form_method: :post, form_local: true, resource_name: 'files', manual_submit: false # Auto-submit after upload } uppy_uploader(.merge()) end |
#large_file_uploader_s3(options = {}) ⇒ String
Helper method for large file uploads with S3 mode in existing uploader
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'app/helpers/uppy_uploader_helper.rb', line 310 def large_file_uploader_s3( = {}) = { endpoint: upload_uploads_path, # Still needed for XHR fallback presigned_url_endpoint: presigned_url_uploads_path, upload_complete_endpoint: upload_complete_uploads_path, max_files: 1, max_file_size: 500 * 1024 * 1024, # 500MB allowed_file_types: ['*/*'], hidden_field_name: 'upload_ids', auto_proceed: true, height: 400, note: 'Large files up to 500MB - uploading directly to cloud storage for better performance', submit_button_text: 'Upload File', form_url: '#', form_method: :post, form_local: true, resource_name: 'upload', mode: 's3' # Use S3 mode } uppy_uploader(.merge()) end |
#lead_sketch_uploader(options = {}) ⇒ String
Helper method for lead form sketch uploads
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'app/helpers/uppy_uploader_helper.rb', line 178 def lead_sketch_uploader( = {}) = { # Lead form uploads use the WWW uploads endpoint endpoint: upload_www_uploads_path, max_files: 10, max_file_size: 250 * 1024 * 1024, # 250MB per file to allow large docs/CAD # Accept virtually any file except executables allowed_file_types: ['*/*'], hidden_field_name: 'lead[sketch_drawings]', auto_proceed: false, height: 200, note: 'Attach project filesimages, PDFs, docs, CAD files, or ZIPs', submit_button_text: 'Upload Sketches', form_url: '#', form_method: :post, form_local: true, resource_name: 'lead', category: 'sketch' } uppy_uploader(.merge()) end |
#public_warranty_card_uploader(options = {}) ⇒ String
Helper method for warranty-card uploads on the PUBLIC registration form.
Files land unattached (7-day expiry) via the WWW endpoint and their ids
collect in the hidden field; Warranty::PublicRegistration claims them on
submit.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'app/helpers/uppy_uploader_helper.rb', line 117 def public_warranty_card_uploader( = {}) = { endpoint: upload_www_uploads_path, max_files: 10, max_file_size: 10 * 1024 * 1024, # 10MB allowed_file_types: ['image/*', 'application/pdf'], hidden_field_name: 'warranty_uploads[upload_ids]', auto_proceed: true, height: 200, note: 'Warranty card, receipt, or install photos — images or PDFs, up to 10MB each', submit_button_text: 'Upload Files', form_url: '#', form_method: :post, form_local: true, resource_name: 'warranty_uploads', category: 'warranty_card', manual_submit: false } uppy_uploader(.merge()) end |
#rma_image_uploader(rma, options = {}) ⇒ String
Helper method specifically for RMA image uploads
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/uppy_uploader_helper.rb', line 43 def rma_image_uploader(rma, = {}) = { endpoint: upload_uploads_path, max_files: 10, max_file_size: 10 * 1024 * 1024, # 10MB allowed_file_types: ['image/*'], hidden_field_name: 'rma[upload_ids]', auto_proceed: false, height: 400, note: 'Image files only, up to 10MB each', submit_button_text: 'Upload & Attach Images', form_url: do_add_multiple_images_rma_path(rma), form_method: :post, form_local: true, resource_name: 'rma', resource_type: 'Rma', resource_id: rma.id, category: 'photo', manual_submit: true } uppy_uploader(.merge()) end |
#rma_image_uploader_s3(rma, options = {}) ⇒ String
Helper method for RMA image uploads with S3 mode in existing uploader
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'app/helpers/uppy_uploader_helper.rb', line 273 def rma_image_uploader_s3(rma, = {}) = { endpoint: upload_uploads_path, # Still needed for XHR fallback presigned_url_endpoint: presigned_url_uploads_path, upload_complete_endpoint: upload_complete_uploads_path, max_files: 10, max_file_size: 10 * 1024 * 1024, # 10MB allowed_file_types: ['image/*'], hidden_field_name: 'rma[upload_ids]', auto_proceed: true, # Auto-upload files immediately when dropped height: 400, note: 'Drop images here - they will upload automatically to cloud storage', submit_button_text: 'Upload & Attach Images', # Not used since manual_submit: false form_url: do_add_multiple_images_rma_path(rma), form_method: :post, form_local: true, resource_name: 'rma', resource_type: 'Rma', resource_id: rma.id, category: 'photo', manual_submit: false, # Auto-submit after upload mode: 's3' # Use S3 mode } uppy_uploader(.merge()) end |
#uppy_uploader(options = {}) ⇒ String
Helper method to render the uppy uploader with sensible defaults
28 29 30 |
# File 'app/helpers/uppy_uploader_helper.rb', line 28 def uppy_uploader( = {}) render 'shared/uppy_uploader', end |
#video_uploader(options = {}) ⇒ String
Helper method for video uploads
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'app/helpers/uppy_uploader_helper.rb', line 210 def video_uploader( = {}) = { endpoint: cf_upload_videos_path, max_files: 1, max_file_size: 100 * 1024 * 1024, # 100MB allowed_file_types: ['video/*'], hidden_field_name: 'video[cloudflare_uid]', auto_proceed: true, height: 400, note: 'Video files only, up to 100MB', submit_button_text: 'Upload Video', form_url: '#', form_method: :post, form_local: true, resource_name: 'video' } uppy_uploader(.merge()) end |
#warranty_card_uploader(warranty, options = {}) ⇒ String
Helper method for warranty-card uploads on CRM warranty pages. Uploads
attach to the persisted Warranty immediately (resource params on the
endpoint), so no separate submit step is needed.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/helpers/uppy_uploader_helper.rb', line 80 def warranty_card_uploader(warranty, = {}) = { endpoint: upload_uploads_path, max_files: 10, max_file_size: 10 * 1024 * 1024, # 10MB allowed_file_types: ['image/*', 'application/pdf'], hidden_field_name: 'warranty[upload_ids]', auto_proceed: true, height: 300, note: 'Warranty cards — images or PDFs, up to 10MB each', submit_button_text: 'Upload Warranty Cards', form_url: '#', form_method: :post, form_local: true, resource_name: 'warranty', resource_type: 'Warranty', resource_id: warranty.id, category: 'warranty_card', manual_submit: false } uppy_uploader(.merge()) end |