WaiverUploadController

Waiver Upload Controller

Handles file selection, validation, preview, and upload progress for waiver images. Supports multiple file uploads with mobile camera capture integration.

Targets:

  • waiverType: Waiver type select dropdown
  • fileInput: File input element
  • preview: Preview area container
  • progress: Progress bar container
  • progressBar: Progress bar element
  • progressText: Progress text element
  • submitButton: Submit button

Actions:

  • handleFileSelect: Triggered when files are selected
  • handleSubmit: Triggered when form is submitted

Members

ALLOWED_TYPES

Allowed MIME types for uploads (images and PDFs)

MAX_FILE_SIZE

Maximum file size in bytes (25MB)

Methods

connect()

Initialize controller

escapeHtml(text) → {string}

Escape HTML to prevent XSS

Parameters:
NameTypeDescription
textstring

Text to escape

Returns:

Escaped text

Type: 
string

formatFileSize(bytes) → {string}

Format file size for display

Parameters:
NameTypeDescription
bytesnumber

File size in bytes

Returns:

Formatted file size

Type: 
string

handleFileSelect(event)

Handle file selection from input

Parameters:
NameTypeDescription
eventEvent

File input change event

handleSubmit(event)

Handle form submission

Parameters:
NameTypeDescription
eventEvent

Form submit event

hidePreview()

Hide file preview area

removeFile(index)

Remove a file from selection

Parameters:
NameTypeDescription
indexnumber

File index to remove

showPreview()

Show file preview area with selected files

simulateProgress()

Simulate upload progress (since conversion is synchronous)

updateProgress(percent)

Update progress bar

Parameters:
NameTypeDescription
percentnumber

Progress percentage (0-100)

validateFile(file) → {Object}

Validate a single file

Parameters:
NameTypeDescription
fileFile

File to validate

Returns:

Validation result {valid: boolean, error: string}

Type: 
Object