@@ -15,8 +15,9 @@ const confirmBtn = editDialog.querySelector("#confirmBtn");
1515const selectEl = editDialog . querySelector ( "select" ) ; // store
1616const inputEl = editDialog . querySelector ( "input" ) ; // key
1717const textareaEl = editDialog . querySelector ( "textarea" ) ; // value
18+ const wrapCheckboxEl = editDialog . querySelector ( 'input[type="checkbox"]' ) ; // key
1819
19- let editorTempCell = null ;
20+ let editorTempRow = null ;
2021
2122// button refs
2223const impbtn = document . getElementById ( "impbtn" ) ;
@@ -30,14 +31,15 @@ const log = document.getElementById("log");
3031const tip = document . getElementById ( "tip" ) ;
3132
3233const tips = [
33- "Duplicate items with Copy & Import quickly " ,
34- "Filter do not change selections" ,
34+ "Duplicate items with Copy & Import" ,
35+ "Filter dont change selections" ,
3536 "Copy & Download act on selected items" ,
36- "Imported items become selected after Import" ,
37- "Hover Cells to show validation errors" ,
38- "Reorder rows before Copy or Download" ,
39- "Discard to drop all not submitted changes" ,
40- "Middle click the toolbar button to open detached" ,
37+ "Imported items become selected" ,
38+ "Hover cells to show validation errors" ,
39+ "Reorder before Copy or Download" ,
40+ "Discard drops all not submitted changes" ,
41+ "Middle click the toolbar button to open it detached" ,
42+ "Double click on a value cell to open the row editor" ,
4143] ;
4244
4345let validateAndHighlightTimer ;
@@ -274,10 +276,12 @@ var uniqueKey = function (cell, value, parameters) {
274276 return true ;
275277} ;
276278
279+ /*
280+ // when it contains linebreaks, we go into full editor mode
277281var editCheck = function (cell) {
278- const lines = cell . getValue ( ) . split ( / \r \n | \r | \n / ) ;
279- return lines . length < 10 ;
282+ return cell.getValue().split(/\r\n|\r|\n/).length < 10;
280283};
284+ */
281285
282286async function onDOMContentLoaded ( ) {
283287 if ( isNaN ( TABID ) ) {
@@ -293,7 +297,7 @@ async function onDOMContentLoaded() {
293297 columnDefaults : {
294298 resizable : false ,
295299 } ,
296- placeholder : "No items found " ,
300+ placeholder : "No items" ,
297301 layout : "fitDataStretch" ,
298302 pagination : false ,
299303 movableRows : true ,
@@ -342,12 +346,13 @@ async function onDOMContentLoaded() {
342346 hozAlign : "left" ,
343347 headerFilter : "list" ,
344348 editor : "list" ,
349+ //verticalNavigation: "hybrid",
345350 editorParams : { values : [ "Local" , "Session" ] } ,
346351 headerFilterPlaceholder : "Select" ,
347352 headerFilterFunc : storeHeaderFilter ,
348353 headerFilterParams : {
354+ clearable : true ,
349355 values : [ "Local" , "Session" ] ,
350- verticalNavigation : "hybrid" ,
351356 multiselect : true ,
352357 } ,
353358 validator : [ "in:Local|Session" , "required" ] ,
@@ -387,11 +392,13 @@ async function onDOMContentLoaded() {
387392 width : "25%" ,
388393 headerFilter : "input" ,
389394 headerFilterPlaceholder : "Filter" ,
395+ formatter : "plaintext" ,
390396 editor : "input" ,
391397 editorParams : {
392398 elementAttributes : {
393399 spellcheck : "false" ,
394400 } ,
401+ shiftEnterSubmit : true ,
395402 } ,
396403 } ,
397404
@@ -401,28 +408,32 @@ async function onDOMContentLoaded() {
401408 headerFilter : "input" ,
402409 headerFilterPlaceholder : "Filter" ,
403410 editor : "textarea" ,
404- editable : editCheck ,
411+ // editable: editCheck,
405412 editorParams : {
406413 elementAttributes : {
407414 spellcheck : "false" ,
415+ wrap : "off" ,
408416 } ,
409417 verticalNavigation : "editor" ,
410418 variableHeight : true ,
411419 shiftEnterSubmit : true ,
412420 } ,
413421 formatter : "plaintext" ,
414- cellClick : function ( e , cell ) {
422+ /**/
423+ cellDblClick : function ( e , cell ) {
424+ //if(!editCheck(cell)){
425+ editDialog . showModal ( ) ;
426+ editDialog . focus ( ) ; // focus something else first !!
415427 const rowData = cell . getRow ( ) . getData ( ) ;
416- if ( ! ( rowData . value . split ( / \r \n | \r | \n / ) . length < 10 ) ) {
417- editorTempCell = cell ;
418- textareaEl . value = rowData . value ;
419- selectEl . value = rowData . store ;
420- inputEl . value = rowData . key ;
421- editDialog . showModal ( ) ;
422- textareaEl . focus ( ) ;
423- textareaEl . setSelectionRange ( 0 , 0 ) ;
424- }
428+ editorTempRow = cell . getRow ( ) ;
429+ textareaEl . value = rowData . value ;
430+ selectEl . value = rowData . store ;
431+ inputEl . value = rowData . key ;
432+ textareaEl . focus ( ) ;
433+ textareaEl . setSelectionRange ( 0 , 0 ) ;
434+ //}
425435 } ,
436+ /**/
426437 } ,
427438 ] ,
428439 } ) ;
@@ -438,6 +449,7 @@ async function onDOMContentLoaded() {
438449 } ) ;
439450
440451 // load data
452+ table . alert ( "Loading data" ) ;
441453 const data = await getTblData ( ) ;
442454 data . forEach ( async ( e , index ) => {
443455 table . addRow ( e , true ) ;
@@ -451,6 +463,8 @@ async function onDOMContentLoaded() {
451463 }
452464 } ) ;
453465
466+ table . clearAlert ( ) ;
467+
454468 tableData = table . getData ( ) ;
455469
456470 // do this after the inital data load
@@ -462,10 +476,26 @@ async function onDOMContentLoaded() {
462476
463477 confirmBtn . addEventListener ( "click" , ( event ) => {
464478 event . preventDefault ( ) ; // dont submit fake form
465- editorTempCell . setValue ( textareaEl . value , true ) ;
479+
480+ editorTempRow . update ( {
481+ store : selectEl . value ,
482+ key : inputEl . value ,
483+ value : textareaEl . value ,
484+ } ) ;
485+
466486 editDialog . close ( ) ;
467487 } ) ;
468- }
488+
489+ //table.getColumn("store").setHeaderFilterValue(["Local","Session"]);
490+
491+ wrapCheckboxEl . addEventListener ( "click" , ( evt ) => {
492+ if ( evt . target . checked ) {
493+ textareaEl . style . whiteSpace = "nowrap" ;
494+ } else {
495+ textareaEl . style . whiteSpace = "wrap" ;
496+ }
497+ } ) ;
498+ } // onDOMContentLoaded
469499
470500function onChange ( evt ) {
471501 let id = evt . target . id ;
0 commit comments