Former-commit-id: 8fc595933b73d635bbe20e018958343d9dd3e31b [formerly c056d2fa20bec942e89710ff469e12cb07a498a9] [formerly a455096212ba0cb70102a99c714d8ff3e1401f17 [formerly 1861645b0421c2989def739a5d40aa7cde5a5288]] Former-commit-id: 794d333ef3a2788c5e76f7c1a558af8be1137c20 [formerly ab8ca7057862e8919a7d01c3d71ecd70ba7b32f3] Former-commit-id: 3430567351ec7425e167c4c128bb7316ff631eac
55 lines
1.3 KiB
Vue
55 lines
1.3 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>{{ $t('prompts.newDir') }}</h3>
|
|
<p>{{ $t('prompts.newDirMessage') }}</p>
|
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
|
<div>
|
|
<button class="ok"
|
|
:aria-label="$t('buttons.create')"
|
|
:title="$t('buttons.create')"
|
|
@click="submit">{{ $t('buttons.create') }}</button>
|
|
<button class="cancel"
|
|
@click="$store.commit('closeHovers')"
|
|
:aria-label="$t('buttons.cancel')"
|
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import url from '@/utils/url'
|
|
import api from '@/utils/api'
|
|
|
|
export default {
|
|
name: 'new-dir',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function (event) {
|
|
event.preventDefault()
|
|
if (this.new === '') return
|
|
|
|
// Build the path of the new directory.
|
|
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) })
|
|
|
|
// Close the prompt
|
|
this.$store.commit('closeHovers')
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|