diff --git a/owncloud/README.md b/owncloud/README.md index cc7c9fc..81b680c 100644 --- a/owncloud/README.md +++ b/owncloud/README.md @@ -22,6 +22,11 @@ it. ## Changelog +## 3.2.1 + +- Disable the confirmation button in the 'add files' dialog if the File-picker + is working or selection is empty + ### 3.2 - Initial release for Indico 3.2 diff --git a/owncloud/indico_owncloud/client/index.js b/owncloud/indico_owncloud/client/index.js index 0b570bd..004aafa 100644 --- a/owncloud/indico_owncloud/client/index.js +++ b/owncloud/indico_owncloud/client/index.js @@ -9,6 +9,10 @@ window.setupOwncloudFilePickerWidget = ({filepickerUrl, fieldId}) => { window.addEventListener('message', message => { const iframe = document.querySelector('#owncloud_filepicker-file-picker'); + const submitButton = document.querySelector( + '#attachment-owncloudfilepicker-form input[type=submit]' + ); + if ( iframe && message.origin === filepickerUrl && @@ -17,6 +21,7 @@ window.setupOwncloudFilePickerWidget = ({filepickerUrl, fieldId}) => { message.data.files ) { document.getElementById(`${fieldId}-files`).value = message.data.files.join('\n'); + submitButton.disabled = !message.data.ready || !message.data.files.length; } }); }; diff --git a/owncloud/indico_owncloud/forms.py b/owncloud/indico_owncloud/forms.py index de33eab..eaa62cb 100644 --- a/owncloud/indico_owncloud/forms.py +++ b/owncloud/indico_owncloud/forms.py @@ -34,7 +34,7 @@ class AttachmentOwncloudFormMixin: def validate_owncloud_filepicker(self, field): if self.owncloud_filepicker.data and self.owncloud_filepicker.data['files'] == ['']: - raise ValidationError("Select files to add and click 'Select resources'") + raise ValidationError('Select some files') class AddAttachmentOwncloudForm(AttachmentOwncloudFormMixin, AttachmentFormBase): diff --git a/owncloud/indico_owncloud/templates/owncloud_filepicker_widget.html b/owncloud/indico_owncloud/templates/owncloud_filepicker_widget.html index e9a41e9..180fca9 100644 --- a/owncloud/indico_owncloud/templates/owncloud_filepicker_widget.html +++ b/owncloud/indico_owncloud/templates/owncloud_filepicker_widget.html @@ -12,6 +12,7 @@ {% block javascript %}