...
 
Commits (3)
......@@ -86,7 +86,7 @@ Each template receives these variables:
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() %>">
<a class="dropdown-item urlfilter <%- active ? 'active': '' %>" href="<%- qsort.update({[namespace + '_sort']: [op + colinfo.name]}, active ? 'del': 'add').toString() %>">
<%- title %>
</a>
<% }) %>
......
<!DOCTYPE html>
<html>
<head>
<title>formhandler tests</title>
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css">
<style>
.position-relative {
position: relative;
}
.pos-cc {
position: absolute;
top: 45%;
left: 45%;
}
.d-none {
display: none !important;
}
</style>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../node_modules/popper.js/dist/umd/popper.min.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../node_modules/lodash/lodash.min.js"></script>
<script src="../node_modules/moment/min/moment.min.js"></script>
<script src="../node_modules/numeral/min/numeral.min.js"></script>
<script src="../dist/formhandler.min.js"></script>
<script src="../dist/scale.min.js"></script>
<script src="../node_modules/d3/build/d3.js"></script>
<script src="../node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"></script>
<script src="tape.js"></script>
<script src="tape-stream.js"></script>
</head>
<body>
<div class="fh-table" data-src="/formhandler-data"></div>
<div class="fh13i" data-src="/formhandler-data"></div>
</body>
<script>
$('.fh-table').formhandler({
pageSize: 5,
columns: [
{
name: 'Continent'
}
]
})
// WIP: Test for - if namespace is specified, URL should append with namespace
tape('$().formhandler() if namespace is specified, URL should append with namespace ', function (t) {
window.history.pushState({}, '', '#')
$('.fh13i').formhandler({
namespace: 'fhname13i',
pageSize: 10,
columns: [
{
name: 'Continent'
}
]
}).one('load', function () {
$('body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr:nth-child(1) > td > [href="?fhname13i:Continent=Europe&_offset="]').click()
})
setTimeout(function () {
let tr_list = $('body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr > td > [href="?fhname13i:Continent=Europe&_offset="]').text().split(" ")
// Check all values has only 'Europe' for this table
t.ok(tr_list.every(v => v.trim() === 'Europe'))
// Check filters badges are created for this table
let _filters = $('body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark')
t.ok(_filters.length > 0)
t.equal(_filters.text().trim(), 'Continent = Europe')
t.equal( g1.url.parse(location.href).hash ,'?fhname13i%3AContinent=Europe')
// Test if the filters are not effected to the other table
t.equal($('body > div.fh-table > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark').length,
0)
t.ok($('body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr > td > [href="?fhname13i:Continent=Europe&_offset="]').text().split(" ").every(v => v.trim() === 'Europe'))
// Test filter for other functionalities - 'sort'
$('body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge.badge-danger').click()
$('body > div.fh13i > div.position-relative > div.formhandler > div.table > table > thead > tr > th > div.dropdown > div.dropdown-menu > a:nth-child(1)').click()
setTimeout(function(){
t.equal( g1.url.parse(location.href).hash ,'?fhname13i%3A_sort=Continent')
t.equal(
$('body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark').text().trim(),
'_sort = Continent'
)
t.end()
}, 500)
}, 500)
})
// End
</script>
</html>
......@@ -79,7 +79,7 @@
<div class="cell_template4" data-src="/formhandler-data"></div>
<div class="cell_template5" data-src="/formhandler-data"></div>
<!-- formhandler tables for namespaces -->
<div class="fh13" data-src="/formhandler-data"></div>
<div class="fh1" data-src="formhandler_csv.json"></div>
......@@ -410,7 +410,7 @@
$('.fh13')
.formhandler({
name: 'fhname13',
namespace: 'fhname13',
columns: [
{
name: 'Continent'
......