Skip to content
Snippets Groups Projects
Commit 3dcee651 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

use event bus to toggle display of gallery link and make sure the gallery link...

Closes #2409

Merge request studip/studip!1604
parent 2ba89885
No related branches found
No related tags found
No related merge requests found
...@@ -59,16 +59,6 @@ class Course_FilesController extends AuthenticatedController ...@@ -59,16 +59,6 @@ class Course_FilesController extends AuthenticatedController
); );
} }
$actions->addLink(
_('Bildergalerie öffnen'),
'#g',
Icon::create('file-pic', 'clickable'),
[
'onClick' => "STUDIP.Files.openGallery(); return false;",
'v-if' => "hasFilesOfType('image')"
]
);
if ($this->topFolder && $this->topFolder->isSubfolderAllowed($GLOBALS['user']->id)) { if ($this->topFolder && $this->topFolder->isSubfolderAllowed($GLOBALS['user']->id)) {
$actions->addLink( $actions->addLink(
_('Neuer Ordner'), _('Neuer Ordner'),
...@@ -93,9 +83,18 @@ class Course_FilesController extends AuthenticatedController ...@@ -93,9 +83,18 @@ class Course_FilesController extends AuthenticatedController
)->asDialog(); )->asDialog();
} }
$sidebar->addWidget($actions);
$actions->addLink(
_('Bildergalerie öffnen'),
'#g',
Icon::create('file-pic'),
[
'onClick' => "STUDIP.Files.openGallery(); return false;",
'style' => 'display: none',
]
);
$sidebar->addWidget($actions);
if ($this->topFolder->isWritable($GLOBALS['user']->id)) { if ($this->topFolder->isWritable($GLOBALS['user']->id)) {
$uploadArea = new LinksWidget(); $uploadArea = new LinksWidget();
...@@ -172,10 +171,10 @@ class Course_FilesController extends AuthenticatedController ...@@ -172,10 +171,10 @@ class Course_FilesController extends AuthenticatedController
$actions->addLink( $actions->addLink(
_('Bildergalerie öffnen'), _('Bildergalerie öffnen'),
'#g', '#g',
Icon::create('file-pic', 'clickable'), Icon::create('file-pic'),
[ [
'onClick' => "STUDIP.Files.openGallery(); return false;", 'onClick' => "STUDIP.Files.openGallery(); return false;",
'v-if' => "hasFilesOfType('image')" 'style' => 'display: none',
] ]
); );
if ($GLOBALS['user']->id !== 'nobody') { if ($GLOBALS['user']->id !== 'nobody') {
......
...@@ -100,15 +100,6 @@ class FilesController extends AuthenticatedController ...@@ -100,15 +100,6 @@ class FilesController extends AuthenticatedController
); );
} }
$actions->addLink(
_('Bildergalerie öffnen'),
'#g',
Icon::create('file-pic', 'clickable'),
[
'onClick' => "STUDIP.Files.openGallery(); return false;"
]
);
if ($folder->isWritable($GLOBALS['user']->id)) { if ($folder->isWritable($GLOBALS['user']->id)) {
$actions->addLink( $actions->addLink(
_('Dokument hinzufügen'), _('Dokument hinzufügen'),
...@@ -146,6 +137,17 @@ class FilesController extends AuthenticatedController ...@@ -146,6 +137,17 @@ class FilesController extends AuthenticatedController
)->asDialog(); )->asDialog();
} }
} }
$actions->addLink(
_('Bildergalerie öffnen'),
'#g',
Icon::create('file-pic'),
[
'onClick' => "STUDIP.Files.openGallery(); return false;",
'style' => 'display: none',
]
);
$sidebar->addWidget($actions); $sidebar->addWidget($actions);
if ($folder->isWritable($GLOBALS['user']->id)) { if ($folder->isWritable($GLOBALS['user']->id)) {
...@@ -612,10 +614,10 @@ class FilesController extends AuthenticatedController ...@@ -612,10 +614,10 @@ class FilesController extends AuthenticatedController
$actions->addLink( $actions->addLink(
_('Bildergalerie öffnen'), _('Bildergalerie öffnen'),
'#g', '#g',
Icon::create('file-pic', 'clickable'), Icon::create('file-pic'),
[ [
'onClick' => "STUDIP.Files.openGallery(); return false;", 'onClick' => "STUDIP.Files.openGallery(); return false;",
'v-if' => "hasFilesOfType('image')" 'style' => 'display: none',
] ]
); );
$sidebar->addWidget($actions); $sidebar->addWidget($actions);
......
...@@ -17,6 +17,10 @@ function searchMoreFiles (button) { ...@@ -17,6 +17,10 @@ function searchMoreFiles (button) {
return false; return false;
} }
STUDIP.eventBus.on('files-vue-app-updated', ({hasImages}) => {
$('#sidebar-actions a[onclick*="Files.openGallery"]').toggle(hasImages);
});
STUDIP.domReady(() => { STUDIP.domReady(() => {
STUDIP.Files.init(); STUDIP.Files.init();
...@@ -49,11 +53,6 @@ STUDIP.domReady(() => { ...@@ -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) => { jQuery(document).on('ajaxComplete', (event, xhr) => {
if (!xhr.getResponseHeader('X-Filesystem-Changes')) { if (!xhr.getResponseHeader('X-Filesystem-Changes')) {
return; return;
......
...@@ -29,11 +29,19 @@ const Files = { ...@@ -29,11 +29,19 @@ const Files = {
}, },
removeFile(id) { removeFile(id) {
this.files = this.files.filter(file => file.id != id) this.files = this.files.filter(file => file.id != id)
},
onUpdated() {
STUDIP.eventBus.emit('files-vue-app-updated', {
hasImages: this.hasFilesOfType('image'),
});
} }
}, },
components: { FilesTable, }, components: { FilesTable, },
mounted () { updated () {
$(document).trigger('files-vue-app-loaded'); this.onUpdated();
},
created () {
this.onUpdated();
} }
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment