mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
search items
This commit is contained in:
parent
3c4d48fdc7
commit
5d5f95725f
@ -308,6 +308,9 @@ func ItemListHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
statusValue := storage.StatusValues[status]
|
statusValue := storage.StatusValues[status]
|
||||||
filter.Status = &statusValue
|
filter.Status = &statusValue
|
||||||
}
|
}
|
||||||
|
if search := query.Get("search"); len(search) != 0 {
|
||||||
|
filter.Search = &search
|
||||||
|
}
|
||||||
items := db(req).ListItems(filter, (curPage-1)*perPage, perPage)
|
items := db(req).ListItems(filter, (curPage-1)*perPage, perPage)
|
||||||
count := db(req).CountItems(filter)
|
count := db(req).CountItems(filter)
|
||||||
rw.WriteHeader(http.StatusOK)
|
rw.WriteHeader(http.StatusOK)
|
||||||
|
@ -60,6 +60,7 @@ type ItemFilter struct {
|
|||||||
FolderID *int64
|
FolderID *int64
|
||||||
FeedID *int64
|
FeedID *int64
|
||||||
Status *ItemStatus
|
Status *ItemStatus
|
||||||
|
Search *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) CreateItems(items []Item) bool {
|
func (s *Storage) CreateItems(items []Item) bool {
|
||||||
@ -112,6 +113,16 @@ func listQueryPredicate(filter ItemFilter) (string, []interface{}) {
|
|||||||
cond = append(cond, "i.status = ?")
|
cond = append(cond, "i.status = ?")
|
||||||
args = append(args, *filter.Status)
|
args = append(args, *filter.Status)
|
||||||
}
|
}
|
||||||
|
if filter.Search != nil {
|
||||||
|
words := strings.Fields(*filter.Search)
|
||||||
|
terms := make([]string, len(words))
|
||||||
|
for idx, word := range words {
|
||||||
|
terms[idx] = word + "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
cond = append(cond, "i.search_rowid in (select rowid from search where search match ?)")
|
||||||
|
args = append(args, strings.Join(terms, " "))
|
||||||
|
}
|
||||||
|
|
||||||
predicate := "1"
|
predicate := "1"
|
||||||
if len(cond) > 0 {
|
if len(cond) > 0 {
|
||||||
|
@ -72,10 +72,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="vh-100 d-flex flex-column border-right flex-shrink-0" style="width: 300px">
|
<div class="vh-100 d-flex flex-column border-right flex-shrink-0" style="width: 300px">
|
||||||
<div class="p-2 border-bottom" v-if="filterSelected != 'starred'">
|
<div class="d-flex">
|
||||||
<button class="btn btn-outline-secondary p-0" @click="markItemsRead()">
|
<input class="form-control" type="" v-model="itemSearch">
|
||||||
<img src="./static/images/check.svg" alt="" style="width: 20px; height: 20px;">
|
<div class="p-2 border-bottom" v-if="filterSelected != 'starred'">
|
||||||
</button>
|
<button class="btn btn-outline-secondary p-0" @click="markItemsRead()">
|
||||||
|
<img src="./static/images/check.svg" alt="" style="width: 20px; height: 20px;">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-2 overflow-auto" v-scroll="loadMoreItems">
|
<div class="p-2 overflow-auto" v-scroll="loadMoreItems">
|
||||||
<label v-for="item in items" :key="item.id"
|
<label v-for="item in items" :key="item.id"
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
var debounce = function(callback, wait) {
|
var debounce = function(callback, wait) {
|
||||||
var timeout
|
var timeout
|
||||||
return function() {
|
return function() {
|
||||||
var context = this, args = arguments
|
var ctx = this, args = arguments
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
timeout = setTimeout(function() {
|
timeout = setTimeout(function() {
|
||||||
callback.apply(this, args)
|
callback.apply(ctx, args)
|
||||||
}, wait)
|
}, wait)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,6 +43,7 @@ var vm = new Vue({
|
|||||||
},
|
},
|
||||||
'itemSelected': null,
|
'itemSelected': null,
|
||||||
'itemSelectedDetails': {},
|
'itemSelectedDetails': {},
|
||||||
|
'itemSearch': '',
|
||||||
'settings': 'create',
|
'settings': 'create',
|
||||||
'loading': {
|
'loading': {
|
||||||
'newfeed': false,
|
'newfeed': false,
|
||||||
@ -121,6 +122,11 @@ var vm = new Vue({
|
|||||||
api.items.update(this.itemSelectedDetails.id, {status: this.itemSelectedDetails.status})
|
api.items.update(this.itemSelectedDetails.id, {status: this.itemSelectedDetails.status})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'itemSearch': debounce(function(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.refreshItems()
|
||||||
|
}
|
||||||
|
}, 500),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refreshStats: function() {
|
refreshStats: function() {
|
||||||
@ -147,6 +153,9 @@ var vm = new Vue({
|
|||||||
if (this.filterSelected) {
|
if (this.filterSelected) {
|
||||||
query.status = this.filterSelected
|
query.status = this.filterSelected
|
||||||
}
|
}
|
||||||
|
if (this.itemSearch) {
|
||||||
|
query.search = this.itemSearch
|
||||||
|
}
|
||||||
return query
|
return query
|
||||||
},
|
},
|
||||||
refreshFeeds: function() {
|
refreshFeeds: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user