JS design
Former-commit-id: 46ef678067f79997b35a86931a324e8404d4db98 [formerly 16e52ff387b32d4dcbec9bfe6132ea71192f331a] [formerly 985b6e3050f66c3131f1c62aab9a5dbe025437f2 [formerly fc71509dd0
]]
Former-commit-id: acffffe9de1e64b90cc0cc0eb2dff9e367c70d88 [formerly af4f7056c6fb45b96e115b182e7ab2303fc39159]
Former-commit-id: 17d369064f83ebf81d7374b92245c9003f86efbe
pull/726/head
parent
562a3862e0
commit
deef004513
|
@ -34,6 +34,10 @@
|
||||||
<i class="material-icons">error</i>
|
<i class="material-icons">error</i>
|
||||||
<span>You're not welcome here.</span>
|
<span>You're not welcome here.</span>
|
||||||
</h2>
|
</h2>
|
||||||
|
<h2 class="message" v-else>
|
||||||
|
<i class="material-icons">error_outline</i>
|
||||||
|
<span>Something really went wrong.</span>
|
||||||
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<editor v-else-if="isEditor"></editor>
|
<editor v-else-if="isEditor"></editor>
|
||||||
<listing v-else-if="isListing"></listing>
|
<listing v-else-if="isListing"></listing>
|
||||||
|
@ -132,7 +136,7 @@ export default {
|
||||||
window.addEventListener('keydown', (event) => {
|
window.addEventListener('keydown', (event) => {
|
||||||
// Esc!
|
// Esc!
|
||||||
if (event.keyCode === 27) {
|
if (event.keyCode === 27) {
|
||||||
this.$store.commit('resetPrompts')
|
this.$store.commit('closePrompts')
|
||||||
|
|
||||||
// Unselect all files and folders.
|
// Unselect all files and folders.
|
||||||
if (this.req.kind === 'listing') {
|
if (this.req.kind === 'listing') {
|
||||||
|
@ -150,20 +154,20 @@ export default {
|
||||||
// Del!
|
// Del!
|
||||||
if (event.keyCode === 46) {
|
if (event.keyCode === 46) {
|
||||||
if (this.showDeleteButton()) {
|
if (this.showDeleteButton()) {
|
||||||
this.$store.commit('showDelete', true)
|
this.$store.commit('showPrompt', 'delete')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// F1!
|
// F1!
|
||||||
if (event.keyCode === 112) {
|
if (event.keyCode === 112) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.$store.commit('showHelp', true)
|
this.$store.commit('showPrompt', 'help')
|
||||||
}
|
}
|
||||||
|
|
||||||
// F2!
|
// F2!
|
||||||
if (event.keyCode === 113) {
|
if (event.keyCode === 113) {
|
||||||
if (this.showRenameButton()) {
|
if (this.showRenameButton()) {
|
||||||
this.$store.commit('showRename', true)
|
this.$store.commit('showPrompt', 'rename')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,11 +189,14 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchData () {
|
fetchData () {
|
||||||
|
// Set loading to true and reset the error.
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.error = null
|
this.error = null
|
||||||
|
|
||||||
// Reset selected items and multiple selection.
|
// Reset selected items and multiple selection.
|
||||||
this.$store.commit('resetSelected')
|
this.$store.commit('resetSelected')
|
||||||
this.$store.commit('multiple', false)
|
this.$store.commit('multiple', false)
|
||||||
|
this.$store.commit('closePrompts')
|
||||||
|
|
||||||
let url = this.$route.path
|
let url = this.$route.path
|
||||||
if (url === '') url = '/'
|
if (url === '') url = '/'
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<div v-if="user.allowNew">
|
<div v-if="user.allowNew">
|
||||||
<button @click="$store.commit('showNewDir', true)" aria-label="New directory" title="New directory" class="action">
|
<button @click="$store.commit('showPrompt', 'newDir')" aria-label="New directory" title="New directory" class="action">
|
||||||
<i class="material-icons">create_new_folder</i>
|
<i class="material-icons">create_new_folder</i>
|
||||||
<span>New folder</span>
|
<span>New folder</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button @click="$store.commit('showNewFile', true)" aria-label="New file" title="New file" class="action">
|
<button @click="$store.commit('showPrompt', 'newFile')" aria-label="New file" title="New file" class="action">
|
||||||
<i class="material-icons">note_add</i>
|
<i class="material-icons">note_add</i>
|
||||||
<span>New file</span>
|
<span>New file</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default {
|
||||||
name: 'delete-button',
|
name: 'delete-button',
|
||||||
methods: {
|
methods: {
|
||||||
show: function (event) {
|
show: function (event) {
|
||||||
this.$store.commit('showDelete', true)
|
this.$store.commit('showPrompt', 'delete')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit('showDownload', true)
|
this.$store.commit('showPrompt', 'download')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<button title="Info" aria-label="Info" class="action" @click="$store.commit('showInfo', true)">
|
<button title="Info" aria-label="Info" class="action" @click="this.$store.commit('showPrompt', 'info')">
|
||||||
<i class="material-icons">info</i>
|
<i class="material-icons">info</i>
|
||||||
<span>Info</span>
|
<span>Info</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<button @click="$store.commit('showMove', true)" aria-label="Move" title="Move" class="action">
|
<button @click="this.$store.commit('showPrompt', 'move')" aria-label="Move" title="Move" class="action">
|
||||||
<i class="material-icons">forward</i>
|
<i class="material-icons">forward</i>
|
||||||
<span>Move file</span>
|
<span>Move file</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<button @click="$store.commit('showRename', true)" aria-label="Rename" title="Rename" class="action">
|
<button @click="this.$store.commit('showPrompt', 'rename')" aria-label="Rename" title="Rename" class="action">
|
||||||
<i class="material-icons">mode_edit</i>
|
<i class="material-icons">mode_edit</i>
|
||||||
<span>Rename</span>
|
<span>Rename</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -22,9 +22,9 @@ export default {
|
||||||
...mapState(['req', 'selected'])
|
...mapState(['req', 'selected'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['showDelete']),
|
...mapMutations(['closePrompts']),
|
||||||
submit: function (event) {
|
submit: function (event) {
|
||||||
this.showDelete(false)
|
this.closePrompts()
|
||||||
// buttons.setLoading('delete')
|
// buttons.setLoading('delete')
|
||||||
|
|
||||||
if (this.req.kind !== 'listing') {
|
if (this.req.kind !== 'listing') {
|
||||||
|
|
|
@ -39,6 +39,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(uri)
|
window.open(uri)
|
||||||
|
this.$store.commit('closePrompts')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" @click="$store.commit('showHelp', false)" class="ok">OK</button>
|
<button type="submit" @click="$store.commit('closePrompts')" class="ok">OK</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" @click="$store.commit('showInfo', false)" class="ok">OK</button>
|
<button type="submit" @click="$store.commit('closePrompts')" class="ok">OK</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button class="ok" @click="move">Move</button>
|
<button class="ok" @click="move">Move</button>
|
||||||
<button class="cancel" @click="$store.commit('showMove', false)">Cancel</button>
|
<button class="cancel" @click="$store.commit('closePrompts')">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
||||||
<div>
|
<div>
|
||||||
<button class="ok" @click="submit">Create</button>
|
<button class="ok" @click="submit">Create</button>
|
||||||
<button class="cancel" @click="$store.commit('showNewDir', false)">Cancel</button>
|
<button class="cancel" @click="$store.commit('closePrompts')">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.$store.commit('showNewDir', false)
|
this.$store.commit('closePrompts')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
|
||||||
<div>
|
<div>
|
||||||
<button class="ok" @click="submit">Create</button>
|
<button class="ok" @click="submit">Create</button>
|
||||||
<button class="cancel" @click="$store.commit('showNewFile', false)">Cancel</button>
|
<button class="cancel" @click="$store.commit('closePrompts')">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.$store.commit('showNewFile', false)
|
this.$store.commit('closePrompts')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import Download from './Download'
|
||||||
import Move from './Move'
|
import Move from './Move'
|
||||||
import NewFile from './NewFile'
|
import NewFile from './NewFile'
|
||||||
import NewDir from './NewDir'
|
import NewDir from './NewDir'
|
||||||
import {mapGetters, mapState} from 'vuex'
|
import {mapGetters} from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'prompts',
|
name: 'prompts',
|
||||||
|
@ -37,9 +37,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'showOverlay'
|
'showOverlay',
|
||||||
]),
|
|
||||||
...mapState([
|
|
||||||
'showInfo',
|
'showInfo',
|
||||||
'showHelp',
|
'showHelp',
|
||||||
'showDelete',
|
'showDelete',
|
||||||
|
@ -52,7 +50,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetPrompts () {
|
resetPrompts () {
|
||||||
this.$store.commit('resetPrompts')
|
this.$store.commit('closePrompts')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
computed: mapState(['req', 'selected', 'selectedCount']),
|
computed: mapState(['req', 'selected', 'selectedCount']),
|
||||||
methods: {
|
methods: {
|
||||||
cancel: function (event) {
|
cancel: function (event) {
|
||||||
this.$store.commit('showRename', false)
|
this.$store.commit('closePrompts')
|
||||||
},
|
},
|
||||||
oldName: function () {
|
oldName: function () {
|
||||||
if (this.req.kind !== 'listing') {
|
if (this.req.kind !== 'listing') {
|
||||||
|
@ -68,7 +68,7 @@ export default {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.$store.commit('showRename', false)
|
this.$store.commit('closePrompts')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
const getters = {
|
const getters = {
|
||||||
showOverlay: state => {
|
showInfo: state => (state.prompt === 'info'),
|
||||||
return state.showInfo ||
|
showHelp: state => (state.prompt === 'help'),
|
||||||
state.showHelp ||
|
showDelete: state => (state.prompt === 'delete'),
|
||||||
state.showDelete ||
|
showRename: state => (state.prompt === 'rename'),
|
||||||
state.showRename ||
|
showMove: state => (state.prompt === 'move'),
|
||||||
state.showMove ||
|
showNewFile: state => (state.prompt === 'newFile'),
|
||||||
state.showNewFile ||
|
showNewDir: state => (state.prompt === 'newDir'),
|
||||||
state.showNewDir ||
|
showDownload: state => (state.prompt === 'download'),
|
||||||
state.showDownload
|
showOverlay: state => (state.prompt !== null),
|
||||||
},
|
|
||||||
selectedCount: state => state.selected.length
|
selectedCount: state => state.selected.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,7 @@
|
||||||
const mutations = {
|
const mutations = {
|
||||||
showInfo: (state, value) => (state.showInfo = value),
|
closePrompts: (state) => { state.prompt = null },
|
||||||
showHelp: (state, value) => (state.showHelp = value),
|
showPrompt: (state, value) => { state.prompt = value },
|
||||||
showDelete: (state, value) => (state.showDelete = value),
|
setReload: (state, value) => { state.reload = value },
|
||||||
showRename: (state, value) => (state.showRename = value),
|
|
||||||
showMove: (state, value) => (state.showMove = value),
|
|
||||||
showNewFile: (state, value) => (state.showNewFile = value),
|
|
||||||
showNewDir: (state, value) => (state.showNewDir = value),
|
|
||||||
showDownload: (state, value) => (state.showDownload = value),
|
|
||||||
resetPrompts: (state) => {
|
|
||||||
state.showHelp = false
|
|
||||||
state.showInfo = false
|
|
||||||
state.showDelete = false
|
|
||||||
state.showRename = false
|
|
||||||
state.showMove = false
|
|
||||||
state.showNewFile = false
|
|
||||||
state.showNewDir = false
|
|
||||||
state.showDownload = false
|
|
||||||
},
|
|
||||||
setReload: (state, value) => (state.reload = value),
|
|
||||||
setUser: (state, value) => (state.user = value),
|
setUser: (state, value) => (state.user = value),
|
||||||
setJWT: (state, value) => (state.jwt = value),
|
setJWT: (state, value) => (state.jwt = value),
|
||||||
multiple: (state, value) => (state.multiple = value),
|
multiple: (state, value) => (state.multiple = value),
|
||||||
|
|
|
@ -14,14 +14,7 @@ const state = {
|
||||||
reload: false,
|
reload: false,
|
||||||
selected: [],
|
selected: [],
|
||||||
multiple: false,
|
multiple: false,
|
||||||
showInfo: false,
|
prompt: null
|
||||||
showHelp: false,
|
|
||||||
showDelete: false,
|
|
||||||
showRename: false,
|
|
||||||
showMove: false,
|
|
||||||
showNewFile: false,
|
|
||||||
showNewDir: false,
|
|
||||||
showDownload: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
|
|
Loading…
Reference in New Issue