-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathFilesList.vue
More file actions
228 lines (208 loc) · 5.7 KB
/
FilesList.vue
File metadata and controls
228 lines (208 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!--
- SPDX-FileCopyrightText: 2024 LibreCode coop and LibreCode contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcAppContent :page-heading="t('libresign', 'Files')">
<div class="files-list__header">
<NcBreadcrumbs class="files-list__breadcrumbs">
<NcBreadcrumb :name="t('libresign', 'Files')"
:title="t('libresign', 'Files')"
:exact="true"
:force-icon-text="true"
:to="{ name: 'fileslist' }"
:aria-description="t('libresign', 'Files')"
:disable-drop="true"
@click.native="refresh()">
<template #icon>
<NcIconSvgWrapper :size="20"
:svg="viewIcon" />
</template>
</NcBreadcrumb>
<template #actions>
<RequestPicker />
</template>
</NcBreadcrumbs>
<NcLoadingIcon v-if="isRefreshing" class="files-list__refresh-icon" />
<NcButton :aria-label="gridViewButtonLabel"
:title="gridViewButtonLabel"
class="files-list__header-grid-button"
type="tertiary"
@click="toggleGridView">
<template #icon>
<ListViewIcon v-if="userConfigStore.grid_view" />
<ViewGridIcon v-else />
</template>
</NcButton>
</div>
<FilesListVirtual :nodes="dirContentsSorted"
:loading="loading">
<template #empty>
<NcLoadingIcon
v-if="loading && !isRefreshing"
class="files-list__loading-icon"
:size="38"
:name="t('libresign', 'Loading …')" />
<NcEmptyContent
v-else-if="!loading && isEmptyDir && filtersStore.activeChips.length === 0"
:name="t('libresign', 'There are no documents')"
:description="canRequestSign ? t('libresign', 'Choose the file to request signatures.') : ''">
<template v-if="canRequestSign" #action>
<RequestPicker />
</template>
<template #icon>
<FolderIcon />
</template>
</NcEmptyContent>
<NcEmptyContent
v-else-if="!loading && isEmptyDir && filtersStore.activeChips.length > 0"
:name="t('libresign', 'No documents found')">
<template #icon>
<FolderIcon />
</template>
</NcEmptyContent>
</template>
</FilesListVirtual>
</NcAppContent>
</template>
<script>
import HomeSvg from '@mdi/svg/svg/home.svg?raw'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import ListViewIcon from 'vue-material-design-icons/FormatListBulletedSquare.vue'
import ViewGridIcon from 'vue-material-design-icons/ViewGrid.vue'
import { loadState } from '@nextcloud/initial-state'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcBreadcrumb from '@nextcloud/vue/components/NcBreadcrumb'
import NcBreadcrumbs from '@nextcloud/vue/components/NcBreadcrumbs'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
import FilesListVirtual from './FilesListVirtual.vue'
import RequestPicker from '../../Components/Request/RequestPicker.vue'
import { useFilesStore } from '../../store/files.js'
import { useFiltersStore } from '../../store/filters.js'
import { useUserConfigStore } from '../../store/userconfig.js'
export default {
name: 'FilesList',
components: {
NcAppContent,
NcButton,
ListViewIcon,
ViewGridIcon,
NcLoadingIcon,
FolderIcon,
NcBreadcrumb,
NcBreadcrumbs,
NcIconSvgWrapper,
FilesListVirtual,
RequestPicker,
NcEmptyContent,
},
setup() {
const filesStore = useFilesStore()
const filtersStore = useFiltersStore()
const userConfigStore = useUserConfigStore()
return {
filesStore,
filtersStore,
userConfigStore,
}
},
data() {
return {
loading: true,
dirContentsFiltered: [],
canRequestSign: loadState('libresign', 'can_request_sign', false),
}
},
computed: {
viewIcon() {
return HomeSvg
},
gridViewButtonLabel() {
return this.userConfigStore.grid_view
? t('libresign', 'Switch to list view')
: t('libresign', 'Switch to grid view')
},
dirContentsSorted() {
return this.filesStore.filesSorted()
},
isEmptyDir() {
return this.filesStore.filesSorted().length === 0
},
isRefreshing() {
return !this.isEmptyDir
&& this.loading
},
},
async mounted() {
await this.filesStore.getAllFiles({ force_fetch: true })
this.loading = false
this.filesStore.disableIdentifySigner()
},
beforeUnmount() {
this.filesStore.selectFile()
},
methods: {
refresh() {
this.filesStore.updateAllFiles()
},
toggleGridView() {
this.userConfigStore.update('grid_view', !this.userConfigStore.grid_view)
},
},
}
</script>
<style scoped lang="scss">
.app-content {
// Virtual list needs to be full height and is scrollable
display: flex;
overflow: hidden;
flex-direction: column;
max-height: 100%;
position: relative !important;
}
.files-list__breadcrumbs {
// Take as much space as possible
flex: 1 1 100% !important;
width: 100%;
height: 100%;
margin-block: 0;
margin-inline: 10px;
min-width: 0;
:deep() {
a {
cursor: pointer !important;
}
}
&--with-progress {
flex-direction: column !important;
align-items: flex-start !important;
}
}
.files-list {
&__header {
display: flex;
align-items: center;
// Do not grow or shrink (vertically)
flex: 0 0;
max-width: 100%;
// Align with the navigation toggle icon
margin-block: var(--app-navigation-padding, 4px);
margin-inline: calc(var(--default-clickable-area, 44px) + 2 * var(--app-navigation-padding, 4px)) var(--app-navigation-padding, 4px);
>* {
// Do not grow or shrink (horizontally)
flex: 0 0;
}
}
&__refresh-icon {
flex: 0 0 var(--default-clickable-area);
width: var(--default-clickable-area);
height: var(--default-clickable-area);
}
&__loading-icon {
margin: auto;
}
}
</style>