There was an error while loading. Please reload this page.
1 parent 2ea4e59 commit 5ab7640Copy full SHA for 5ab7640
7 files changed
js/src/export.js
@@ -599,9 +599,9 @@ window.AJAX.registerOnload('export.js', function () {
599
* Disables the view output as text option if the output must be saved as a file
600
*/
601
$('#plugins').on('change', function () {
602
- var activePlugin = $('#plugins').find('option:selected').val();
603
- var forceFile = $('#force_file_' + activePlugin).val();
604
- if (forceFile === 'true') {
+ const isBinary = $('#plugins').find('option:selected')
+ .attr('data-is-binary') === 'true';
+ if (isBinary) {
605
if ($('#radio_dump_asfile').prop('checked') !== true) {
606
$('#radio_dump_asfile').prop('checked', true);
607
Export.toggleSaveToFile();
libraries/classes/Controllers/Import/ImportController.php
@@ -251,10 +251,7 @@ public function __invoke(ServerRequest $request): void
251
return;
252
}
253
254
- $post_patterns = [
255
- '/^force_file_/',
256
- '/^' . $GLOBALS['format'] . '_/',
257
- ];
+ $post_patterns = ['/^' . $GLOBALS['format'] . '_/'];
258
259
Core::setPostAsGlobal($post_patterns);
260
libraries/classes/Plugins.php
@@ -259,7 +259,7 @@ public static function getDefault($section, $opt)
* @param ExportPlugin[]|ImportPlugin[]|SchemaPlugin[] $list
*
261
* @return array<int, array<string, bool|string>>
262
- * @psalm-return list<array{name: non-empty-lowercase-string, text: string, is_selected: bool, force_file: bool}>
+ * @psalm-return list<array{name: non-empty-lowercase-string, text: string, is_selected: bool, is_binary: bool}>
263
264
public static function getChoice(array $list, string $default): array
265
{
@@ -271,7 +271,7 @@ public static function getChoice(array $list, string $default): array
271
'name' => $pluginName,
272
'text' => self::getString($properties->getText()),
273
'is_selected' => $pluginName === $default,
274
- 'force_file' => $properties->getForceFile(),
+ 'is_binary' => $properties->getForceFile(),
275
];
276
277
templates/database/designer/schema_export.twig
@@ -8,10 +8,6 @@
8
{% endfor %}
9
</select>
10
11
- {% for option in plugins_choice %}
12
- <input type="hidden" id="force_file_{{ option.name }}" value="true">
13
- {% endfor %}
14
-
15
<input type="hidden" name="page_number" value="{{ page }}">
16
{{ options|raw }}
17
</fieldset>
templates/export.twig
@@ -120,13 +120,9 @@
120
<div class="card-body">
121
<select class="form-select" id="plugins" name="what" aria-label="{% trans 'File format to export' %}">
122
{% for option in plugins_choice %}
123
- <option value="{{ option.name }}"{{ option.is_selected ? ' selected' }}>{{ option.text }}</option>
+ <option value="{{ option.name }}"{{ option.is_selected ? ' selected' }} data-is-binary="{{ option.is_binary ? 'true' : 'false' }}">{{ option.text }}</option>
124
125
126
127
128
- <input type="hidden" id="force_file_{{ option.name }}" value="{{ option.force_file ? 'true' : 'false' }}">
129
130
</div>
131
132
templates/import.twig
@@ -170,10 +170,6 @@
170
171
172
173
174
175
176
177
<div id="import_notification"></div>
178
179
test/classes/PluginsTest.php
@@ -133,10 +133,10 @@ public function testGetChoice(): void
133
134
$actual = Plugins::getChoice($exportList, 'xml');
135
$expected = [
136
- ['name' => 'json', 'text' => 'JSON', 'is_selected' => false, 'force_file' => false],
137
- ['name' => 'ods', 'text' => 'OpenDocument Spreadsheet', 'is_selected' => false, 'force_file' => true],
138
- ['name' => 'sql', 'text' => 'SQL', 'is_selected' => false, 'force_file' => false],
139
- ['name' => 'xml', 'text' => 'XML', 'is_selected' => true, 'force_file' => false],
+ ['name' => 'json', 'text' => 'JSON', 'is_selected' => false, 'is_binary' => false],
+ ['name' => 'ods', 'text' => 'OpenDocument Spreadsheet', 'is_selected' => false, 'is_binary' => true],
+ ['name' => 'sql', 'text' => 'SQL', 'is_selected' => false, 'is_binary' => false],
+ ['name' => 'xml', 'text' => 'XML', 'is_selected' => true, 'is_binary' => false],
140
141
$this->assertEquals($expected, $actual);
142
0 commit comments