Skip to content

Commit

Permalink
refactor: migrate search to NcTextField with clear button
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Oct 31, 2024
1 parent 955c939 commit bc2f986
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/NotesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
<template slot="list">
<NcAppContentList class="content-list">
<div class="content-list__search">
<input type="search" :placeholder="t('notes', 'Search for notes')" @input="event => searchText = event.target.value">
<NcTextField
:value.sync="searchText"
:label="t('notes', 'Search for notes')"
:show-trailing-button="searchText !== ''"
trailing-button-icon="close"
:trailing-button-label="t('Clear search')"
@trailing-button-click="searchText=''"
/>
</div>

<NotesList v-if="groupedNotes.length === 1"
Expand Down Expand Up @@ -58,6 +65,7 @@ import {
NcAppContentList,
NcAppContentDetails,
NcButton,
NcTextField,
} from '@nextcloud/vue'
import { categoryLabel } from '../Util.js'
import NotesList from './NotesList.vue'
Expand All @@ -75,6 +83,7 @@ export default {
NcAppContentList,
NcAppContentDetails,
NcButton,
NcTextField,
Note,
NotesList,
NotesCaption,
Expand All @@ -98,6 +107,7 @@ export default {
lastYear: new Date(new Date().getFullYear() - 1, 0),
showFirstNotesOnly: true,
showNote: true,
searchText: '',
}
},
Expand Down Expand Up @@ -143,18 +153,11 @@ export default {
}, [])
}
},
searchText: {
get() {
return store.state.searchText
},
set(value) {
store.commit('updateSearchText', value)
},
},
},
watch: {
category() { this.showFirstNotesOnly = true },
searchText(value) { store.commit('updateSearchText', value) },
},
created() {
Expand Down

0 comments on commit bc2f986

Please sign in to comment.