ui: Add sent offer status filter.
This commit is contained in:
parent
6e5c54b447
commit
ba5339d8bd
@ -5697,6 +5697,14 @@ class BasicSwap(BaseApp):
|
||||
|
||||
if sent:
|
||||
q = q.filter(Offer.was_sent == True) # noqa: E712
|
||||
|
||||
active_state = filters.get('active', 'any')
|
||||
if active_state == 'active':
|
||||
q = q.filter(Offer.expire_at > now, Offer.active_ind == 1)
|
||||
elif active_state == 'expired':
|
||||
q = q.filter(Offer.expire_at <= now)
|
||||
elif active_state == 'revoked':
|
||||
q = q.filter(Offer.active_ind != 1)
|
||||
else:
|
||||
q = q.filter(sa.and_(Offer.expire_at > now, Offer.active_ind == 1))
|
||||
|
||||
|
@ -309,6 +309,26 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% if sent_offers %}
|
||||
<div class="flex items-center">
|
||||
<div class="w-full md:w-auto p-1.5">
|
||||
<p class="text-sm font-heading bold">State:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-auto p-1.5">
|
||||
<div class="relative">
|
||||
<svg class="absolute right-4 top-1/2 transform -translate-y-1/2" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11.3333 6.1133C11.2084 5.98913 11.0395 5.91943 10.8633 5.91943C10.6872 5.91943 10.5182 5.98913 10.3933 6.1133L8.00001 8.47329L5.64001 6.1133C5.5151 5.98913 5.34613 5.91943 5.17001 5.91943C4.99388 5.91943 4.82491 5.98913 4.70001 6.1133C4.63752 6.17527 4.58792 6.249 4.55408 6.33024C4.52023 6.41148 4.50281 6.49862 4.50281 6.58663C4.50281 6.67464 4.52023 6.76177 4.55408 6.84301C4.58792 6.92425 4.63752 6.99799 4.70001 7.05996L7.52667 9.88663C7.58865 9.94911 7.66238 9.99871 7.74362 10.0326C7.82486 10.0664 7.912 10.0838 8.00001 10.0838C8.08801 10.0838 8.17515 10.0664 8.25639 10.0326C8.33763 9.99871 8.41136 9.94911 8.47334 9.88663L11.3333 7.05996C11.3958 6.99799 11.4454 6.92425 11.4793 6.84301C11.5131 6.76177 11.5305 6.67464 11.5305 6.58663C11.5305 6.49862 11.5131 6.41148 11.4793 6.33024C11.4454 6.249 11.3958 6.17527 11.3333 6.1133Z" fill="#8896AB"> </path>
|
||||
</svg>
|
||||
<select name="active" class="appearance-none pr-10 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
|
||||
<option value="any" {% if filters.active=='any' %} selected{% endif %}>Any</option>
|
||||
<option value="active" {% if filters.active=='active' %} selected{% endif %}>Active</option>
|
||||
<option value="expired" {% if filters.active=='expired' %} selected{% endif %}>Expired</option>
|
||||
<option value="revoked" {% if filters.active=='revoked' %} selected{% endif %}>Revoked</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="w-full md:w-auto p-1.5">
|
||||
<div class="relative">
|
||||
<button type="submit" name='clearfilters' value="Clear Filters" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md shadow-button focus:ring-0 focus:outline-none">
|
||||
|
@ -577,6 +577,7 @@ def page_offers(self, url_split, post_string, sent=False):
|
||||
'sort_by': 'created_at',
|
||||
'sort_dir': 'desc',
|
||||
'sent_from': 'any' if sent is False else 'only',
|
||||
'active': 'any',
|
||||
}
|
||||
messages = []
|
||||
form_data = self.checkForm(post_string, 'offers', messages)
|
||||
@ -596,6 +597,10 @@ def page_offers(self, url_split, post_string, sent=False):
|
||||
sent_from = get_data_entry(form_data, 'sent_from')
|
||||
ensure(sent_from in ['any', 'only'], 'Invalid sent filter')
|
||||
filters['sent_from'] = sent_from
|
||||
if have_data_entry(form_data, 'active'):
|
||||
active_filter = get_data_entry(form_data, 'active')
|
||||
ensure(active_filter in ['any', 'active', 'expired', 'revoked'], 'Invalid active filter')
|
||||
filters['active'] = active_filter
|
||||
|
||||
set_pagination_filters(form_data, filters)
|
||||
|
||||
@ -648,4 +653,5 @@ def page_offers(self, url_split, post_string, sent=False):
|
||||
'filters': filters,
|
||||
'offers': formatted_offers,
|
||||
'summary': summary,
|
||||
'sent_offers': sent,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user