Commit 641c6fc8 authored by Tejesh's avatar Tejesh 🖖

merge star_col

parent aca93ac5
Pipeline #84234 failed with stage
in 2 minutes and 8 seconds
......@@ -95,23 +95,24 @@ 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_opts = _.find(options.columns, { name: '*' })
if (star_col_opts) {
var column_opts_clone = []
options.columns.forEach(function (col_opts) {
if (col_opts.name === '*') {
_.differenceBy(meta.columns, options.columns, 'name')
.forEach(function (meta_col_opts) {
column_opts_clone.push(Object.assign({}, star_col_opts, meta_col_opts))
})
} else {
column_opts_clone.push(col_opts)
}
})
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 = _.cloneDeep(column_opts_clone)
}
options.columns = action_header_cols ? action_header_cols : options.columns
// Render all components into respective targets
var template_data = {
data: data,
......@@ -141,12 +142,17 @@ 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) {
......
Continent,Cross,ID,Name,Shapes,Stripes,Symbols,Text&,Union-Flag,c1,c2,c3,c4,c5,c6,c7,c8,date col,Bool Col
Edited,,AND,Andorra,,Horizontal,,,,35,1.0,26.0,0.0,32.0,0.0,0.0,4.0,16-01-2013,True
Europe,,AND,Andorra,,Horizontal,,,,35,1.0,26.0,0.0,32.0,0.0,0.0,4.0,16-01-2013,True
Asia,,ARE,United Arab Emirates,,Horizontal,,,,24,0.0,0.0,25.0,0.0,0.0,25.0,24.0,17-02-2013,False
Asia,,AFG,Afghanistan,,Vertical,,Country&,,28,1.0,0.0,33.0,0.0,0.0,33.0,3.0,06-02-2013,True
North America,,ATG,Antigua Barbuda,,,,,,50,0.0,5.0,0.0,0.0,10.0,25.0,7.0,11-02-2013,False
......
......@@ -215,13 +215,13 @@
$(this).parent().html(html)
})
// editing rows with no click must also update values
var init_cell_value = $(".edit-fh table > tbody > tr:nth-child(1) > td:nth-child(2) > a.urlfilter").text().trim()
var stripe_cell_value = $('.edit-fh table tbody tr:nth-child(1) td:nth-child(4) a').text().trim()
var c1_cell_value = $('.edit-fh table tbody tr:nth-child(1) td:nth-child(3) a').text().trim()
$('.edit button').click()
// make sure the initial value is Europe
test.equals($(".edit-fh table > tbody > tr:nth-child(1) > td:nth-child(2) > input").val().trim(), init_cell_value)
// editing rows with no click must also update values
var init_cell_value = $(".edit-fh table > tbody > tr:nth-child(1) > td:nth-child(2) > a.urlfilter").text().trim()
var stripe_cell_value = $('.edit-fh table tbody tr:nth-child(1) td:nth-child(4) a').text().trim()
var c1_cell_value = $('.edit-fh table tbody tr:nth-child(1) td:nth-child(3) a').text().trim()
$('.edit button').click()
// make sure the initial value is Europe
test.equals($(".edit-fh table > tbody > tr:nth-child(1) > td:nth-child(2) > input").val().trim(), init_cell_value)
$(".edit-fh table > tbody > tr:nth-child(1) > td:nth-child(3) > input").val('300000').trigger('change')
......
......@@ -51,9 +51,6 @@
tape('$() test link false renders just td tag, without a tag', function(t) {
$('.no-link').formhandler({
columns: [
{
name: '*'
},
{
name: 'Continent',
link: '?ID=AND',
......@@ -73,6 +70,9 @@
'Diagonal'
]
}
},
{
name: '*'
}
],
pageSize: 3,
......@@ -81,8 +81,8 @@
edit: true
})
.on('load', function () {
t.equals($('div.no-link tr:nth-child(1) > td:nth-child(3)').text().trim(), "AND")
t.equals($('div.no-link tr:nth-child(2) > td:nth-child(3)').text().trim(), "ARE")
t.equals($('div.no-link tr:nth-child(1) > td:nth-child(2)').text().trim(), "AND")
t.equals($('div.no-link tr:nth-child(2) > td:nth-child(2)').text().trim(), "ARE")
t.ok($('div.no-link tr:nth-child(1) > td:nth-child(1) a').hasClass('urlfilter'), 'has class urlfilter')
t.ok($('div.no-link tr:nth-child(1) > td:nth-child(1) a').attr('href'), '?ID=AND')
......@@ -93,9 +93,6 @@
tape('$() test delete action for empty data case and test for edit and add button', function(t) {
$('.delete_btn').formhandler({
columns: [
{
name: '*'
},
{
name: 'ID',
editable: false
......@@ -109,7 +106,10 @@
'Horizontal',
'Diagonal'
]
}
},
},
{
name: '*'
},
{
name: 'DELETE Action',
......@@ -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(2) 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