@@ -14,6 +14,7 @@ class SpreadsheetDataInput {
1414 this . fileInput = this . element . querySelector ( '.spreadsheet-file-select' ) ;
1515 this . directionInput = this . element . querySelector ( '.spreadsheet-input-direction' ) ;
1616 this . resetInput = this . element . querySelector ( '.spreadsheet-reset-button' ) ;
17+ this . unsetInput = this . element . querySelector ( '.spreadsheet-unset-button' ) ;
1718
1819 // data inputs
1920 this . originalDataInput = this . element . querySelector ( 'input.spreadsheet-input-original' ) ;
@@ -53,6 +54,19 @@ class SpreadsheetDataInput {
5354 this . updateSpreadsheet ( true ) ;
5455 } ) ;
5556
57+ // bind click on reset button
58+ this . unsetInput . addEventListener ( 'click' , ( ) => {
59+ this . dsn = new DSN ( '' ) ;
60+ this . sheetWrapper . style . display = 'none' ;
61+ if ( this . tableWrapper !== null ) {
62+ this . tableWrapper . style . display = 'none' ;
63+ }
64+ if ( this . directionInput !== null ) {
65+ this . directionInput . disabled = true ;
66+ }
67+ this . updateSpreadsheet ( ) ;
68+ } ) ;
69+
5670 // only bind if table wrapper exists
5771 if ( this . tableWrapper !== null ) {
5872 this . tableWrapper . addEventListener ( 'changeSelection' , ( event ) => {
@@ -71,21 +85,8 @@ class SpreadsheetDataInput {
7185
7286 // bind click on column based extraction toggle when range and direction select are active/available
7387 if ( this . tableWrapper !== null && this . directionInput !== null ) {
74- this . directionInput . addEventListener ( 'click' , ( event ) => {
75- const target = event . currentTarget ;
76- const targetParentNode = target . parentNode ;
77- this . dsn . direction = ( ( target . value || 'horizontal' ) === 'horizontal' ? 'vertical' : 'horizontal' ) ;
78-
79- // update target value and text
80- target . setAttribute ( 'value' , this . dsn . direction ) ;
81- if ( this . dsn . direction !== 'horizontal' ) {
82- targetParentNode . querySelector ( '.direction-row' ) . style . display = 'none' ;
83- targetParentNode . querySelector ( '.direction-column' ) . style . display = 'block' ;
84- } else {
85- targetParentNode . querySelector ( '.direction-column' ) . style . display = 'none' ;
86- targetParentNode . querySelector ( '.direction-row' ) . style . display = 'block' ;
87- }
88-
88+ this . directionInput . addEventListener ( 'click' , ( ) => {
89+ this . dsn . direction = ( ( this . dsn . direction || 'horizontal' ) === 'horizontal' ? 'vertical' : 'horizontal' ) ;
8990 this . updateSpreadsheet ( ) ;
9091 } ) ;
9192 }
@@ -101,6 +102,15 @@ class SpreadsheetDataInput {
101102
102103 // set select value to trigger browser showing correct item
103104 this . fileInput . value = this . dsn . fileUid ;
105+ if ( this . directionInput !== null ) {
106+ if ( this . dsn . direction === 'vertical' ) {
107+ this . directionInput . querySelector ( '.direction-row' ) . style . display = 'none' ;
108+ this . directionInput . querySelector ( '.direction-column' ) . style . display = 'block' ;
109+ } else {
110+ this . directionInput . querySelector ( '.direction-column' ) . style . display = 'none' ;
111+ this . directionInput . querySelector ( '.direction-row' ) . style . display = 'block' ;
112+ }
113+ }
104114
105115 // update formatted and database input value
106116 let formatted = this . spreadsheet . getSheetName ( ) ;
@@ -115,13 +125,23 @@ class SpreadsheetDataInput {
115125 database += '&range=' + this . dsn . range ;
116126 }
117127
118- // only set direction if range select and direction input is active/ available
128+ // only set direction if range select and direction input is available
119129 if ( this . tableWrapper !== null && this . directionInput !== null && this . dsn . direction . length > 0 ) {
120130 database += '&direction=' + this . dsn . direction ;
121131 }
122132
123133 this . formattedDataInput . setAttribute ( 'value' , formatted ) ;
124134 this . databaseDataInput . setAttribute ( 'value' , database ) ;
135+
136+ if ( database !== '' ) {
137+ this . sheetWrapper . style . display = '' ;
138+ if ( this . tableWrapper !== null ) {
139+ this . tableWrapper . style . display = '' ;
140+ }
141+ if ( this . directionInput !== null ) {
142+ this . directionInput . disabled = false ;
143+ }
144+ }
125145 }
126146}
127147
0 commit comments