Dani3lSun / apex-plugin-dropzone

Oracle APEX Region Plugin - Dropzone
MIT License
72 stars 19 forks source link

Update Dropzone "Max Files" dynamically #83

Open darrenrhymer opened 3 years ago

darrenrhymer commented 3 years ago

Hi

APEX OCI, 20.2

In my project I want to limit the user to uploading 6 images per product. On the page I have 3 hidden fields:

P1_DROPZONE_NO_IMAGES select count(*) from my_table where id = :P1_ID

P1_DROPZONE_MAX_IMAGES static = 6

P1_DROPZONE_FILE_COUNT = :P1_DROPZONE_MAX_IMAGES - :P1_DROPZONE_NO_IMAGES

The DROPZONE attributes max Files: &P1_DROPZONE_FILE_COUNT.

When I refresh the page and i have 4 images stored in db my values are : P1_DROPZONE_NO_IMAGES = 4 P1_DROPZONE_MAX_IMAGES = 6 P1_DROPZONE_FILE_COUNT = 2

And i cannot load any more than 2 images using Dropzone. However when i upload one image my values are now: P1_DROPZONE_NO_IMAGES = 5 P1_DROPZONE_MAX_IMAGES = 6 P1_DROPZONE_FILE_COUNT = 1

But I can still then add a further 2. The value of P1_DROPZONE_FILE_COUNT is 1 but the Max Files in Dropzone is still 2. I have tried refreshing the DropZone region.

How can I make sure Dropzone MaxFiles is updated correctly please?

Thanks

darrenrhymer commented 3 years ago

In the DA execute a Javascript Code action:

$('.dropzone')[0].dropzone.options.maxFiles = $v("P1_DROPZONE_FILE_COUNT");