2020-10-04 01:30:50 +03:00
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
<!--
|
|
|
|
- @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
-
|
|
|
|
- @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
-
|
|
|
|
- @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>
|
2020-01-29 18:31:47 +03:00
|
|
|
<AppSidebarTab
|
|
|
|
:id="id"
|
2020-10-04 14:49:57 +03:00
|
|
|
ref="tab"
|
2019-05-23 18:03:04 +03:00
|
|
|
:name="name"
|
2020-10-04 01:30:50 +03:00
|
|
|
:icon="icon">
|
2020-10-04 14:49:57 +03:00
|
|
|
<!-- Fallback loading -->
|
|
|
|
<EmptyContent v-if="loading" icon="icon-loading" />
|
|
|
|
|
2020-10-04 01:30:50 +03:00
|
|
|
<!-- Using a dummy div as Vue mount replace the element directly
|
|
|
|
It does NOT append to the content -->
|
2020-10-04 14:49:57 +03:00
|
|
|
<div ref="mount" />
|
2020-10-04 01:30:50 +03:00
|
|
|
</AppSidebarTab>
|
2019-05-23 18:03:04 +03:00
|
|
|
</template>
|
2020-10-04 01:30:50 +03:00
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
<script>
|
2020-01-16 02:03:29 +03:00
|
|
|
import AppSidebarTab from '@nextcloud/vue/dist/Components/AppSidebarTab'
|
2020-10-04 14:49:57 +03:00
|
|
|
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
|
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
export default {
|
2020-10-04 01:30:50 +03:00
|
|
|
name: 'SidebarTab',
|
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
components: {
|
2020-07-31 10:26:43 +03:00
|
|
|
AppSidebarTab,
|
2020-10-04 14:49:57 +03:00
|
|
|
EmptyContent,
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
props: {
|
2020-10-04 01:30:50 +03:00
|
|
|
fileInfo: {
|
2019-05-23 18:03:04 +03:00
|
|
|
type: Object,
|
2020-10-04 01:30:50 +03:00
|
|
|
default: () => {},
|
2019-11-13 15:05:10 +03:00
|
|
|
required: true,
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-01-29 18:31:47 +03:00
|
|
|
id: {
|
2019-05-23 18:03:04 +03:00
|
|
|
type: String,
|
2019-11-13 15:05:10 +03:00
|
|
|
required: true,
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
name: {
|
|
|
|
type: String,
|
2019-11-13 15:05:10 +03:00
|
|
|
required: true,
|
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 14:49:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lifecycle methods.
|
|
|
|
* They are prefixed with `on` to avoid conflict with Vue
|
|
|
|
* methods like this.destroy
|
|
|
|
*/
|
|
|
|
onMount: {
|
2020-10-04 01:30:50 +03:00
|
|
|
type: Function,
|
|
|
|
required: true,
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 14:49:57 +03:00
|
|
|
onUpdate: {
|
|
|
|
type: Function,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
onDestroy: {
|
|
|
|
type: Function,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
}
|
2020-10-04 01:30:50 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-10-04 14:49:57 +03:00
|
|
|
// TODO: implement a better way to force pass a prop from Sidebar
|
2019-05-23 18:03:04 +03:00
|
|
|
activeTab() {
|
|
|
|
return this.$parent.activeTab
|
2019-11-13 15:05:10 +03:00
|
|
|
},
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
watch: {
|
2020-10-04 14:49:57 +03:00
|
|
|
async fileInfo(newFile, oldFile) {
|
|
|
|
// Update fileInfo on change
|
2020-10-04 01:30:50 +03:00
|
|
|
if (newFile.id !== oldFile.id) {
|
2020-10-04 14:49:57 +03:00
|
|
|
this.loading = true
|
|
|
|
await this.onUpdate(this.fileInfo)
|
|
|
|
this.loading = false
|
2019-05-23 18:03:04 +03:00
|
|
|
}
|
2019-11-13 15:05:10 +03:00
|
|
|
},
|
2019-05-23 18:03:04 +03:00
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
|
2020-10-04 14:49:57 +03:00
|
|
|
async mounted() {
|
|
|
|
this.loading = true
|
|
|
|
// Mount the tab: mounting point, fileInfo, vue context
|
|
|
|
await this.onMount(this.$refs.mount, this.fileInfo, this.$refs.tab)
|
|
|
|
this.loading = false
|
2019-10-23 19:40:48 +03:00
|
|
|
},
|
2020-10-04 01:30:50 +03:00
|
|
|
|
2020-10-04 14:49:57 +03:00
|
|
|
async beforeDestroy() {
|
|
|
|
// unmount the tab
|
|
|
|
await this.onDestroy()
|
2019-11-13 15:05:10 +03:00
|
|
|
},
|
2020-10-04 14:49:57 +03:00
|
|
|
|
2019-05-23 18:03:04 +03:00
|
|
|
}
|
|
|
|
</script>
|