2424 </NcAppSidebar >
2525</template >
2626
27- <script >
27+ <script setup lang="ts" >
2828import { t } from ' @nextcloud/l10n'
29+ import { computed , ref , watch } from ' vue'
30+ import { useRoute } from ' vue-router'
2931
3032import NcAppSidebar from ' @nextcloud/vue/components/NcAppSidebar'
3133import NcAppSidebarTab from ' @nextcloud/vue/components/NcAppSidebarTab'
@@ -37,57 +39,67 @@ import { useFilesStore } from '../../store/files.js'
3739import { useSidebarStore } from ' ../../store/sidebar.js'
3840import { useSignStore } from ' ../../store/sign.js'
3941
40- export default {
42+ defineOptions ( {
4143 name: ' RightSidebar' ,
42- components: {
43- NcAppSidebar,
44- NcAppSidebarTab,
45- RequestSignatureTab,
46- SignTab,
47- },
48- setup () {
49- const filesStore = useFilesStore ()
50- const signStore = useSignStore ()
51- const sidebarStore = useSidebarStore ()
52- return { filesStore, signStore, sidebarStore }
53- },
54- computed: {
55- fileName () {
56- return this .filesStore .getFile ()? .name ?? ' '
57- },
58- subTitle () {
59- if (! this .opened ) {
60- return t (' libresign' , ' Enter who will receive the request' )
61- }
62- return this .filesStore .getSubtitle ()
63- },
64- showRequestSignatureTab () {
65- return this .sidebarStore .activeTab === ' request-signature-tab'
66- },
67- showSign () {
68- return this .sidebarStore .activeTab === ' sign-tab'
69- },
70- },
71- watch: {
72- ' sidebarStore.activeTab' (newValue, previousValue) {
73- if (this .$refs ? .rightAppSidebar ? .$refs ? .tabs ) {
74- this .$refs .rightAppSidebar .$refs .tabs .activeTab = newValue
75- }
76- },
77- ' $route.name' (routeName) {
78- this .sidebarStore .handleRouteChange (routeName)
79- },
80- },
81- methods: {
82- t,
83- handleUpdateActive (active ) {
84- this .sidebarStore .setActiveTab (active)
85- },
86- closeSidebar () {
87- this .sidebarStore .hideSidebar ()
88- },
89- },
44+ })
45+
46+ type SidebarRef = {
47+ $refs? : {
48+ tabs? : {
49+ activeTab? : string
50+ }
51+ }
9052}
53+
54+ const filesStore = useFilesStore ()
55+ const signStore = useSignStore ()
56+ const sidebarStore = useSidebarStore ()
57+ const route = useRoute ()
58+ const rightAppSidebar = ref <SidebarRef | null >(null )
59+
60+ const fileName = computed (() => filesStore .getFile ()?.name ?? ' ' )
61+ const opened = computed (() => sidebarStore .isVisible )
62+ const subTitle = computed (() => {
63+ if (! opened .value ) {
64+ return t (' libresign' , ' Enter who will receive the request' )
65+ }
66+ return filesStore .getSubtitle ()
67+ })
68+
69+ const showRequestSignatureTab = computed (() => sidebarStore .activeTab === ' request-signature-tab' )
70+ const showSign = computed (() => sidebarStore .activeTab === ' sign-tab' )
71+
72+ watch (() => sidebarStore .activeTab , (newValue ) => {
73+ if (rightAppSidebar .value ?.$refs ?.tabs ) {
74+ rightAppSidebar .value .$refs .tabs .activeTab = newValue
75+ }
76+ })
77+
78+ watch (() => route .name , (routeName ) => {
79+ sidebarStore .handleRouteChange (routeName )
80+ })
81+
82+ function handleUpdateActive(active : string ) {
83+ sidebarStore .setActiveTab (active )
84+ }
85+
86+ function closeSidebar() {
87+ sidebarStore .hideSidebar ()
88+ }
89+
90+ defineExpose ({
91+ filesStore ,
92+ signStore ,
93+ sidebarStore ,
94+ rightAppSidebar ,
95+ fileName ,
96+ opened ,
97+ subTitle ,
98+ showRequestSignatureTab ,
99+ showSign ,
100+ handleUpdateActive ,
101+ closeSidebar ,
102+ })
91103 </script >
92104<style lang="scss" scoped>
93105.app-sidebar__tab {
0 commit comments