44-->
55<template >
66 <div v-if =" enabledFlow" class =" documents" >
7- <h2 >{{ t('libresign', 'Your profile documents') }}</h2 >
7+ <h2 >{{ t('libresign', 'Identification documents') }}</h2 >
88
99 <NcLoadingIcon v-if =" loading" :size =" 44" />
1010
11- <ul v-else class =" documents-list" >
12- <NcListItem v-for =" (doc, index) in list"
13- :key =" `doc-${index}-${doc.nodeId}-${doc.file_type.key}`"
14- :name =" doc.file_type.name"
15- :bold =" false" >
16- <template #subname >
17- {{ doc.statusText }}
18- </template >
19- <template #actions >
20- <NcActionButton v-if =" doc.status === -1"
21- :aria-label =" t('libresign', 'Choose from Files')"
22- @click =" toggleFilePicker(doc.file_type.key)" >
23- <template #icon >
24- <FolderIcon :size =" 20" />
25- </template >
26- {{ t('libresign', 'Choose from Files') }}
27- </NcActionButton >
28- <NcActionButton v-if =" doc.status === -1"
29- :aria-label =" t('libresign', 'Upload file')"
30- @click =" inputFile(doc.file_type.key)" >
31- <template #icon >
32- <UploadIcon :size =" 20" />
33- </template >
34- {{ t('libresign', 'Upload file') }}
35- </NcActionButton >
36- <NcActionButton v-if =" doc.status !== -1"
37- :aria-label =" t('libresign', 'Delete file')"
38- @click =" deleteFile(doc)" >
39- <template #icon >
40- <DeleteIcon :size =" 20" />
41- </template >
42- {{ t('libresign', 'Delete file') }}
43- </NcActionButton >
44- </template >
45- </NcListItem >
46- </ul >
11+ <template v-else >
12+ <NcNoteCard v-if =" hasDocumentsWaitingApproval" type =" info" >
13+ {{ t('libresign', 'Your identification documents are waiting for approval.') }}
14+ </NcNoteCard >
15+
16+ <ul class =" documents-list" >
17+ <NcListItem v-for =" (doc, index) in list"
18+ :key =" `doc-${index}-${doc.nodeId}-${doc.file_type.key}`"
19+ :name =" doc.file_type.name"
20+ :bold =" false" >
21+ <template #subname >
22+ {{ doc.statusText }}
23+ </template >
24+ <template #actions >
25+ <NcActionButton v-if =" doc.status === -1"
26+ :aria-label =" t('libresign', 'Choose from Files')"
27+ @click =" toggleFilePicker(doc.file_type.key)" >
28+ <template #icon >
29+ <FolderIcon :size =" 20" />
30+ </template >
31+ {{ t('libresign', 'Choose from Files') }}
32+ </NcActionButton >
33+ <NcActionButton v-if =" doc.status === -1"
34+ :aria-label =" t('libresign', 'Upload file')"
35+ @click =" inputFile(doc.file_type.key)" >
36+ <template #icon >
37+ <UploadIcon :size =" 20" />
38+ </template >
39+ {{ t('libresign', 'Upload file') }}
40+ </NcActionButton >
41+ <NcActionButton v-if =" doc.status !== -1"
42+ :aria-label =" t('libresign', 'Delete file')"
43+ @click =" deleteFile(doc)" >
44+ <template #icon >
45+ <DeleteIcon :size =" 20" />
46+ </template >
47+ {{ t('libresign', 'Delete file') }}
48+ </NcActionButton >
49+ </template >
50+ </NcListItem >
51+ </ul >
52+ </template >
4753
4854 <FilePicker v-if =" showFilePicker"
4955 :name =" t('libresign', 'Select your file')"
5561</template >
5662
5763<script >
64+ import { translate as t } from ' @nextcloud/l10n'
5865import axios from ' @nextcloud/axios'
5966import { showError , showWarning , showSuccess } from ' @nextcloud/dialogs'
6067import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
@@ -63,30 +70,12 @@ import { generateOcsUrl } from '@nextcloud/router'
6370import NcActionButton from ' @nextcloud/vue/dist/Components/NcActionButton.js'
6471import NcListItem from ' @nextcloud/vue/dist/Components/NcListItem.js'
6572import NcLoadingIcon from ' @nextcloud/vue/dist/Components/NcLoadingIcon.js'
73+ import NcNoteCard from ' @nextcloud/vue/dist/Components/NcNoteCard.js'
6674
6775import DeleteIcon from ' vue-material-design-icons/Delete.vue'
6876import FolderIcon from ' vue-material-design-icons/Folder.vue'
6977import UploadIcon from ' vue-material-design-icons/Upload.vue'
7078
71- const FILE_TYPE_INFO = {
72- IDENTIFICATION : {
73- key: ' IDENTIFICATION' ,
74- name: t (' libresign' , ' Identification Document' ),
75- description: t (' libresign' , ' Identification Document' ),
76- },
77- }
78-
79- const findDocumentByType = (list , type ) => {
80- return list .find (row => row? .file_type ? .type === type) || {
81- nodeId: 0 ,
82- uuid: ' ' ,
83- status: - 1 ,
84- statusText: t (' libresign' , ' Not sent yet' ),
85- name: t (' libresign' , ' Not defined yet' ),
86- file_type: FILE_TYPE_INFO [type] || { type },
87- }
88- }
89-
9079const loadFileToBase64 = file => {
9180 return new Promise ((resolve , reject ) => {
9281 const reader = new FileReader ()
@@ -105,6 +94,7 @@ export default {
10594 NcActionButton,
10695 NcListItem,
10796 NcLoadingIcon,
97+ NcNoteCard,
10898 UploadIcon,
10999 },
110100 props: {
@@ -130,22 +120,45 @@ export default {
130120 type: ' primary' ,
131121 }]
132122 },
123+ fileTypeInfo () {
124+ return {
125+ IDENTIFICATION : {
126+ key: ' IDENTIFICATION' ,
127+ name: t (' libresign' , ' Identification Document' ),
128+ description: t (' libresign' , ' Identification Document' ),
129+ },
130+ }
131+ },
133132 documents () {
134133 return {
135- default: findDocumentByType (this .documentList , ' IDENTIFICATION' ),
134+ default: this . findDocumentByType (this .documentList , ' IDENTIFICATION' ),
136135 }
137136 },
138137 list () {
139138 return Object .values (this .documents )
140139 },
140+ hasDocumentsWaitingApproval () {
141+ return this .list .some (doc => doc .status === 2 )
142+ },
141143 enabledFlow () {
142- return loadState (' libresign' , ' config' ).identificationDocumentsFlow
144+ const config = loadState (' libresign' , ' config' , {})
145+ return config .identificationDocumentsFlow || false
143146 },
144147 },
145148 mounted () {
146149 this .loadDocuments ()
147150 },
148151 methods: {
152+ findDocumentByType (list , type ) {
153+ return list .find (row => row? .file_type ? .type === type) || {
154+ nodeId: 0 ,
155+ uuid: ' ' ,
156+ status: - 1 ,
157+ statusText: t (' libresign' , ' Not sent yet' ),
158+ name: t (' libresign' , ' Not defined yet' ),
159+ file_type: this .fileTypeInfo [type] || { type },
160+ }
161+ },
149162 toggleFilePicker (type ) {
150163 this .selectedType = type
151164 this .showFilePicker = ! this .showFilePicker
0 commit comments