Skip to content

Commit 396cfeb

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents c3de952 + b26d378 commit 396cfeb

7 files changed

Lines changed: 314 additions & 269 deletions

File tree

Resources/Private/Assets/JavaScript/main.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Resources/Private/Language/de.locallang.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
</trans-unit>
2626
<trans-unit id="formengine.spreadsheet.button.reset.title" xml:space="preserve">
2727
<source>Revert Changes</source>
28+
<target>Änderungen verwerfen</target>
29+
</trans-unit>
30+
<trans-unit id="formengine.spreadsheet.button.unset.title" xml:space="preserve">
31+
<source>Unset field value</source>
2832
<target>Zurücksetzen</target>
2933
</trans-unit>
3034
<trans-unit id="formengine.spreadsheet.label.direction.row-based" xml:space="preserve">

Resources/Private/Language/locallang.xlf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<trans-unit id="formengine.spreadsheet.button.reset.title" xml:space="preserve">
2222
<source>Revert Changes</source>
2323
</trans-unit>
24+
<trans-unit id="formengine.spreadsheet.button.unset.title" xml:space="preserve">
25+
<source>Unset field value</source>
26+
</trans-unit>
2427
<trans-unit id="formengine.spreadsheet.label.direction.row-based" xml:space="preserve">
2528
<source>Row-based Extraction</source>
2629
</trans-unit>

Resources/Private/Templates/FormElement/DataInput.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
title="{f:translate(key: 'formengine.spreadsheet.button.reset.title', extensionName: 'spreadsheets')}">
8282
<c:icon identifier="actions-edit-undo"/>
8383
</button>
84+
<button class="btn btn-default spreadsheet-unset-button" type="button"
85+
title="{f:translate(key: 'formengine.spreadsheet.button.unset.title', extensionName: 'spreadsheets')}">
86+
<c:icon identifier="actions-close"/>
87+
</button>
8488
</span>
8589
</div>
8690

@@ -97,8 +101,7 @@
97101

98102
<f:section name="DirectionButton">
99103
<f:if condition="{config.allowColumnExtraction}">
100-
<button type="button" class="btn btn-default spreadsheet-input-direction"
101-
value="{valueObject.directionOfSelection}">
104+
<button type="button" class="btn btn-default spreadsheet-input-direction">
102105
<span class="direction-column"
103106
style="{f:if(condition: '{valueObject.directionOfSelection} != \'vertical\'', then: 'display:none')}">
104107
<c:icon identifier="actions-arrow-down"/>

0 commit comments

Comments
 (0)