Implemented filter and sort selected functions

This commit is contained in:
Glenn de Haan
2024-10-08 15:29:05 +02:00
parent 5f542660ad
commit ded6547777
2 changed files with 16 additions and 11 deletions

View File

@@ -382,7 +382,12 @@ if(variables.serviceWeb) {
voucher_types: types(variables.voucherTypes), voucher_types: types(variables.voucherTypes),
voucher_custom: variables.voucherCustom, voucher_custom: variables.voucherCustom,
vouchers: cache.vouchers, vouchers: cache.vouchers,
updated: cache.updated updated: cache.updated,
filters: {
status: req.query.status,
quota: req.query.quota
},
sort: req.query.sort
}); });
}); });
app.get('/voucher/:id', [authorization.web], async (req, res) => { app.get('/voucher/:id', [authorization.web], async (req, res) => {

View File

@@ -91,27 +91,27 @@
<div class="flex flex-col"> <div class="flex flex-col">
<label for="status" class="text-sm text-gray-900 dark:text-white mb-1">Status</label> <label for="status" class="text-sm text-gray-900 dark:text-white mb-1">Status</label>
<select id="status" name="status" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Filter by category"> <select id="status" name="status" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Filter by category">
<option value="all">All</option> <option value="all"<%= filters.status === 'all' ? ' selected' : '' %>>All</option>
<option value="available">Available</option> <option value="available"<%= filters.status === 'available' ? ' selected' : '' %>>Available</option>
<option value="in-use">In Use</option> <option value="in-use"<%= filters.status === 'in-use' ? ' selected' : '' %>>In Use</option>
</select> </select>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<label for="quota" class="text-sm text-gray-900 dark:text-white mb-1">Quota</label> <label for="quota" class="text-sm text-gray-900 dark:text-white mb-1">Quota</label>
<select id="quota" name="quota" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Filter by category"> <select id="quota" name="quota" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Filter by category">
<option value="all">All</option> <option value="all"<%= filters.quota === 'all' ? ' selected' : '' %>>All</option>
<option value="multi-use">Multi-use</option> <option value="multi-use"<%= filters.quota === 'multi-use' ? ' selected' : '' %>>Multi-use</option>
<option value="single-use">Single-use</option> <option value="single-use"<%= filters.quota === 'single-use' ? ' selected' : '' %>>Single-use</option>
</select> </select>
</div> </div>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<label for="sort" class="text-sm text-gray-900 dark:text-white mb-1">Sort</label> <label for="sort" class="text-sm text-gray-900 dark:text-white mb-1">Sort</label>
<select id="sort" name="sort" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Sort by"> <select id="sort" name="sort" class="bg-transparent rounded-md text-sm text-gray-600 dark:text-gray-400 focus:outline-none border-b border-black/5 dark:border-white/5" aria-label="Sort by">
<option value="date">Date</option> <option value="date"<%= sort === 'date' ? ' selected' : '' %>>Date</option>
<option value="code">Code</option> <option value="code"<%= sort === 'code' ? ' selected' : '' %>>Code</option>
<option value="duration">Duration</option> <option value="duration"<%= sort === 'duration' ? ' selected' : '' %>>Duration</option>
<option value="status">Status</option> <option value="status"<%= sort === 'status' ? ' selected' : '' %>>Status</option>
</select> </select>
</div> </div>
</div> </div>