Ensure that 'ENTER' key in the data filter should not run the query. Fixes #4199

This commit is contained in:
Akshay Joshi 2019-09-20 18:13:44 +05:30
parent faa6236580
commit 1bef98fdfa
6 changed files with 65 additions and 6 deletions

View File

@ -138,3 +138,8 @@ To delete a row from the grid, click the trash icon.
* Click the *Help* button (?) to access online help.
* Click the *Ok* button to save work.
* Click the *Close* button to discard current changes and close the dialog.
.. toctree::
:maxdepth: 2
viewdata_filter

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -16,3 +16,5 @@ Housekeeping
Bug fixes
*********
| `Issue #4199 <https://redmine.postgresql.org/issues/4199>`_ - Ensure that 'ENTER' key in the data filter should not run the query.

View File

@ -17,5 +17,5 @@ the selected browser node.
current database context.
* Use the :ref:`View Data <editgrid>` button to view/edit the data stored in a
selected table.
* Use the :ref:`Filtered Rows <editgrid>` button to access the Data Filter popup
* Use the :ref:`Filtered Rows <viewdata_filter>` button to access the Data Filter popup
to apply a filter to a set of data for viewing/editing.

View File

@ -0,0 +1,19 @@
.. _viewdata_filter:
******************************
`View/Edit Data Filter`:index:
******************************
You can access *Data Filter dialog* by clicking on *Filtered Rows* toolbar button
visible on the Browser panel or by selecting *View/Edit Data -> Filtered Rows*
context menu option.
This allows you to specify an SQL Filter to limit the data displayed
in the edit grid window:
.. image:: images/viewdata_filter_dialog.png
:alt: View Data filter dialog window
:align: center
.. note:: Use SHIFT + ENTER keys to apply filter.

View File

@ -123,12 +123,24 @@ function initFilterDialog(alertify, pgBrowser) {
setup:function() {
return {
buttons:[{
text: '',
key: 112,
className: 'btn btn-secondary pull-left fa fa-question pg-alertify-icon-button',
attrs: {
name: 'dialog_help',
type: 'button',
label: gettext('Data Filter'),
url: url_for('help.static', {
'filename': 'viewdata_filter.html',
}),
},
},{
text: gettext('Cancel'),
key: 27,
className: 'btn btn-secondary fa fa-times pg-alertify-button',
},{
text: gettext('OK'),
key: 13,
key: null,
className: 'btn btn-primary fa fa-check pg-alertify-button',
}],
options: {
@ -141,7 +153,19 @@ function initFilterDialog(alertify, pgBrowser) {
};
},
build: function() {
alertify.pgDialogBuild.apply(this);
var that = this;
alertify.pgDialogBuild.apply(that);
// Set the tooltip of OK
$(that.__internal.buttons[2].element).attr('title', gettext('Use SHIFT + ENTER to apply filter...'));
// For sort/filter dialog we capture the keypress event
// and on "shift + enter" we clicked on "OK" button.
$(that.elements.body).on('keypress', function(evt) {
if (evt.shiftKey && evt.keyCode == 13) {
that.__internal.buttons[2].element.click();
}
});
},
prepare:function() {
var that = this,
@ -155,7 +179,7 @@ function initFilterDialog(alertify, pgBrowser) {
this.setContent($content.get(0));
// Disable OK button
that.__internal.buttons[1].element.disabled = true;
that.__internal.buttons[2].element.disabled = true;
// Apply CodeMirror to filter text area.
this.filter_obj = CodeMirror.fromTextArea($sql_filter.get(0), {
@ -181,9 +205,9 @@ function initFilterDialog(alertify, pgBrowser) {
that.filter_obj.on('change', function() {
if (that.filter_obj.getValue() !== '') {
that.__internal.buttons[1].element.disabled = false;
that.__internal.buttons[2].element.disabled = false;
} else {
that.__internal.buttons[1].element.disabled = true;
that.__internal.buttons[2].element.disabled = true;
}
});
},
@ -221,6 +245,15 @@ function initFilterDialog(alertify, pgBrowser) {
e
);
});
} else if(closeEvent.index == 0) {
/* help Button */
closeEvent.cancel = true;
pgBrowser.showHelp(
closeEvent.button.element.name,
closeEvent.button.element.getAttribute('url'),
null, null
);
return;
}
},
};