Updates on search and something

Former-commit-id: 229baefa76ee3202dcf4aac3249a461b6cc51eed [formerly 2773046c33eee1ff79ef1d02238de37e14860726] [formerly 2d50f10c3f809c6135cc861eaf0360092a23ea3f [formerly 14ff4f2b74c440888b632a6bacd338067dd0b588]]
Former-commit-id: e766887e65390514cf827700c3ab0d5ed000c480 [formerly 7429be72884d3eb154e45dc638fd17dfcfdfaa62]
Former-commit-id: d23373bf316295d6579e4bbc780f5b963c632c4d
This commit is contained in:
Henrique Dias 2017-07-04 17:15:38 +01:00
parent 9c0c2d7a02
commit 231e1e1147
21 changed files with 92 additions and 50 deletions

View File

@ -9,6 +9,9 @@
<search></search> <search></search>
</div> </div>
<div> <div>
<button @click="openSearch" aria-label="Search" title="Search" class="search-button action">
<i class="material-icons">search</i>
</button>
<rename-button v-show="!loading && showRenameButton()"></rename-button> <rename-button v-show="!loading && showRenameButton()"></rename-button>
<move-button v-show="!loading && showMoveButton()"></move-button> <move-button v-show="!loading && showMoveButton()"></move-button>
<delete-button v-show="!loading && showDeleteButton()"></delete-button> <delete-button v-show="!loading && showDeleteButton()"></delete-button>
@ -141,7 +144,7 @@ export default {
window.addEventListener('keydown', (event) => { window.addEventListener('keydown', (event) => {
// Esc! // Esc!
if (event.keyCode === 27) { if (event.keyCode === 27) {
this.$store.commit('closePrompts') this.$store.commit('closeHovers')
// Unselect all files and folders. // Unselect all files and folders.
if (this.req.kind === 'listing') { if (this.req.kind === 'listing') {
@ -159,20 +162,20 @@ export default {
// Del! // Del!
if (event.keyCode === 46) { if (event.keyCode === 46) {
if (this.showDeleteButton()) { if (this.showDeleteButton()) {
this.$store.commit('showPrompt', 'delete') this.$store.commit('showHover', 'delete')
} }
} }
// F1! // F1!
if (event.keyCode === 112) { if (event.keyCode === 112) {
event.preventDefault() event.preventDefault()
this.$store.commit('showPrompt', 'help') this.$store.commit('showHover', 'help')
} }
// F2! // F2!
if (event.keyCode === 113) { if (event.keyCode === 113) {
if (this.showRenameButton()) { if (this.showRenameButton()) {
this.$store.commit('showPrompt', 'rename') this.$store.commit('showHover', 'rename')
} }
} }
@ -201,7 +204,7 @@ export default {
// 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') this.$store.commit('closeHovers')
let url = this.$route.path let url = this.$route.path
if (url === '') url = '/' if (url === '') url = '/'
@ -224,6 +227,9 @@ export default {
this.loading = false this.loading = false
}) })
}, },
openSearch () {
this.$store.commit('showHover', 'search')
},
showUpload: function () { showUpload: function () {
if (this.req.kind === 'editor') return false if (this.req.kind === 'editor') return false
return this.user.allowNew return this.user.allowNew

View File

@ -41,7 +41,6 @@ export default {
data: function () { data: function () {
return { return {
value: '', value: '',
active: false,
ongoing: false, ongoing: false,
scrollable: null, scrollable: null,
search: [], search: [],
@ -49,7 +48,11 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['user']), ...mapState(['user', 'show']),
// Computed property for activeness of search.
active () {
return (this.show === 'search')
},
// Placeholder value. // Placeholder value.
placeholder: function () { placeholder: function () {
if (this.user.allowCommands && this.user.commands.length > 0) { if (this.user.allowCommands && this.user.commands.length > 0) {
@ -88,14 +91,14 @@ export default {
// when it's pressed, it closes the search window. // when it's pressed, it closes the search window.
window.addEventListener('keydown', (event) => { window.addEventListener('keydown', (event) => {
if (event.keyCode === 27) { if (event.keyCode === 27) {
this.active = false this.$store.commit('closeHovers')
} }
}) })
}, },
methods: { methods: {
// Sets the search to active. // Sets the search to active.
open: function (event) { open: function (event) {
this.active = true this.$store.commit('showHover', 'search')
}, },
// Closes the search and prevents the event // Closes the search and prevents the event
// of propagating so it doesn't trigger the // of propagating so it doesn't trigger the
@ -103,7 +106,7 @@ export default {
close: function (event) { close: function (event) {
event.stopPropagation() event.stopPropagation()
event.preventDefault() event.preventDefault()
this.active = false this.$store.commit('closeHovers')
}, },
// Checks if the current input is a supported command. // Checks if the current input is a supported command.
supported: function () { supported: function () {
@ -127,7 +130,6 @@ export default {
return return
} }
this.active = true
this.search.length = 0 this.search.length = 0
this.commands.length = 0 this.commands.length = 0
}, },

View File

@ -6,12 +6,12 @@
</router-link> </router-link>
<div v-if="user.allowNew"> <div v-if="user.allowNew">
<button @click="$store.commit('showPrompt', 'newDir')" aria-label="New directory" title="New directory" class="action"> <button @click="$store.commit('showHover', '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('showPrompt', 'newFile')" aria-label="New file" title="New file" class="action"> <button @click="$store.commit('showHover', '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>
@ -60,7 +60,7 @@ export default {
}, },
methods: { methods: {
help: function () { help: function () {
this.$store.commit('showPrompt', 'help') this.$store.commit('showHover', 'help')
}, },
logout: auth.logout logout: auth.logout
} }

View File

@ -10,7 +10,7 @@ export default {
name: 'delete-button', name: 'delete-button',
methods: { methods: {
show: function (event) { show: function (event) {
this.$store.commit('showPrompt', 'delete') this.$store.commit('showHover', 'delete')
} }
} }
} }

View File

@ -28,7 +28,7 @@ export default {
return return
} }
this.$store.commit('showPrompt', 'download') this.$store.commit('showHover', 'download')
} }
} }
} }

View File

@ -1,10 +1,17 @@
<template> <template>
<button title="Info" aria-label="Info" class="action" @click="$store.commit('showPrompt', 'info')"> <button title="Info" aria-label="Info" class="action" @click="show">
<i class="material-icons">info</i> <i class="material-icons">info</i>
<span>Info</span> <span>Info</span>
</button> </button>
</template> </template>
<script> <script>
export default {name: 'info-button'} export default {
name: 'info-button',
methods: {
show: function (event) {
this.$store.commit('showHover', 'info')
}
}
}
</script> </script>

View File

@ -1,10 +1,17 @@
<template> <template>
<button @click="this.$store.commit('showPrompt', 'move')" aria-label="Move" title="Move" class="action"> <button @click="show" 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>
</template> </template>
<script> <script>
export default {name: 'move-button'} export default {
name: 'move-button',
methods: {
show: function (event) {
this.$store.commit('showHover', 'move')
}
}
}
</script> </script>

View File

@ -1,10 +1,17 @@
<template> <template>
<button @click="this.$store.commit('showPrompt', 'rename')" aria-label="Rename" title="Rename" class="action"> <button @click="show" 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>
</template> </template>
<script> <script>
export default {name: 'rename-button'} export default {
name: 'rename-button',
methods: {
show: function (event) {
this.$store.commit('showHover', 'rename')
}
}
}
</script> </script>

View File

@ -5,7 +5,7 @@
<p v-show="req.kind === 'listing'">Are you sure you want to delete {{ selectedCount }} file(s)?</p> <p v-show="req.kind === 'listing'">Are you sure you want to delete {{ selectedCount }} file(s)?</p>
<div> <div>
<button @click="submit" autofocus>Delete</button> <button @click="submit" autofocus>Delete</button>
<button @click="closePrompts" class="cancel">Cancel</button> <button @click="closeHovers" class="cancel">Cancel</button>
</div> </div>
</div> </div>
</template> </template>
@ -22,9 +22,9 @@ export default {
...mapState(['req', 'selected']) ...mapState(['req', 'selected'])
}, },
methods: { methods: {
...mapMutations(['closePrompts']), ...mapMutations(['closeHovers']),
submit: function (event) { submit: function (event) {
this.closePrompts() this.closeHovers()
// buttons.setLoading('delete') // buttons.setLoading('delete')
if (this.req.kind !== 'listing') { if (this.req.kind !== 'listing') {

View File

@ -34,7 +34,7 @@ export default {
api.download(format, ...files) api.download(format, ...files)
} }
this.$store.commit('closePrompts') this.$store.commit('closeHovers')
} }
} }
} }

View File

@ -20,7 +20,7 @@
</ul> </ul>
<div> <div>
<button type="submit" @click="$store.commit('closePrompts')" class="ok">OK</button> <button type="submit" @click="$store.commit('closeHovers')" class="ok">OK</button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -21,7 +21,7 @@
</section> </section>
<div> <div>
<button type="submit" @click="$store.commit('closePrompts')" class="ok">OK</button> <button type="submit" @click="$store.commit('closeHovers')" class="ok">OK</button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -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('closePrompts')">Cancel</button> <button class="cancel" @click="$store.commit('closeHovers')">Cancel</button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -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('closePrompts')">Cancel</button> <button class="cancel" @click="$store.commit('closeHovers')">Cancel</button>
</div> </div>
</div> </div>
</template> </template>
@ -45,7 +45,7 @@ export default {
console.log(error) console.log(error)
}) })
this.$store.commit('closePrompts') this.$store.commit('closeHovers')
} }
} }
} }

