Commit 1e0d73e2 authored by Bharat R's avatar Bharat R 👀
Browse files

Fix : #175

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