Improvements and more reliability :)

Former-commit-id: 4d5ca1dd46c57e35222860a66c9f98f945fbaad7 [formerly 5a0bea68d0ddec09c95919c1ef45bdff3f602bc6] [formerly b324db325f094e5563f945c41f4f9eeb0b2df086 [formerly 698a08e1a9]]
Former-commit-id: 6c39601f33482edafad63f4b39e10e2720db2813 [formerly 02a9c37289ce3d27eee55f3eb3052391349adc0e]
Former-commit-id: fd29981acff35fa5428af5e1d95fe1d53bba0459
This commit is contained in:
Henrique Dias
2017-06-30 17:49:05 +01:00
parent 713e89eb68
commit c7e37c09e1
17 changed files with 239 additions and 300 deletions

View File

@@ -11,11 +11,10 @@
</template>
<script>
import { mapState } from 'vuex'
import page from '../utils/page'
import webdav from '../utils/webdav'
var $ = window.info
export default {
name: 'rename-prompt',
data: function () {
@@ -23,30 +22,31 @@ export default {
name: ''
}
},
computed: mapState(['req', 'selected', 'selectedCount']),
methods: {
cancel: function (event) {
this.$store.commit('showRename', false)
},
oldName: function () {
if ($.req.kind !== 'listing') {
return $.req.data.name
if (this.req.kind !== 'listing') {
return this.req.data.name
}
if ($.selected.length === 0 || $.selected.length > 1) {
if (this.selectedCount === 0 || this.selectedCount > 1) {
// This shouldn't happen.
return
}
return $.req.data.items[$.selected[0]].name
return this.req.data.items[this.selected[0]].name
},
submit: function (event) {
let oldLink = ''
let newLink = ''
if ($.req.kind !== 'listing') {
oldLink = $.req.data.url
if (this.req.kind !== 'listing') {
oldLink = this.req.data.url
} else {
oldLink = $.req.data.items[$.selected[0]].url
oldLink = this.req.data.items[this.selected[0]].url
}
newLink = page.removeLastDir(oldLink) + '/' + this.name
@@ -55,7 +55,7 @@ export default {
webdav.move(oldLink, newLink)
.then(() => {
if ($.req.kind !== 'listing') {
if (this.req.kind !== 'listing') {
page.open(newLink)
return
}
@@ -67,7 +67,6 @@ export default {
console.log(error)
})
this.name = ''
this.$store.commit('showRename', false)
return
}