Commit 32e13edf authored by Tejesh's avatar Tejesh 🖖
Browse files

wip: 3 tests fail

parent f0ca162d
Pipeline #83647 failed with stage
in 2 minutes and 10 seconds
......@@ -95,23 +95,22 @@ export function formhandler(js_options) {
meta.columns = data.length ? _.map(data[0], function (val, col) { return { name: col } }) : []
// If any column name is '*', show all columns
var star_col = _.find(options.columns, function (o) { return o['name'] === '*' })
if (star_col) {
var action_header_cols = _.cloneDeep(meta.columns)
_.map(options.columns, function (option_col) {
var found = _.find(meta.columns, function (o) { return o['name'] === option_col.name })
if (!found && option_col.name !== '*')
action_header_cols.push(option_col)
})
var star_col_index = _.findIndex(options.columns, function (o) { return o['name'] === '*' })
if (star_col_index >= 0) {
var resolved_star_cols = options.columns.map(function(each_col_options) {
if (each_col_options.name !== '*') return each_col_options
return meta.columns.map(function(col_opts) {
return Object.assign({}, options.columns[star_col_index], col_opts)
})
}).reduce(function (acc, curr) {
if (!Array.isArray(curr)) return acc.concat([curr])
return acc.concat(curr)
}, [])
options.columns = _.cloneDeep(resolved_star_cols)
action_header_cols = _.map(action_header_cols, function (col) {
var options_col = _.find(options.columns, function (o) { return o['name'] === col.name })
return options_col ? options_col : $.extend({}, star_col, col)
})
}
options.columns = action_header_cols ? action_header_cols : options.columns
// Render all components into respective targets
var template_data = {
data: data,
......@@ -141,12 +140,15 @@ export function formhandler(js_options) {
var url_args = parse(location.hash.replace(/^#/, '')).searchList
url_args = namespace(url_args, options.name)
// Create arguments passed to the FormHandler. Override with the user URL args
var args = _.extend({
c: options.columns.map(function (d) { return d.name }),
var default_url_args = {
_limit: options.pageSize,
_format: 'json',
_meta: 'y'
}, url_args)
}
var star_col = _.find(options.columns, function (o) { return o['name'] === '*' })
if (!star_col) default_url_args['_c'] = options.columns.map(function (d) { return d.name })
var args = _.extend(default_url_args, url_args)
$('.loader', $this).removeClass('d-none')
function done(data, status, xhr) {
......
......@@ -14,7 +14,7 @@ const app = express()
app.route('/formhandler-data').get(function(req, res) {
var url = req.protocol + '://' + req.get('host') + req.originalUrl
res.send(g1.datafilter(data, g1.url.parse(url).searchList, 'fhname13'))
res.send(g1.datafilter(data, g1.url.parse(url).searchList))
})
app.route('/data-list').get(function (req, res) {
......
......@@ -131,7 +131,7 @@
$('.add-btn').click()
t.ok($('.edit-btn').prop('disabled'))
// stripes column is dropdown select HTML element and not input textbox
t.equals($('div.delete_btn tr.new-row td:nth-child(6) select').length, 1)
t.equals($('div.delete_btn tr.new-row td:nth-child(21) select').length, 1)
// all other columns must be input textbox and editable, overriding isEditable: false option also
t.equals($('div.delete_btn tr.new-row td:nth-child(1) input').length, 1)
$('.add-btn').click()
......
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