Former-commit-id: 4aab1964b9462d1fdee92999dd5a7d03f17b4457 [formerly 22352202547980b191886cf29f68ce8e9cc4c39b] [formerly 1a66bae34022092936c2912ea3a323a6984fe7e4 [formerly 1e7c4e6468b07dbb2b2726df4ff345371e2ec714]] Former-commit-id: 94170b15369b05e8f4985e88242ba453b5545116 [formerly 2a0b57bebcd48c0189974f4f9e72679b5c67f37b] Former-commit-id: 635be5ad2826c1659670997900122d024a46de24
78 lines
1.7 KiB
Vue
78 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 '../page'
|
|
import webdav from '../webdav'
|
|
|
|
var $ = window.info
|
|
|
|
export default {
|
|
name: 'rename-prompt',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
cancel: function (event) {
|
|
$.showRename = false
|
|
this.name = ''
|
|
},
|
|
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 = ''
|
|
$.showRename = false
|
|
return
|
|
}
|
|
}
|
|
}
|
|
</script>
|