mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-10 12:12:57 +00:00

progresses on sharing #192 Progresses on #192 Progresses on #192 Little API update Build assets Former-commit-id: 68e70132ea857eb65638c0496c030be1c181ed1c [formerly d67b74280b7f12c3e20de6abe31fcfc26e8f43ef] [formerly 8fe91e003c9616da23f0e673ad4bb89d792a41c8 [formerly 868434360592aa0280e0d631840750d53a564cd3]] Former-commit-id: 7d22ff468e580601d0c3e0921734b587b92484f8 [formerly 55f9d830636f9bbf15e0453d1ee7de6ee5d5191e] Former-commit-id: ad411a5979521dda9ea9683d86e4c8ae7b3c9e6f
79 lines
2.0 KiB
Vue
79 lines
2.0 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>{{ $t('prompts.rename') }}</h3>
|
|
<p>{{ $t('prompts.renameMessage') }} <code>{{ oldName() }}</code>:</p>
|
|
|
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
|
<div>
|
|
<button @click="submit"
|
|
type="submit"
|
|
:aria-label="$t('buttons.rename')"
|
|
:title="$t('buttons.rename')">{{ $t('buttons.rename') }}</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 { mapState } from 'vuex'
|
|
import url from '@/utils/url'
|
|
import * as api from '@/utils/api'
|
|
|
|
export default {
|
|
name: 'rename',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
computed: mapState(['req', 'selected', 'selectedCount']),
|
|
methods: {
|
|
cancel: function (event) {
|
|
this.$store.commit('closeHovers')
|
|
},
|
|
oldName: function () {
|
|
// Get the current name of the file we are editing.
|
|
if (this.req.kind !== 'listing') {
|
|
return this.req.name
|
|
}
|
|
|
|
if (this.selectedCount === 0 || this.selectedCount > 1) {
|
|
// This shouldn't happen.
|
|
return
|
|
}
|
|
|
|
return this.req.items[this.selected[0]].name
|
|
},
|
|
submit: function (event) {
|
|
let oldLink = ''
|
|
let newLink = ''
|
|
|
|
if (this.req.kind !== 'listing') {
|
|
oldLink = this.req.url
|
|
} else {
|
|
oldLink = this.req.items[this.selected[0]].url
|
|
}
|
|
|
|
this.name = encodeURIComponent(this.name)
|
|
newLink = url.removeLastDir(oldLink) + '/' + this.name
|
|
|
|
api.move([{ from: oldLink, to: newLink }])
|
|
.then(() => {
|
|
if (this.req.kind !== 'listing') {
|
|
this.$router.push({ path: newLink })
|
|
return
|
|
}
|
|
this.$store.commit('setReload', true)
|
|
}).catch(error => {
|
|
this.$store.commit('showError', error)
|
|
})
|
|
|
|
this.$store.commit('closeHovers')
|
|
}
|
|
}
|
|
}
|
|
</script>
|