mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Disable add files button when not ready
This commit is contained in:
parent
50b17ea52b
commit
ec984f675b
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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 }},
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user