Former-commit-id: c14972384cc8afad28d49388b0b4545669e20b7d [formerly 0af2e5f9aff2aac576044ca9590045f656fbffda] [formerly 02248a86b7063e1c9d6779c3574a848708ff86f2 [formerly efaa8439a9]]
Former-commit-id: 4ce0a81ea04b56cef11d62107d692502e266a16e [formerly 2c46db9398c267351c10f06c089ed08dc3625232]
Former-commit-id: 1c93a0643217ab69668600b41e2d8263266d7e23
51 lines
1.1 KiB
Vue
51 lines
1.1 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('closeHovers')">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import url from '@/utils/url'
|
|
import api from '@/utils/api'
|
|
|
|
export default {
|
|
name: 'new-file',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function (event) {
|
|
event.preventDefault()
|
|
if (this.new === '') return
|
|
|
|
let uri = this.$route.path
|
|
if (this.$store.state.req.kind !== 'listing') {
|
|
uri = url.removeLastDir(uri) + '/'
|
|
}
|
|
|
|
uri += this.name
|
|
uri = uri.replace('//', '/')
|
|
|
|
api.post(uri)
|
|
.then(() => {
|
|
this.$router.push({ path: uri })
|
|
})
|
|
.catch(error => {
|
|
this.$store.commit('showError', error)
|
|
})
|
|
|
|
this.$store.commit('closeHovers')
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|