Skip to content

Commit 578d736

Browse files
committed
refactor: migrate search to NcTextField with clear button
1 parent 83399a9 commit 578d736

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/components/NotesView.vue

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
<template slot="list">
99
<NcAppContentList class="content-list">
1010
<div class="content-list__search">
11-
<input type="search" :placeholder="t('notes', 'Search for notes')" @input="event => searchText = event.target.value">
11+
<NcTextField
12+
:value.sync="searchText"
13+
:label="t('notes', 'Search for notes')"
14+
:show-trailing-button="searchText !== ''"
15+
trailing-button-icon="close"
16+
:trailing-button-label="t('Clear search')"
17+
@trailing-button-click="searchText=''"
18+
/>
1219
</div>
1320

1421
<NotesList v-if="groupedNotes.length === 1"
@@ -58,6 +65,7 @@ import {
5865
NcAppContentList,
5966
NcAppContentDetails,
6067
NcButton,
68+
NcTextField,
6169
} from '@nextcloud/vue'
6270
import { categoryLabel } from '../Util.js'
6371
import NotesList from './NotesList.vue'
@@ -75,6 +83,7 @@ export default {
7583
NcAppContentList,
7684
NcAppContentDetails,
7785
NcButton,
86+
NcTextField,
7887
Note,
7988
NotesList,
8089
NotesCaption,
@@ -98,6 +107,7 @@ export default {
98107
lastYear: new Date(new Date().getFullYear() - 1, 0),
99108
showFirstNotesOnly: true,
100109
showNote: true,
110+
searchText: '',
101111
}
102112
},
103113

@@ -143,18 +153,11 @@ export default {
143153
}, [])
144154
}
145155
},
146-
searchText: {
147-
get() {
148-
return store.state.searchText
149-
},
150-
set(value) {
151-
store.commit('updateSearchText', value)
152-
},
153-
},
154156
},
155157

156158
watch: {
157159
category() { this.showFirstNotesOnly = true },
160+
searchText(value) { store.commit('updateSearchText', value) },
158161
},
159162

160163
created() {

0 commit comments

Comments
 (0)