2023-10-26 00:43:44 +01:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { useDocumentStore } from '@/stores/documents'
|
2023-11-04 00:21:35 +00:00
|
|
|
import { ref, nextTick } from 'vue'
|
2023-10-26 00:43:44 +01:00
|
|
|
|
|
|
|
const documentStore = useDocumentStore()
|
2023-10-27 16:32:21 +01:00
|
|
|
const searchQuery = ref<string>('')
|
|
|
|
const showSearchInput = ref<boolean>(false)
|
2023-11-04 00:21:35 +00:00
|
|
|
const search = ref<HTMLInputElement | null>()
|
2023-10-27 16:32:21 +01:00
|
|
|
|
|
|
|
const toggleSearchInput = () => {
|
2023-11-03 20:07:05 +00:00
|
|
|
showSearchInput.value = !showSearchInput.value
|
2023-10-27 16:32:21 +01:00
|
|
|
if (!showSearchInput.value) {
|
2023-11-01 23:00:59 +00:00
|
|
|
searchQuery.value = ''
|
2023-10-27 16:32:21 +01:00
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
nextTick(() => {
|
|
|
|
const input = search.value
|
|
|
|
if (input) input.focus()
|
|
|
|
})
|
2023-11-01 23:00:59 +00:00
|
|
|
}
|
2023-10-27 16:32:21 +01:00
|
|
|
|
2023-11-01 23:00:59 +00:00
|
|
|
const executeSearch = (ev: InputEvent) => {
|
|
|
|
// FIXME: Make reactive instead of this update handler
|
|
|
|
const query = (ev.target as HTMLInputElement).value
|
2023-11-03 20:07:05 +00:00
|
|
|
console.log('Searching', query)
|
2023-11-01 23:00:59 +00:00
|
|
|
documentStore.setFilter(query)
|
2023-11-03 20:07:05 +00:00
|
|
|
console.log('Filtered')
|
2023-11-01 23:00:59 +00:00
|
|
|
}
|
2023-10-26 00:43:44 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-11-04 00:21:35 +00:00
|
|
|
<nav>
|
|
|
|
<div class="buttons">
|
2023-10-26 00:43:44 +01:00
|
|
|
<UploadButton />
|
2023-11-04 00:43:37 +00:00
|
|
|
<SvgButton name="create-folder" @click="() => documentStore.fileExplorer.newFolder()"/>
|
2023-11-04 00:21:35 +00:00
|
|
|
<template v-if="true">
|
|
|
|
<div class="smallgap"></div>
|
|
|
|
<p>N selected files:</p>
|
|
|
|
<!-- Needs better icons for copy/move/remove -->
|
|
|
|
<SvgButton name="copy" />
|
|
|
|
<SvgButton name="paste" />
|
|
|
|
<SvgButton name="trash" />
|
2023-10-26 00:43:44 +01:00
|
|
|
</template>
|
2023-11-04 00:21:35 +00:00
|
|
|
<div class="spacer"></div>
|
|
|
|
<SvgButton name="find" @click="toggleSearchInput" />
|
2023-10-27 16:32:21 +01:00
|
|
|
<template v-if="showSearchInput">
|
2023-11-04 00:21:35 +00:00
|
|
|
<input
|
|
|
|
ref="search"
|
|
|
|
type="search"
|
|
|
|
v-model="searchQuery"
|
|
|
|
class="margin-input"
|
|
|
|
@keyup.esc="toggleSearchInput"
|
|
|
|
/>
|
2023-10-27 16:32:21 +01:00
|
|
|
</template>
|
2023-10-26 00:43:44 +01:00
|
|
|
</div>
|
2023-11-04 00:21:35 +00:00
|
|
|
</nav>
|
2023-10-26 00:43:44 +01:00
|
|
|
</template>
|
|
|
|
|
2023-11-04 00:21:35 +00:00
|
|
|
<style scoped>
|
|
|
|
.buttons {
|
|
|
|
padding: 0 0.5em;
|
2023-10-26 00:43:44 +01:00
|
|
|
display: flex;
|
2023-11-04 00:21:35 +00:00
|
|
|
align-items: center;
|
2023-10-26 00:43:44 +01:00
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
.spacer {
|
|
|
|
flex-grow: 1;
|
2023-10-26 00:43:44 +01:00
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
.smallgap {
|
|
|
|
margin-left: 2em;
|
2023-10-26 00:43:44 +01:00
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
.search-widget {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2023-10-27 16:32:21 +01:00
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
input[type='search'] {
|
|
|
|
background: var(--primary-background);
|
|
|
|
color: var(--text-color);
|
|
|
|
border: 0;
|
|
|
|
border-radius: 0.1rem;
|
|
|
|
padding: 0.5rem;
|
|
|
|
outline: none;
|
|
|
|
font-size: 1.2rem;
|
2023-11-03 16:15:37 +00:00
|
|
|
}
|
2023-10-26 00:43:44 +01:00
|
|
|
</style>
|