@@ -22,6 +22,7 @@ const ModelProperty = {
2222 ROW_COUNT : 'row_count' ,
2323 SORT_CONTEXT : 'sort_context' ,
2424 TABLE_HTML : 'table_html' ,
25+ MAX_COLUMNS : 'max_columns' ,
2526} ;
2627
2728const Event = {
@@ -71,6 +72,10 @@ function render({ model, el }) {
7172 attributeFilter : [ 'class' , 'data-theme' , 'data-vscode-theme-kind' ] ,
7273 } ) ;
7374
75+ // Settings controls container
76+ const settingsContainer = document . createElement ( 'div' ) ;
77+ settingsContainer . classList . add ( 'settings' ) ;
78+
7479 // Pagination controls
7580 const paginationContainer = document . createElement ( 'div' ) ;
7681 paginationContainer . classList . add ( 'pagination' ) ;
@@ -102,6 +107,32 @@ function render({ model, el }) {
102107 pageSizeInput . appendChild ( option ) ;
103108 }
104109
110+ // Max columns controls
111+ const maxColumnsContainer = document . createElement ( 'div' ) ;
112+ maxColumnsContainer . classList . add ( 'max-columns' ) ;
113+ const maxColumnsLabel = document . createElement ( 'label' ) ;
114+ const maxColumnsInput = document . createElement ( 'select' ) ;
115+
116+ maxColumnsLabel . textContent = 'Max columns:' ;
117+
118+ // 0 represents "All"
119+ const maxColumnOptions = [ 3 , 5 , 7 , 10 , 20 , 0 ] ;
120+ for ( const cols of maxColumnOptions ) {
121+ const option = document . createElement ( 'option' ) ;
122+ option . value = cols ;
123+ option . textContent = cols === 0 ? 'All' : cols ;
124+
125+ const currentMax = model . get ( ModelProperty . MAX_COLUMNS ) ;
126+ // Handle None/null from python as 0/All
127+ const currentMaxVal =
128+ currentMax === null || currentMax === undefined ? 0 : currentMax ;
129+
130+ if ( cols === currentMaxVal ) {
131+ option . selected = true ;
132+ }
133+ maxColumnsInput . appendChild ( option ) ;
134+ }
135+
105136 function updateButtonStates ( ) {
106137 const currentPage = model . get ( ModelProperty . PAGE ) ;
107138 const pageSize = model . get ( ModelProperty . PAGE_SIZE ) ;
@@ -259,6 +290,12 @@ function render({ model, el }) {
259290 }
260291 } ) ;
261292
293+ maxColumnsInput . addEventListener ( Event . CHANGE , ( e ) => {
294+ const newVal = Number ( e . target . value ) ;
295+ model . set ( ModelProperty . MAX_COLUMNS , newVal ) ;
296+ model . save_changes ( ) ;
297+ } ) ;
298+
262299 model . on ( Event . CHANGE_TABLE_HTML , handleTableHTMLChange ) ;
263300 model . on ( `change:${ ModelProperty . ROW_COUNT } ` , updateButtonStates ) ;
264301 model . on ( `change:${ ModelProperty . ERROR_MESSAGE } ` , handleErrorMessageChange ) ;
@@ -270,11 +307,19 @@ function render({ model, el }) {
270307 paginationContainer . appendChild ( prevPage ) ;
271308 paginationContainer . appendChild ( pageIndicator ) ;
272309 paginationContainer . appendChild ( nextPage ) ;
310+
273311 pageSizeContainer . appendChild ( pageSizeLabel ) ;
274312 pageSizeContainer . appendChild ( pageSizeInput ) ;
313+
314+ maxColumnsContainer . appendChild ( maxColumnsLabel ) ;
315+ maxColumnsContainer . appendChild ( maxColumnsInput ) ;
316+
317+ settingsContainer . appendChild ( maxColumnsContainer ) ;
318+ settingsContainer . appendChild ( pageSizeContainer ) ;
319+
275320 footer . appendChild ( rowCountLabel ) ;
276321 footer . appendChild ( paginationContainer ) ;
277- footer . appendChild ( pageSizeContainer ) ;
322+ footer . appendChild ( settingsContainer ) ;
278323
279324 el . appendChild ( errorContainer ) ;
280325 el . appendChild ( tableContainer ) ;
0 commit comments