7575 </NcButton >
7676 </template >
7777 </NcDialog >
78- <EditNameDialog v-if =" showEnvelopeNameModal"
79- :open =" showEnvelopeNameModal"
80- :name =" envelopeName"
81- :title =" t('libresign', 'Envelope name')"
82- :label =" t('libresign', 'Enter a name for the envelope')"
83- :placeholder =" t('libresign', 'Envelope name')"
84- :loading =" loading"
85- @save =" confirmEnvelopeName"
86- @close =" cancelEnvelopeName" />
8778 </div >
8879</template >
8980<script >
@@ -97,6 +88,7 @@ import { getCapabilities } from '@nextcloud/capabilities'
9788import { showError } from ' @nextcloud/dialogs'
9889import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
9990import { loadState } from ' @nextcloud/initial-state'
91+ import { spawnDialog } from ' @nextcloud/vue/functions/dialog'
10092
10193import NcActionButton from ' @nextcloud/vue/components/NcActionButton'
10294import NcActions from ' @nextcloud/vue/components/NcActions'
@@ -116,7 +108,6 @@ export default {
116108 name: ' RequestPicker' ,
117109 components: {
118110 CloudUploadIcon,
119- EditNameDialog,
120111 FilePicker,
121112 FolderIcon,
122113 LinkIcon,
@@ -160,8 +151,6 @@ export default {
160151 uploadedBytes: 0 ,
161152 totalBytes: 0 ,
162153 uploadStartTime: null ,
163- showEnvelopeNameModal: false ,
164- envelopeName: ' ' ,
165154 pendingPaths: [],
166155 pendingFiles: [],
167156 }
@@ -290,9 +279,20 @@ export default {
290279
291280 if (files .length > 1 && this .envelopeEnabled ) {
292281 this .pendingFiles = files
293- this .envelopeName = ' '
294- this .showEnvelopeNameModal = true
282+ const [envelopeName ] = await spawnDialog (
283+ EditNameDialog,
284+ {
285+ title: this .t (' libresign' , ' Envelope name' ),
286+ label: this .t (' libresign' , ' Enter a name for the envelope' ),
287+ placeholder: this .t (' libresign' , ' Envelope name' ),
288+ },
289+ )
295290 input .remove ()
291+
292+ if (envelopeName) {
293+ await this .upload (files, envelopeName)
294+ }
295+ this .pendingFiles = []
296296 return
297297 }
298298
@@ -329,8 +329,36 @@ export default {
329329
330330 if (this .envelopeEnabled && paths .length > 1 ) {
331331 this .pendingPaths = paths
332- this .envelopeName = ' '
333- this .showEnvelopeNameModal = true
332+ const [envelopeName ] = await spawnDialog (
333+ EditNameDialog,
334+ {
335+ title: this .t (' libresign' , ' Envelope name' ),
336+ label: this .t (' libresign' , ' Enter a name for the envelope' ),
337+ placeholder: this .t (' libresign' , ' Envelope name' ),
338+ },
339+ )
340+
341+ if (envelopeName) {
342+ const filesPayload = paths .map ((path ) => ({
343+ file: { path },
344+ name: (path .match (/ ([^ /] *? )(?:\. [^ . ] * )? $ / )[1 ] ?? ' ' ),
345+ }))
346+ await this .filesStore .upload ({
347+ files: filesPayload,
348+ name: envelopeName .trim (),
349+ })
350+ .then ((fileId ) => {
351+ this .filesStore .selectFile (fileId)
352+ })
353+ .catch (({ response }) => {
354+ showError (response? .data ? .ocs ? .data ? .message || this .t (' libresign' , ' Upload failed' ))
355+ })
356+ .finally (() => {
357+ this .pendingPaths = []
358+ })
359+ } else {
360+ this .pendingPaths = []
361+ }
334362 return
335363 }
336364
@@ -348,41 +376,6 @@ export default {
348376 showError (response .data .ocs .data .message )
349377 })
350378 },
351- confirmEnvelopeName (newName ) {
352- this .envelopeName = newName
353- this .showEnvelopeNameModal = false
354-
355- if (this .pendingPaths .length > 0 ) {
356- const filesPayload = this .pendingPaths .map ((path ) => ({
357- file: { path },
358- name: (path .match (/ ([^ /] *? )(?:\. [^ . ] * )? $ / )[1 ] ?? ' ' ),
359- }))
360- this .filesStore .upload ({
361- files: filesPayload,
362- name: this .envelopeName .trim (),
363- })
364- .then ((fileId ) => {
365- this .filesStore .selectFile (fileId)
366- })
367- .catch (({ response }) => {
368- showError (response? .data ? .ocs ? .data ? .message || t (' libresign' , ' Upload failed' ))
369- })
370- .finally (() => {
371- this .pendingPaths = []
372- this .envelopeName = ' '
373- })
374- return
375- }
376-
377- const files = this .pendingFiles
378- this .upload (files)
379- },
380- cancelEnvelopeName () {
381- this .pendingFiles = []
382- this .pendingPaths = []
383- this .envelopeName = ' '
384- this .showEnvelopeNameModal = false
385- },
386379 },
387380}
388381< / script>
0 commit comments