Disable add files button when not ready

This commit is contained in:
Javier Ferrer 2022-09-15 15:29:46 +02:00 committed by Adrian Moennich
parent 50b17ea52b
commit ec984f675b
5 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
});
};

View File

@ -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):

View File

@ -12,6 +12,7 @@
{% block javascript %}
<script>
document.querySelector('#attachment-owncloudfilepicker-form input[type=submit]').disabled = true;
setupOwncloudFilePickerWidget({
filepickerUrl: {{ field.filepicker_url | tojson }},
fieldId: {{ field.id | tojson }},

View File

@ -1,6 +1,6 @@
[metadata]
name = indico-plugin-owncloud
version = 3.2
version = 3.2.1
description = Integrates ownCloud storage as a source for materials
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8; variant=GFM