Skip to content

Commit f7112c3

Browse files
authored
Lke 1588 add truncated option (#3)
Data Table plugin: Add an option to show long text
1 parent 8ad4618 commit f7112c3

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This plugin supports the following URL parameters in the query string:
4545
| `param_number_{{Encoded field name}}` | number (**optional**) | *For query templates*, any numerical parameter of the template. | `param_number_age=30` |
4646
| `param_string_{{Encoded field name}}` | string (**optional**) | *For query templates*, any string parameter of the template. | `param_string_city=Paris` |
4747
| `param_ids_{{Encoded field name}}` | comma-separated list (**optional**) | *For query templates*, any edgeset/nodeset parameter of the template. | `param_ids_target_ids=1,50,12` |
48+
| `showLongValues` | boolean (**optional**) | Avoids truncation of long texts. | `showLongValues=false` |
4849

4950
### Usage with standard queries
5051

public/css/main.css

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,16 @@ svg.stroke {
297297
border-radius: 4px !important;
298298
}
299299

300-
.tabulator-cell {
301-
height: 44px;
302-
padding: 12px !important;
303-
border-bottom: 1px solid #aaa !important;
304-
background-color: #fff !important;
300+
.tabulator-row .tabulator-cell {
301+
padding: 12px;
302+
border-bottom: 1px solid #aaa;
303+
background-color: #fff;
304+
white-space: pre-wrap;
305+
max-width: 300px;
306+
}
307+
308+
.tabulator .tabulator-header .tabulator-col {
309+
max-width: 300px;
305310
}
306311

307312
.tabulator-row {

public/js/main.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let tableStructure;
44
let schema;
55
let table;
66
let query;
7+
let isShowingLongValues;
78
let pluginConfiguration;
89
const headersToAlignRight = [];
910
const loaderElement = document.getElementById('loader');
@@ -137,7 +138,8 @@ function getParameter(value, key) {
137138
'sourceKey',
138139
'limit',
139140
'queryId',
140-
'queryName'
141+
'queryName',
142+
'showLongValues'
141143
],
142144
startWith: [
143145
'param_number_',
@@ -252,7 +254,12 @@ async function validatePluginConfiguration() {
252254
* @param cell
253255
* @returns {string}
254256
*/
255-
function truncateTableText(cell) {
257+
function formatTableCell(cell) {
258+
cell.getElement().setAttribute("dir", "auto"); //Add support for right to left text
259+
260+
if (isShowingLongValues) {
261+
return cell.getValue();
262+
}
256263
return truncateText(cell.getValue(), 38);
257264
}
258265

@@ -342,9 +349,9 @@ function getTableStructure(schemaStructure) {
342349
title: property.propertyKey,
343350
field: escapeDotCharacters(property.propertyKey),
344351
align: align,
345-
titleFormatter: truncateTableText,
352+
titleFormatter: formatTableCell,
346353
headerSort: false,
347-
formatter: truncateTableText,
354+
formatter: formatTableCell,
348355
tooltip: getFieldTooltip
349356
};
350357
});
@@ -709,6 +716,15 @@ async function getQuery() {
709716
}
710717
}
711718

719+
function parseBool(val) {
720+
if ((typeof val === 'string' && (val.toLowerCase() === 'true' || val.toLowerCase() === 'yes')) || val === 1)
721+
return true;
722+
else if ((typeof val === 'string' && (val.toLowerCase() === 'false' || val.toLowerCase() === 'no')) || val === 0)
723+
return false;
724+
725+
return false;
726+
}
727+
712728
/**
713729
* start the plugin table
714730
* @returns {Promise<void>}
@@ -717,6 +733,7 @@ async function main() {
717733
loaderElement.classList.add('active');
718734
parseQueryParams();
719735
try {
736+
isShowingLongValues = parseBool(queryParams.global.showLongValues);
720737
validateGlobalQueryParams(queryParams.global);
721738
query = JSON.parse((await getQuery()).response).body;
722739
validateTemplateFieldsParams(query);
@@ -729,7 +746,6 @@ async function main() {
729746
} catch(e) {
730747
handleError(e);
731748
}
732-
733749
}
734750

735751
main();

0 commit comments

Comments
 (0)