View File

@ -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('closePrompts')">Cancel</button> <button class="cancel" @click="$store.commit('closeHovers')">Cancel</button>
</div> </div>
</div> </div>
</template> </template>
@ -45,7 +45,7 @@ export default {
console.log(error) console.log(error)
}) })
this.$store.commit('closePrompts') this.$store.commit('closeHovers')
} }
} }
} }

View File

@ -22,7 +22,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 {mapState} from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'prompts', name: 'prompts',
@ -37,20 +37,22 @@ export default {
Help Help
}, },
computed: { computed: {
...mapState(['prompt']), ...mapState(['show']),
showInfo: function () { return this.prompt === 'info' }, showInfo: function () { return this.show === 'info' },
showHelp: function () { return this.prompt === 'help' }, showHelp: function () { return this.show === 'help' },
showDelete: function () { return this.prompt === 'delete' }, showDelete: function () { return this.show === 'delete' },
showRename: function () { return this.prompt === 'rename' }, showRename: function () { return this.show === 'rename' },
showMove: function () { return this.prompt === 'move' }, showMove: function () { return this.show === 'move' },
showNewFile: function () { return this.prompt === 'newFile' }, showNewFile: function () { return this.show === 'newFile' },
showNewDir: function () { return this.prompt === 'newDir' }, showNewDir: function () { return this.show === 'newDir' },
showDownload: function () { return this.prompt === 'download' }, showDownload: function () { return this.show === 'download' },
showOverlay: function () { return this.prompt !== null } showOverlay: function () {
return (this.show !== null && this.show !== 'search')
}
}, },
methods: { methods: {
resetPrompts () { resetPrompts () {
this.$store.commit('closePrompts') this.$store.commit('closeHovers')
} }
} }
} }

