comparison libervia/web/pages/_browser/jid_search.py @ 1593:c6976c5b85a1

browser (chat/select): add bookmarked entities on empty search
author Goffi <goffi@goffi.org>
date Mon, 11 Dec 2023 00:43:06 +0100
parents f1d09a4d38dc
children 4a9679369856
comparison
equal deleted inserted replaced
1592:291a7026cb2b 1593:c6976c5b85a1
74 74
75 self.empty_cb = empty_cb or self.on_empty_search 75 self.empty_cb = empty_cb or self.on_empty_search
76 76
77 current_search = search_elt.value.strip() or None 77 current_search = search_elt.value.strip() or None
78 if not current_search: 78 if not current_search:
79 self.empty_cb() 79 aio.run(self.empty_cb(self))
80 else: 80 else:
81 aio.run(self.perform_search(current_search)) 81 aio.run(self.perform_search(current_search))
82 82
83 def default_get_url(self, item): 83 def default_get_url(self, item):
84 """Default method to get the URL for a given entity 84 """Default method to get the URL for a given entity
121 """ 121 """
122 evt.stopPropagation() 122 evt.stopPropagation()
123 evt.preventDefault() 123 evt.preventDefault()
124 search_text = evt.target.value.strip() 124 search_text = evt.target.value.strip()
125 if not search_text: 125 if not search_text:
126 self.empty_cb() 126 aio.run(self.empty_cb(self))
127 elif len(search_text) > 2: 127 elif len(search_text) > 2:
128 aio.run(self.perform_search(search_text)) 128 aio.run(self.perform_search(search_text))
129 129
130 def on_form_submit(self, evt): 130 def on_form_submit(self, evt):
131 search_text = self.search_elt.value.strip() 131 search_text = self.search_elt.value.strip()
151 if current_query != query: 151 if current_query != query:
152 await self.perform_search(current_query) 152 await self.perform_search(current_query)
153 return 153 return
154 self.filter_cb(jid_items) 154 self.filter_cb(jid_items)
155 155
156 def on_empty_search(self): 156 async def on_empty_search(self, jid_search):
157 """Handle the situation when the search box is empty""" 157 """Handle the situation when the search box is empty"""
158 assert self.container_elt is not None 158 assert self.container_elt is not None
159 items = [ 159 items = [
160 { 160 {
161 "entity": jid_, 161 "entity": jid_,