Commit 1e0d73e2 authored by Bharat R's avatar Bharat R

Fix : #175

parent 3136a339
Pipeline #106979 failed with stage
in 3 minutes and 26 seconds
......@@ -182,7 +182,7 @@ export function formhandler(js_options) {
else {
$.ajax(options.src, {
dataType: 'json',
data: args,
data: namespace(args, options.namespace),
traditional: true
}).done(done)
.always(function () { $('.loader', $this).addClass('d-none') })
......@@ -210,8 +210,10 @@ function modalHandler($this) {
.on('shown.bs.modal', '.formhandler-table-modal', function (e) {
var $el = $(e.relatedTarget)
var template_data = $this.data('formhandler')
var namespace = template_data.options.namespace
var op = $el.data('op')
var col = $el.closest('[data-col]').data('col')
col = namespace ? (namespace + ':' + col) : col
var val = ''
// If there is a value, show it, and allow user to remove the filter
if (template_data.args[col + op]) {
......
......@@ -63,6 +63,7 @@ Each template receives these variables:
var cols = options.columns.length ? filtered_cols : meta.columns;
cols = cols.filter(function(col) { return col.hide !== true})
var form_id = idcount
var namespace = options.namespace ? options.namespace + ':' : ''
%>
<table class="table table-sm table-striped">
......@@ -102,7 +103,7 @@ Each template receives these variables:
<div class="dropdown-divider"></div>
<% } %>
<% if (colinfo.hideable) { %>
<a class="dropdown-item urlfilter" href="?_c=-<%- encodeURIComponent(colinfo.name) %>" data-mode="add">Hide</a>
<a class="dropdown-item urlfilter" href="?<%- namespace + '_c=-' + encodeURIComponent(colinfo.name) %>" data-mode="add">Hide</a>
<% } %>
</div><!-- .dropdown-menu -->
</div><!-- .dropdown -->
......@@ -168,7 +169,7 @@ Each template receives these variables:
</td>
<% } else { %>
<td>
<a class="urlfilter" href="?<%- encodeURIComponent(colinfo.name) %>=<%- encodeURIComponent(val) %>&amp;_offset=">
<a class="urlfilter ii" href="?<%- namespace + encodeURIComponent(colinfo.name) %>=<%- encodeURIComponent(val) %>&amp;_offset=">
<%= disp %>
</a>
</td>
......@@ -333,22 +334,28 @@ Each template receives these variables:
_.each(args['_c'], function(col_name) {
qparts.update({_c: col_name}, 'add')
var hide_col = col_name[0] == '-'
var display_name = hide_col ? col_name.slice(1) : col_name %>
var display_name = hide_col ? col_name.slice(1) : col_name
display_name = (display_name.indexOf(':') > -1)? display_name.split(':')[1].trim() : display_name %>
<a href="?_c=<%- encodeURIComponent(col_name) %>" data-mode="del" class="badge badge-pill <%- hide_col ? 'badge-dark' : 'badge-danger' %> urlfilter"
title="<%- hide_col ? 'Show' : 'Hide' %> column <%- display_name %>">
<%- display_name %>
</a>
<% })
_.each(args, function(list_values, key) {
var isnamespaced_key = (key.indexOf(":") > -1)
var has_valid_namespace = (options.namespace)? (key.indexOf(options.namespace +':') > -1) : false
if (key.charAt(0) !== '_' && key !== 'c') {
_.each(args[key], function(col_name) {
var update = {}
update[key] = col_name
qparts.update(update, 'add') %>
<a href="?<%- encodeURIComponent(key) %>=<%- encodeURIComponent(col_name) %>" data-mode="del" class="badge badge-pill badge-dark urlfilter" title="Clear <%- key %> filter">
<%- key %> = <%- col_name %>
</a>
<% })
if( !isnamespaced_key || (isnamespaced_key && has_valid_namespace) ){
var update = {}
update[key] = col_name
qparts.update(update, 'add')
var display_key = (key.indexOf(options.namespace +':') > -1)? key.split(":")[1].trim() : key %>
<a href="?<%- encodeURIComponent(key) %>=<%- encodeURIComponent(col_name) %>" data-mode="del" class="badge badge-pill badge-dark urlfilter" title="Clear <%- key %> filter">
<%- display_key %> = <%- col_name %>
</a>
<% } })
}
})
qparts = qparts.toString()
......@@ -374,7 +381,6 @@ Each template receives these variables:
options.columns
var cols = options.columns.length ? filtered_cols : meta.columns
var form_id = idcount, img
var namespace = options.namespace ? options.namespace + ':' : ''
if (options.rowTemplate) {
_.each(data, function(row, rowIndex) { %>
<%= typeof options.rowTemplate == 'function' ? options.rowTemplate({row: row, index: rowIndex, data: data}) : _.template(options.rowTemplate)({row: row, data: data, index: rowIndex}) %>
......
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