2020 *
2121 */
2222
23+ import { getCurrentDirectory } from '../helpers/filesApp'
2324import Types from '../helpers/types'
2425import { createEmptyFile } from '../services/api'
2526import { generateUrl , generateFilePath , generateOcsUrl } from '@nextcloud/router'
@@ -91,7 +92,7 @@ const NewFileMenu = {
9192 const fileAction = OCA . Files . fileActions . getDefaultFileAction ( fileModel . get ( 'mimetype' ) , 'file' , OC . PERMISSION_ALL )
9293 fileAction . action ( filename , {
9394 $file : null ,
94- dir : FileList . getCurrentDirectory ( ) ,
95+ dir : getCurrentDirectory ( ) ,
9596 FileList,
9697 fileActions : FileList . fileActions ,
9798 } )
@@ -102,16 +103,18 @@ const NewFileMenu = {
102103 } ,
103104
104105 _createDocumentFromTemplate ( templateId , mimetype , filename ) {
106+ const dir = getCurrentDirectory ( )
105107 OCA . Files . Files . isFileNameValid ( filename )
106108 filename = FileList . getUniqueName ( filename )
109+
107110 $ . post (
108111 generateUrl ( 'apps/richdocuments/ajax/documents/create' ) ,
109- { mimetype, filename, dir : document . getElementById ( 'dir' ) . value } ,
112+ { mimetype, filename, dir } ,
110113 function ( response ) {
111114 if ( response && response . status === 'success' ) {
112115 FileList . add ( response . data , { animate : false , scrollTo : false } )
113116 const fileModel = FileList . getModelForFile ( filename )
114- const path = document . getElementById ( ' dir' ) . value + '/' + filename
117+ const path = dir + '/' + filename
115118 OCA . RichDocuments . openWithTemplate ( {
116119 fileId : - 1 ,
117120 path,
0 commit comments