Skip to content

Commit

Permalink
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 629cf26
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/NotesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<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=''">

Check warning on line 11 in src/components/NotesView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Require self-closing on Vue.js custom components (<NcTextField>)

Check failure on line 11 in src/components/NotesView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'trailing-button-icon' should be on a new line

Check failure on line 11 in src/components/NotesView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':trailing-button-label' should be on a new line

Check failure on line 11 in src/components/NotesView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'@trailing-button-click' should be on a new line
</NcTextField>
</div>

<NotesList v-if="groupedNotes.length === 1"
Expand Down Expand Up @@ -58,7 +59,9 @@ import {
NcAppContentList,
NcAppContentDetails,
NcButton,
NcTextField,
} from '@nextcloud/vue'

import { categoryLabel } from '../Util.js'
import NotesList from './NotesList.vue'
import NotesCaption from './NotesCaption.vue'
Expand All @@ -75,6 +78,7 @@ export default {
NcAppContentList,
NcAppContentDetails,
NcButton,
NcTextField,
Note,
NotesList,
NotesCaption,
Expand All @@ -98,6 +102,7 @@ export default {
lastYear: new Date(new Date().getFullYear() - 1, 0),
showFirstNotesOnly: true,
showNote: true,
searchText: '',
}
},

Expand Down Expand Up @@ -143,18 +148,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 629cf26

Please sign in to comment.