diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-10-07 16:54:33 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-10-07 16:54:33 +0300 |
commit | 02982d59f79cf86fe850afa4f40506d431cfc04e (patch) | |
tree | a617bb86353b573b8cfe052b0ab183ba4f9002ac /src | |
parent | 34023e2972a177a0c90075112466540fbe4e1884 (diff) |
Move file list access to files app integration
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/view/FilesAppIntegration.js | 26 | ||||
-rw-r--r-- | src/viewer.js | 19 |
2 files changed, 28 insertions, 17 deletions
diff --git a/src/view/FilesAppIntegration.js b/src/view/FilesAppIntegration.js index e8e1a248..da5c0a8f 100644 --- a/src/view/FilesAppIntegration.js +++ b/src/view/FilesAppIntegration.js @@ -25,6 +25,9 @@ const isPublic = document.getElementById('isPublic') && document.getElementById( export default { fileModel: null, + + fileList: FileList, + /* Views: people currently editing the file */ views: {}, @@ -32,15 +35,17 @@ export default { following: null, - init({ fileName, fileId, sendPostMessage }) { + init({ fileName, fileId, sendPostMessage, fileList }) { this.fileName = fileName this.fileId = fileId + this.fileList = fileList this.sendPostMessage = sendPostMessage }, initAfterReady() { if (typeof this.getFileList() !== 'undefined') { this.getFileModel() + this.getFileList().hideMask() } const headerRight = document.querySelector('#header .header-right') @@ -57,6 +62,10 @@ export default { }, close() { + if (this.getFileList()) { + this.getFileList().setViewerMode(false) + this.getFileList().reload() + } this.fileModel = null if (!isPublic) { this.removeVersionSidebarEvents() @@ -65,10 +74,11 @@ export default { }, share() { - if (isPublic) { + if (isPublic || !this.getFileList()) { console.error('[FilesAppIntegration] Sharing is not supported') + return } - FileList.showDetailsView(this.fileName, 'shareTabView') + this.getFileList().showDetailsView(this.fileName, 'shareTabView') OC.Apps.showAppSidebar() }, @@ -93,6 +103,9 @@ export default { }, getFileList() { + if (this.fileList) { + return this.fileList + } if (OCA.Files.App) { return OCA.Files.App.fileList } @@ -341,8 +354,11 @@ export default { }, showRevHistory() { - FileList.showDetailsView(this.fileName, 'versionsTabView') - this.addCurrentVersion() + if (this.getFileList()) { + this.getFileList() + .showDetailsView(this.fileName, 'versionsTabView') + this.addCurrentVersion() + } }, showVersionPreview: function(e) { diff --git a/src/viewer.js b/src/viewer.js index 223953c1..1fabe145 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -62,13 +62,15 @@ const odfViewer = { return } odfViewer.open = true + let fileList = FileList if (context) { + fileList = context.fileList var fileDir = context.dir var fileId = context.fileId || context.$file.attr('data-id') var templateId = context.templateId - FileList.setViewerMode(true) - FileList.setPageTitle(fileName) - FileList.showMask() + context.fileList.setViewerMode(true) + context.fileList.setPageTitle(fileName) + context.fileList.showMask() } odfViewer.receivedLoading = false @@ -103,7 +105,7 @@ const odfViewer = { const reloadForFederationCSP = (fileName) => { const preloadId = Preload.open ? parseInt(Preload.open.id) : -1 - const fileModel = FileList.findFile(fileName) + const fileModel = fileList.findFile(fileName) const shareOwnerId = fileModel.shareOwnerId if (typeof shareOwnerId !== 'undefined') { const lastIndex = shareOwnerId.lastIndexOf('@') @@ -157,6 +159,7 @@ const odfViewer = { FilesAppIntegration.init({ fileName, fileId, + fileList, sendPostMessage: (msgId, values) => { PostMessages.sendWOPIPostMessage(FRAME_DOCUMENT, msgId, values) } @@ -169,20 +172,12 @@ const odfViewer = { $('#richdocumentsframe').show() $('html, body').scrollTop(0) $('#content').removeClass('loading') - if (typeof FileList !== 'undefined') { - FileList.hideMask() - } FilesAppIntegration.initAfterReady() }, onClose: function() { odfViewer.open = false clearTimeout(odfViewer.loadingTimeout) - if (typeof FileList !== 'undefined') { - FileList.setViewerMode(false) - FileList.reload() - // FileList.scrollTo() - } odfViewer.receivedLoading = false $('link[href*="richdocuments/css/mobile"]').remove() $('#app-content #controls').removeClass('hidden') |