diff --git a/client/public/stylesheets/unitdatatable.css b/client/public/stylesheets/unitdatatable.css index 93e9d737..f666ab25 100644 --- a/client/public/stylesheets/unitdatatable.css +++ b/client/public/stylesheets/unitdatatable.css @@ -2,7 +2,7 @@ display:flex; flex-direction: column; font-size:13px; - max-height: 150px; + height: 250px; width:fit-content; } diff --git a/client/src/index.ts b/client/src/index.ts index f151acf2..9f9d19f4 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -141,13 +141,21 @@ function setupEvents() { /* Keyup events */ document.addEventListener("keyup", ev => { + switch (ev.code) { + case "KeyL": document.body.toggleAttribute("data-hide-labels"); break; + case "KeyD": toggleDemoEnabled(); + break; + + case "Quote": + unitDataTable.toggle(); } + }); /* @@ -158,7 +166,6 @@ function setupEvents() { unitName.setAttribute( "readonly", "true" ); // Do something with this: - console.log( unitName.value ); }); document.addEventListener( "editUnitName", ev => { diff --git a/client/src/units/unitdatatable.ts b/client/src/units/unitdatatable.ts index 07fb8f01..0e8bde65 100644 --- a/client/src/units/unitdatatable.ts +++ b/client/src/units/unitdatatable.ts @@ -2,7 +2,6 @@ export class UnitDataTable { #element; #tableId = "unit-data-table"; - #hasUpdated = false; constructor() { @@ -28,13 +27,27 @@ export class UnitDataTable { } + hide() { + this.getElement()?.closest( ".ol-dialog" )?.classList.add( "hide" ); + } + + refresh( units:object ) { - if ( this.#hasUpdated ) { - return; - } + const unitsArray = Object.values( units ).sort( ( a, b ) => { - const unitsArray = Object.values( units ); + const aVal = a.baseData.unitName.toLowerCase(); + const bVal = b.baseData.unitName.toLowerCase(); + + if ( aVal > bVal ) { + return 1; + } else if ( bVal > aVal ) { + return -1; + } else { + return 0; + } + + }); function addRow( parentEl:HTMLElement, columns:string[] ) { @@ -75,8 +88,16 @@ export class UnitDataTable { } - - this.#hasUpdated = true; - } + + + show() { + this.getElement()?.closest( ".ol-dialog" )?.classList.remove( "hide" ); + } + + + toggle() { + this.getElement()?.closest( ".ol-dialog" )?.classList.toggle( "hide" ); + } + } \ No newline at end of file diff --git a/client/views/unitdatatable.ejs b/client/views/unitdatatable.ejs index b71bca13..fb89a424 100644 --- a/client/views/unitdatatable.ejs +++ b/client/views/unitdatatable.ejs @@ -1,4 +1,10 @@ -