You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
Former-commit-id: 9f1f09311813203910d5b323ba80712553ee2741 [formerly 0be00be1de305d786affc6bf0886aed9b20fbc51] [formerly 04597463117e94830b24b87faaaccf3d35284427 [formerly 3f2dc3f1c5]]
Former-commit-id: 8d26cc1d96faed73c7974ea7e5e78bf268af3ad9 [formerly a083ac8f68c90a636843c3565bd349657c0ec383]
Former-commit-id: ef10f3b3c388d65ceac40785b45dbac190a6cc99
77 lines
1.7 KiB
Vue
77 lines
1.7 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>Rename</h3>
|
|
<p>Insert a new name for <code>{{ oldName() }}</code>:</p>
|
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
|
<div>
|
|
<button @click="submit" type="submit">Rename</button>
|
|
<button @click="cancel" class="cancel">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import page from '../utils/page'
|
|
import webdav from '../utils/webdav'
|
|
|
|
var $ = window.info
|
|
|
|
export default {
|
|
name: 'rename-prompt',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
cancel: function (event) {
|
|
this.$store.commit('showRename', false)
|
|
},
|
|
oldName: function () {
|
|
if ($.req.kind !== 'listing') {
|
|
return $.req.data.name
|
|
}
|
|
|
|
if ($.selected.length === 0 || $.selected.length > 1) {
|
|
// This shouldn't happen.
|
|
return
|
|
}
|
|
|
|
return $.req.data.items[$.selected[0]].name
|
|
},
|
|
submit: function (event) {
|
|
let oldLink = ''
|
|
let newLink = ''
|
|
|
|
if ($.req.kind !== 'listing') {
|
|
oldLink = $.req.data.url
|
|
} else {
|
|
oldLink = $.req.data.items[$.selected[0]].url
|
|
}
|
|
|
|
newLink = page.removeLastDir(oldLink) + '/' + this.name
|
|
|
|
// buttons.setLoading('rename')
|
|
|
|
webdav.move(oldLink, newLink)
|
|
.then(() => {
|
|
if ($.req.kind !== 'listing') {
|
|
page.open(newLink)
|
|
return
|
|
}
|
|
// TODO: keep selected after reload?
|
|
page.reload()
|
|
// buttons.setDone('rename')
|
|
}).catch(error => {
|
|
// buttons.setDone('rename', false)
|
|
console.log(error)
|
|
})
|
|
|
|
this.name = ''
|
|
this.$store.commit('showRename', false)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
</script>
|