Former-commit-id: 2928727a06a94c0ea87ed821a472ae662df803d1 [formerly 098bc4234803078aba013f6312d179158194fffb] [formerly d2bb681fe62ba87a29b9866e291fb975489cd3fc [formerly 3d25185a557dab1fa529499572c0e6d5bf187ca1]] Former-commit-id: 288ccb95466fbd234d278886800e1d27c54fa8dd [formerly 78c473865b085e97cf435cb230e2afa85559aba0] Former-commit-id: c5dc56f4d6198c9c306c01573e1a1af5f1827c3a
54 lines
1.2 KiB
Vue
54 lines
1.2 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>New file</h3>
|
|
<p>Write the name of the new file.</p>
|
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
|
<div>
|
|
<button class="ok" @click="submit">Create</button>
|
|
<button class="cancel" @click="$store.commit('showNewFile', false)">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import page from '../utils/page'
|
|
import webdav from '../utils/webdav'
|
|
|
|
export default {
|
|
name: 'new-file-prompt',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function (event) {
|
|
event.preventDefault()
|
|
if (this.new === '') return
|
|
|
|
let url = window.location.pathname
|
|
if (this.$store.state.req.kind !== 'listing') {
|
|
url = page.removeLastDir(url) + '/'
|
|
}
|
|
|
|
url += this.name
|
|
url = url.replace('//', '/')
|
|
|
|
// buttons.setLoading('newFile')
|
|
webdav.create(url)
|
|
.then(() => {
|
|
// buttons.setDone('newFile')
|
|
page.open(url)
|
|
})
|
|
.catch(e => {
|
|
// buttons.setDone('newFile', false)
|
|
console.log(e)
|
|
})
|
|
|
|
this.$store.commit('showNewFile', false)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|