diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-12-02 15:40:46 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-12-06 15:37:59 +0300 |
commit | 20a44dd9ca4a17070c9784431f7cdcecfca97d7d (patch) | |
tree | 4899614aca2ef95beb56da7920ebc1140331ad62 /src | |
parent | aed1ed18592c7f7a7b99cffc733821fbce087268 (diff) |
Add setting for rich workspaces
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/files.js | 14 | ||||
-rw-r--r-- | src/views/FilesSettings.vue | 54 | ||||
-rw-r--r-- | src/views/RichWorkspace.vue | 15 |
3 files changed, 81 insertions, 2 deletions
diff --git a/src/files.js b/src/files.js index d8c852089..c0a486ebd 100644 --- a/src/files.js +++ b/src/files.js @@ -20,10 +20,12 @@ * */ +import Vue from 'vue' import FilesEditor from './components/FilesEditor' import PreviewPlugin from './files/PreviewPlugin' import { registerFileActionFallback, registerFileCreate, FilesWorkspacePlugin } from './helpers/files' import { openMimetypesMarkdown, openMimetypesPlainText } from './helpers/mime' +import FilesSettings from './views/FilesSettings' __webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line __webpack_public_path__ = OC.linkTo('text', 'js/') // eslint-disable-line @@ -50,10 +52,22 @@ document.addEventListener('DOMContentLoaded', () => { }) OC.Plugins.register('OCA.Files.SidebarPreviewManager', new PreviewPlugin()) + const settings = document.createElement('div') + document.getElementById('files-setting-showhidden').insertAdjacentElement('afterend', settings) + Vue.prototype.t = window.t + Vue.prototype.n = window.n + Vue.prototype.OCA = window.OCA + const vm = new Vue({ + render: h => h(FilesSettings, {}), + }) + vm.$mount(settings) + }) OC.Plugins.register('OCA.Files.FileList', FilesWorkspacePlugin) OCA.Text = { Editor: FilesEditor, + // FIXME get from capabilities + RichWorkspaceEnabled: true, } diff --git a/src/views/FilesSettings.vue b/src/views/FilesSettings.vue new file mode 100644 index 000000000..7976e1612 --- /dev/null +++ b/src/views/FilesSettings.vue @@ -0,0 +1,54 @@ +<!-- + - @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + - + - @author Julius Härtl <jus@bitgrid.net> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. + - + --> +<template> + <div id="files-setting-showhidden"> + <input id="showRichWorkspacesToggle" + v-model="showWorkspace" + class="checkbox" + type="checkbox" + @change="toggle"> + <label for="showRichWorkspacesToggle">{{ t('text', 'Show rich workspaces') }}</label> + </div> +</template> + +<script> +import { emit } from '@nextcloud/event-bus' + +export default { + name: 'FilesSettings', + data() { + return { + showWorkspace: OCA.Text.RichWorkspaceEnabled, + } + }, + methods: { + toggle() { + // FIXME: save to app config + if (this.showWorkspace) { + emit('Text::showRichWorkspace') + } else { + emit('Text::hideRichWorkspace') + } + }, + }, +} +</script> diff --git a/src/views/RichWorkspace.vue b/src/views/RichWorkspace.vue index 5de4a105b..6e0125480 100644 --- a/src/views/RichWorkspace.vue +++ b/src/views/RichWorkspace.vue @@ -21,7 +21,7 @@ --> <template> - <div id="rich-workspace" :class="{'icon-loading': !loaded || !ready, 'focus': focus }"> + <div v-if="enabled" id="rich-workspace" :class="{'icon-loading': !loaded || !ready, 'focus': focus }"> <div v-if="!file || (autofocus && !ready)" class="empty-workspace" @click="createNew"> <p class="placeholder"> {{ t('text', 'Add notes, lists or links …') }} @@ -47,6 +47,7 @@ <script> import axios from '@nextcloud/axios' import { generateOcsUrl } from '@nextcloud/router' +import { subscribe } from '@nextcloud/event-bus' const IS_PUBLIC = !!(document.getElementById('isPublic')) const WORKSPACE_URL = generateOcsUrl('apps/text' + (IS_PUBLIC ? '/public' : ''), 2) + 'workspace' @@ -69,6 +70,7 @@ export default { loaded: false, ready: false, autofocus: false, + enabled: OCA.Text.RichWorkspaceEnabled, } }, computed: { @@ -82,7 +84,16 @@ export default { }, }, async mounted() { - this.getFileInfo() + if (this.enabled) { + this.getFileInfo() + } + subscribe('Text::showRichWorkspace', () => { + this.enabled = true + this.getFileInfo() + }) + subscribe('Text::hideRichWorkspace', () => { + this.enabled = false + }) }, methods: { getFileInfo() { |