View File

@ -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('closePrompts') this.$store.commit('closeHovers')
}, },
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('closePrompts') this.$store.commit('closeHovers')
return return
} }
} }

View File

@ -53,6 +53,10 @@ header>div:last-child {
justify-content: flex-end; justify-content: flex-end;
} }
header .search-button {
display: none;
}
/* * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * *
* MORE?? * * MORE?? *

View File

@ -22,6 +22,7 @@
transition: .2s ease-in-out left; transition: .2s ease-in-out left;
left: -14em; left: -14em;
} }
header .search-button,
header>div:first-child>.action { header>div:first-child>.action {
display: inherit; display: inherit;
} }
@ -36,4 +37,10 @@
margin: 0 1em; margin: 0 1em;
width: calc(100% - 2em); width: calc(100% - 2em);
} }
#search {
display: none;
}
#search.active {
display: block;
}
} }

View File

@ -1,6 +1,6 @@
const mutations = { const mutations = {
closePrompts: (state) => { state.prompt = null }, closeHovers: state => { state.show = null },
showPrompt: (state, value) => { state.prompt = value }, showHover: (state, value) => { state.show = value },
setReload: (state, value) => { state.reload = value }, 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),

View File

@ -13,7 +13,7 @@ const state = {
reload: false, reload: false,
selected: [], selected: [],
multiple: false, multiple: false,
prompt: null show: null
} }
export default new Vuex.Store({ export default new Vuex.Store({