diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-03-22 11:56:11 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2023-03-22 11:56:11 +0000 |
| commit | 3dcee65137d7c25129c93a2f197084e2e9c8ab2f (patch) | |
| tree | 00bab06ca06cda301075c10b9b095c58ea808a1a /resources | |
| parent | 2ba898859c58b7538f51a257c281a70d42452390 (diff) | |
use event bus to toggle display of gallery link and make sure the gallery link...
Closes #2409
Merge request studip/studip!1604
Diffstat (limited to 'resources')
| -rw-r--r-- | resources/assets/javascripts/bootstrap/files.js | 9 | ||||
| -rw-r--r-- | resources/assets/javascripts/lib/files.js | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/resources/assets/javascripts/bootstrap/files.js b/resources/assets/javascripts/bootstrap/files.js index 72a2a6e..6caef6d 100644 --- a/resources/assets/javascripts/bootstrap/files.js +++ b/resources/assets/javascripts/bootstrap/files.js @@ -17,6 +17,10 @@ function searchMoreFiles (button) { return false; } +STUDIP.eventBus.on('files-vue-app-updated', ({hasImages}) => { + $('#sidebar-actions a[onclick*="Files.openGallery"]').toggle(hasImages); +}); + STUDIP.domReady(() => { STUDIP.Files.init(); @@ -49,11 +53,6 @@ STUDIP.domReady(() => { }); }); -$(document).on('files-vue-app-loaded', () => { - const lightboxImages = $('.lightbox-image'); - $('#sidebar-actions a[onclick*="Files.openGallery"]').attr('disabled', lightboxImages.length === 0); -}); - jQuery(document).on('ajaxComplete', (event, xhr) => { if (!xhr.getResponseHeader('X-Filesystem-Changes')) { return; diff --git a/resources/assets/javascripts/lib/files.js b/resources/assets/javascripts/lib/files.js index d02486d..f806787 100644 --- a/resources/assets/javascripts/lib/files.js +++ b/resources/assets/javascripts/lib/files.js @@ -29,11 +29,19 @@ const Files = { }, removeFile(id) { this.files = this.files.filter(file => file.id != id) + }, + onUpdated() { + STUDIP.eventBus.emit('files-vue-app-updated', { + hasImages: this.hasFilesOfType('image'), + }); } }, components: { FilesTable, }, - mounted () { - $(document).trigger('files-vue-app-loaded'); + updated () { + this.onUpdated(); + }, + created () { + this.onUpdated(); } }); }); |
