Skip to content

Commit

Permalink
Merge pull request #76 from fdm-monster/feat/73-add-file-searcher-to-…
Browse files Browse the repository at this point in the history
…sidenav-filelist

Feat/73 add file searcher to sidenav filelist
  • Loading branch information
davidzwa authored Apr 29, 2023
2 parents 3664033 + 9bb918d commit dc572db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fdm-monster/client",
"version": "1.0.4",
"version": "1.0.5",
"private": false,
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
Expand Down
26 changes: 24 additions & 2 deletions src/components/Generic/SideNavs/FileExplorerSideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@
<v-list v-drop-upload="{ printers: [storedSideNavPrinter] }" dense subheader>
<v-subheader inset>Files - drag 'n drop!</v-subheader>

<v-text-field
v-model="fileSearch"
class="ml-5 mr-5"
label="Search files..."
clearable
prepend-icon="search"
/>

<!-- Empty file list -->
<v-list-item v-if="!filesListed.length">
<v-list-item-avatar>
Expand All @@ -211,7 +219,13 @@
<!-- Loading file list-->
<v-progress-linear v-if="loading" indeterminate></v-progress-linear>

<v-list-item v-for="(file, index) in filesListed" :key="index" link>
<v-list-item
v-for="(file, index) in filesListed"
:key="index"
dense
link
style="padding-top: 0px"
>
<v-list-item-avatar>
<v-tooltip left>
<template v-slot:activator="{ on, attrs }">
Expand Down Expand Up @@ -296,6 +310,7 @@ import { DialogName } from "@/components/Generic/Dialogs/dialog.constants";
import { useDialogsStore } from "@/store/dialog.store";
interface Data {
fileSearch?: string;
shownFileBucket?: PrinterFileBucket;
drawerOpened: boolean;
loading: boolean;
Expand All @@ -314,6 +329,7 @@ export default defineComponent({
async mounted() {},
props: {},
data: (): Data => ({
fileSearch: undefined,
shownFileBucket: undefined,
drawerOpened: false,
loading: true,
Expand All @@ -335,7 +351,13 @@ export default defineComponent({
return !!this.storedSideNavPrinter?.disabledReason?.length;
},
filesListed() {
return this.shownFileBucket?.files || [];
return (
this.shownFileBucket?.files.filter((f) =>
this.fileSearch?.length
? `${f.name}${f.path}`.toLowerCase().includes(this.fileSearch)
: true
) || []
);
},
isStoppable() {
if (!this.storedSideNavPrinter) return false;
Expand Down

0 comments on commit dc572db

Please sign in to comment.