Commit b57ab9dd authored by Pratap Vardhan's avatar Pratap Vardhan

ENH: g1.formhandler supports multiple sort #75

parent ead12162
Pipeline #77388 passed with stage
in 2 minutes and 53 seconds
......@@ -71,16 +71,21 @@ Each template receives these variables:
col_defaults(colinfo, data)
var menu_item = false
var col_id = idcount++
var qsort = parse('?')
var isSorted = _.includes(args['_sort'], colinfo.name) ? {op: '', cls: 'table-primary'} : _.includes(args['_sort'], '-' + colinfo.name) ? {op: '-', cls: 'table-danger'} : {}
%>
<th class="<%- args['_sort'] == colinfo.name ? 'table-primary' : args['_sort'] == '-' + colinfo.name ? 'table-danger' : '' %>" data-col="<%- colinfo.name %>">
<th class="<%- isSorted.cls %>" data-col="<%- colinfo.name %>">
<div class="dropdown">
<a href="#" class="dropdown-toggle text-nowrap" id="fh-dd-<%- col_id %>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%- colinfo.title || colinfo.name %>
</a>
<div class="dropdown-menu" aria-labelledby="fh-dd-<%- col_id %>">
<% _.each(colinfo.sort, function(title, op) { menu_item = true
var active = args['_sort'] == op + colinfo.name %>
<a class="dropdown-item urlfilter <%- active ? 'active': '' %>" href="?_sort=<%- active ? '' : op + colinfo.name %>">
qsort = qsort.update({_sort: args['_sort'] || []})
if (!_.isEmpty(isSorted))
qsort = qsort.update({_sort: [colinfo.name, '-' + colinfo.name]}, 'del')
var active = _.includes(args['_sort'], op + colinfo.name) %>
<a class="dropdown-item urlfilter <%- active ? 'active': '' %>" href="<%- qsort.update({_sort: [op + colinfo.name]}, active ? 'del': 'add').toString() %>">
<%- title %>
</a>
<% }) %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment