]> BookStack Code Mirror - bookstack/commitdiff
Allowed button-based multi-file uploads
authorDan Brown <redacted>
Mon, 22 May 2023 13:19:18 +0000 (14:19 +0100)
committerDan Brown <redacted>
Mon, 22 May 2023 13:20:20 +0000 (14:20 +0100)
Likely something that worked via dropzone before.
This adds support for our custom dropzone file handling.
Related to #4241

resources/js/components/dropzone.js
resources/js/services/dom.js
resources/views/attachments/manager.blade.php
resources/views/pages/parts/image-manager.blade.php

index 1fdf824ae72a38e520aaf170c465e114e96d7960..2b8b35081188f8754a744b5fd412a86076224670 100644 (file)
@@ -21,6 +21,7 @@ export class Dropzone extends Component {
         this.uploadLimitMessage = this.$opts.uploadLimitMessage;
         this.zoneText = this.$opts.zoneText;
         this.fileAcceptTypes = this.$opts.fileAccept;
+        this.allowMultiple = this.$opts.allowMultiple === 'true';
 
         this.setupListeners();
     }
@@ -83,7 +84,12 @@ export class Dropzone extends Component {
     }
 
     manualSelectHandler() {
-        const input = elem('input', {type: 'file', style: 'left: -400px; visibility: hidden; position: fixed;', accept: this.fileAcceptTypes});
+        const input = elem('input', {
+            type: 'file',
+            style: 'left: -400px; visibility: hidden; position: fixed;',
+            accept: this.fileAcceptTypes,
+            multiple: this.allowMultiple ? '' : null,
+        });
         this.container.append(input);
         input.click();
         input.addEventListener('change', () => {
index 78685574850643946fa8b305e479d3f3bc69b9df..d764a2ebe511f19cfeb0f49da1edaf91b833315d 100644 (file)
@@ -10,7 +10,11 @@ export function elem(tagName, attrs = {}, children = []) {
     const el = document.createElement(tagName);
 
     for (const [key, val] of Object.entries(attrs)) {
-        el.setAttribute(key, val);
+        if (val === null) {
+            el.removeAttribute(key);
+        } else {
+            el.setAttribute(key, val);
+        }
     }
 
     for (const child of children) {
index 4526172d4db63b2d62ca7a362bfa4ea131d4b2aa..6cbfd1aae091eb0491f84266b660b0ccb237931d 100644 (file)
@@ -14,6 +14,7 @@
          option:dropzone:upload-limit-message="{{ trans('errors.server_upload_limit') }}"
          option:dropzone:zone-text="{{ trans('entities.attachments_dropzone') }}"
          option:dropzone:file-accept="*"
+         option:dropzone:allow-multiple="true"
          class="px-l files">
 
         <div refs="attachments@list-container dropzone@drop-target" class="relative">
index 0594c67e807d9ecf903da2009bd8b804c0e1440a..da64d681c5283df580367b6ecb38643ec6cfa9ca 100644 (file)
@@ -6,6 +6,7 @@
      option:dropzone:upload-limit-message="{{ trans('errors.server_upload_limit') }}"
      option:dropzone:zone-text="{{ trans('components.image_dropzone_drop') }}"
      option:dropzone:file-accept="image/*"
+     option:dropzone:allow-multiple="true"
      option:image-manager:uploaded-to="{{ $uploaded_to ?? 0 }}"
      class="image-manager">