Allow the selection order to be preserved in the Select2 control to fix column ordering in data Import/Export. Fixes #3029

This commit is contained in:
Akshay Joshi
2018-10-31 10:09:40 +00:00
committed by Dave Page
parent 6e03775f05
commit 3359a0de7a
4 changed files with 43 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ for it.
.. toctree::
release_notes_3_6
release_notes_3_5
release_notes_3_4
release_notes_3_3

View File

@@ -0,0 +1,18 @@
***********
Version 3.6
***********
Release date: 2018-11-29
This release contains a number of features and fixes reported since the release of pgAdmin4 3.5
Features
********
Bug fixes
*********
| `Bug #3029 <https://redmine.postgresql.org/issues/3029>`_ - Allow the selection order to be preserved in the Select2 control to fix column ordering in data Import/Export.

View File

@@ -1781,8 +1781,29 @@ define([
first_empty: true,
multiple: false,
emptyOptions: false,
preserveSelectionOrder: false,
},
}),
events: function() {
// Inherit all default events of InputControl
return _.extend({}, Backform.SelectControl.prototype.events, {
'select2:select': 'onSelect',
});
},
onSelect: function (evt) {
var sel2Options = this.field.get('select2');
if (sel2Options.multiple && sel2Options.preserveSelectionOrder) {
var element = evt.params.data.element;
var $element = $(element);
$element.detach();
$(this.$sel).append($element);
$(this.$sel).trigger('change');
}
},
formatter: Select2Formatter,
template: _.template([
'<label class="<%=Backform.controlLabelClassName%>"><%=label%></label>',
@@ -1836,6 +1857,7 @@ define([
first_empty: true,
multiple: false,
emptyOptions: false,
preserveSelectionOrder: false,
});
// Evaluate the disabled, visible, and required option

View File

@@ -174,6 +174,7 @@ Backform, commonUtils, supportedNodes
allowClear: false,
placeholder: gettext('Columns for importing...'),
first_empty: false,
preserveSelectionOrder: true,
},
visible: 'importing',
helpMessage: gettext('An optional list of columns to be copied. If no column list is specified, all columns of the table will be copied.'),
@@ -192,6 +193,7 @@ Backform, commonUtils, supportedNodes
multiple: true,
allowClear: true,
placeholder: gettext('Colums for exporting...'),
preserveSelectionOrder: true,
},
visible: 'exporting',
transform: function(rows) {