mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Rename the "Resize by data?" to "Columns sized by" and disabled the 'Maximum column width'
button if 'Columns sized by' is set to 'Column data'. Fixes #6622
This commit is contained in:
@@ -892,6 +892,13 @@ define('tools.querytool', [
|
||||
column_size[table_name] = {};
|
||||
}
|
||||
|
||||
// Keep track of column_data_max_width
|
||||
self.max_width_changed = false;
|
||||
if (_.isUndefined(self.old_column_data_max_width) || self.old_column_data_max_width != self.preferences.column_data_max_width) {
|
||||
self.old_column_data_max_width = self.preferences.column_data_max_width;
|
||||
self.max_width_changed = true;
|
||||
}
|
||||
|
||||
|
||||
_.each(columns, function(c) {
|
||||
c.display_name = _.escape(c.display_name);
|
||||
@@ -931,12 +938,12 @@ define('tools.querytool', [
|
||||
}
|
||||
|
||||
if (_.isUndefined(column_size[table_name][options.nonative_field])) {
|
||||
/* If column_data_auto_resize is true then for the first time set
|
||||
* the addWidth parameter to iconWidth and if it is false then
|
||||
/* If column_data_auto_resize is 'by_data' then for the first time set
|
||||
* the addWidth parameter to iconWidth and if it is 'by_name' then
|
||||
* calculate width based on longer string among data type or
|
||||
* column name.
|
||||
*/
|
||||
if (self.preferences.column_data_auto_resize) {
|
||||
if (self.preferences.column_data_auto_resize === 'by_data') {
|
||||
options['addWidth'] = iconWidth;
|
||||
options['width'] = NaN;
|
||||
} else {
|
||||
@@ -1187,9 +1194,9 @@ define('tools.querytool', [
|
||||
dataView.onRowsChanged.subscribe(function(e, args) {
|
||||
grid.invalidateRows(args.rows);
|
||||
grid.render();
|
||||
// Resize all columns if column_data_auto_resize is true.
|
||||
if (self.preferences.column_data_auto_resize) {
|
||||
grid.resizeAllColumns && grid.resizeAllColumns(self.preferences.column_data_max_width);
|
||||
// Resize all columns if column_data_auto_resize is 'by_data'.
|
||||
if (self.preferences.column_data_auto_resize === 'by_data') {
|
||||
grid.resizeAllColumns && grid.resizeAllColumns(self.preferences.column_data_max_width, self.max_width_changed);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1430,7 +1437,7 @@ define('tools.querytool', [
|
||||
}
|
||||
dataView.setItems(collection, self.client_primary_key);
|
||||
/* Resize the columns once if data empty */
|
||||
if (collection.length === 0 && self.preferences.column_data_auto_resize) {
|
||||
if (collection.length === 0 && self.preferences.column_data_auto_resize === 'by_data') {
|
||||
self.grid.resizeAllColumns && self.grid.resizeAllColumns();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -270,27 +270,27 @@ def register_query_tool_preferences(self):
|
||||
|
||||
self.column_data_auto_resize = self.preference.register(
|
||||
'Results_grid', 'column_data_auto_resize',
|
||||
gettext("Resize by data?"), 'boolean', True,
|
||||
gettext("Columns sized by"), 'radioModern', 'by_data',
|
||||
options=[{'label': gettext('Column data'), 'value': 'by_data'},
|
||||
{'label': gettext('Column name'), 'value': 'by_name'}],
|
||||
category_label=PREF_LABEL_RESULTS_GRID,
|
||||
help_str=gettext(
|
||||
'If set to True then data columns will auto-size to the maximum '
|
||||
'If set to \'Column data\' columns will auto-size to the maximum '
|
||||
'width of the data in the column as loaded in the first batch. If '
|
||||
'False, the column will be sized to the widest of the data type '
|
||||
'or column name.'
|
||||
)
|
||||
'set to \'Column name\', the column will be sized to the widest '
|
||||
'of the data type or column name.'
|
||||
),
|
||||
dependents=['column_data_max_width']
|
||||
)
|
||||
|
||||
self.column_data_max_width = self.preference.register(
|
||||
'Results_grid', 'column_data_max_width',
|
||||
gettext("Maximum column width"), 'integer', 0,
|
||||
gettext("Maximum column width (in Pixel)"), 'integer', 0,
|
||||
category_label=PREF_LABEL_RESULTS_GRID,
|
||||
help_str=gettext(
|
||||
'Specify the maximum width of the column when \'Resize by data?\' '
|
||||
'is set to True. If it is set to 0 then columns will auto-size to '
|
||||
'the maximum width of the data in the column. If '
|
||||
'\'Resize by data?\' is set to False then this setting won\'t '
|
||||
'take any effect.'
|
||||
)
|
||||
'Specify the maximum width of the column when '
|
||||
'\'Columns sized by \' is set to \'Column data\'.'
|
||||
),
|
||||
)
|
||||
|
||||
self.sql_font_size = self.preference.register(
|
||||
|
||||
Reference in New Issue
Block a user