Dispatch event to allow apps to load their script for collections

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-03-14 14:42:42 +01:00
parent 3022ef687a
commit e8fe00003b
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF
5 changed files with 26 additions and 17 deletions

View file

@ -45,6 +45,9 @@ $eventDispatcher->addListener(
\OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
}
);
\OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
\OCP\Util::addScript('files_sharing', 'dist/collaboration');
});
$config = \OC::$server->getConfig();
$shareManager = \OC::$server->getShareManager();

View file

@ -33,5 +33,6 @@ $tmpl = new OCP\Template('files_sharing', 'list', '');
$tmpl->assign('showgridview', $showgridview && !$isIE);
OCP\Util::addScript('files_sharing', 'dist/files_sharing');
\OC::$server->getEventDispatcher()->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts');
$tmpl->printPage();

View file

@ -8,22 +8,6 @@ import './sharebreadcrumbview'
import './style/sharetabview.scss'
import './style/sharebreadcrumb.scss'
window.OCP.Collaboration.registerType('files', {
action: () => {
return new Promise((resolve, reject) => {
OC.dialogs.filepicker('Link to a file', function (f) {
const client = OC.Files.getClient();
client.getFileInfo(f).then((status, fileInfo) => {
resolve(fileInfo.id);
}, () => {
reject();
});
}, false);
});
},
/** used in "Link to a {typeString}" */
typeString: t('files_sharing', 'file'),
typeIconClass: 'icon-files-dark'
});
import './collaborationresourceshandler.js'
window.OCA.Sharing = OCA.Sharing;

View file

@ -0,0 +1,20 @@
__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/');
__webpack_nonce__ = btoa(OC.requestToken);
window.OCP.Collaboration.registerType('files', {
action: () => {
return new Promise((resolve, reject) => {
OC.dialogs.filepicker('Link to a file', function (f) {
const client = OC.Files.getClient();
client.getFileInfo(f).then((status, fileInfo) => {
resolve(fileInfo.id);
}, () => {
reject();
});
}, false);
});
},
/** used in "Link to a {typeString}" */
typeString: t('files_sharing', 'file'),
typeIconClass: 'icon-files-dark'
});

View file

@ -5,6 +5,7 @@ module.exports = {
entry: {
'additionalScripts': path.join(__dirname, 'src', 'additionalScripts.js'),
'files_sharing': path.join(__dirname, 'src', 'files_sharing.js'),
'collaboration': path.join(__dirname, 'src', 'collaborationresourceshandler.js'),
},
output: {
path: path.resolve(__dirname, './js/dist/'),