mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-20 11:48:31 -06:00
Fix the boolean editor, and warn the user if there are unsaved changed in the edit grid before refreshing.
This commit is contained in:
parent
fca331acb6
commit
087332f32e
@ -10,7 +10,8 @@
|
|||||||
$.extend(true, window, {
|
$.extend(true, window, {
|
||||||
"Slick": {
|
"Slick": {
|
||||||
"Formatters": {
|
"Formatters": {
|
||||||
"JsonString": JsonFormatter
|
"JsonString": JsonFormatter,
|
||||||
|
"Checkmark": CheckmarkFormatter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -28,4 +29,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckmarkFormatter(row, cell, value, columnDef, dataContext) {
|
||||||
|
return value ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -380,6 +380,14 @@ textarea.editor-text {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Slick.Editors.Checkbox */
|
||||||
|
input.editor-checkbox {
|
||||||
|
margin: 0;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Override selected row color */
|
/* Override selected row color */
|
||||||
.slick-cell.selected {
|
.slick-cell.selected {
|
||||||
background-color: #eeeeee !important;
|
background-color: #eeeeee !important;
|
||||||
|
@ -460,7 +460,8 @@ define(
|
|||||||
field: c.name,
|
field: c.name,
|
||||||
name: c.label
|
name: c.label
|
||||||
};
|
};
|
||||||
// If gird is editable then add formatter & editor as well
|
|
||||||
|
// If gird is editable then add editor
|
||||||
if(is_editable) {
|
if(is_editable) {
|
||||||
if(c.cell == 'Json') {
|
if(c.cell == 'Json') {
|
||||||
options['editor'] = Slick.Editors.JsonText;
|
options['editor'] = Slick.Editors.JsonText;
|
||||||
@ -468,13 +469,19 @@ define(
|
|||||||
else if(c.cell == 'number') {
|
else if(c.cell == 'number') {
|
||||||
options['editor'] = Slick.Editors.Text;
|
options['editor'] = Slick.Editors.Text;
|
||||||
}
|
}
|
||||||
|
else if(c.cell == 'boolean') {
|
||||||
|
options['editor'] = Slick.Editors.Checkbox;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
options['editor'] = Slick.Editors.pgText;
|
options['editor'] = Slick.Editors.pgText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// To handle json format properly in grid
|
|
||||||
|
// To handle json & boolean formatter in grid
|
||||||
if(c.cell == 'Json') {
|
if(c.cell == 'Json') {
|
||||||
options['formatter'] = Slick.Formatters.JsonString;
|
options['formatter'] = Slick.Formatters.JsonString;
|
||||||
|
} else if(c.cell == 'boolean') {
|
||||||
|
options['formatter'] = Slick.Formatters.Checkmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid_columns.push(options)
|
grid_columns.push(options)
|
||||||
@ -485,7 +492,7 @@ define(
|
|||||||
enableAddRow: is_editable,
|
enableAddRow: is_editable,
|
||||||
enableCellNavigation: true,
|
enableCellNavigation: true,
|
||||||
enableColumnReorder: false,
|
enableColumnReorder: false,
|
||||||
asyncEditorLoading: true,
|
asyncEditorLoading: false,
|
||||||
autoEdit: false
|
autoEdit: false
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -692,14 +699,12 @@ define(
|
|||||||
self.grid_resize(grid);
|
self.grid_resize(grid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Resize SlickGrid when output Panel gets focus
|
// Resize SlickGrid when output Panel gets focus
|
||||||
self.data_output_panel.on(wcDocker.EVENT.GAIN_FOCUS, function() {
|
self.data_output_panel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() {
|
||||||
// Resize grid only if output panel is visible
|
// Resize grid only if output panel is visible
|
||||||
if(self.data_output_panel.isVisible())
|
if(self.data_output_panel.isVisible())
|
||||||
self.grid_resize(grid);
|
self.grid_resize(grid);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* This function is responsible to render output grid */
|
/* This function is responsible to render output grid */
|
||||||
@ -1353,9 +1358,36 @@ define(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// This function makes the ajax call to execute the sql query.
|
// This function checks if there is any dirty data in the grid before
|
||||||
|
// it executes the sql query
|
||||||
_execute_data_query: function() {
|
_execute_data_query: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
// Check if the data grid has any changes before running query
|
||||||
|
if(_.has(self, 'data_store') &&
|
||||||
|
( _.size(self.data_store.added) ||
|
||||||
|
_.size(self.data_store.updated) ||
|
||||||
|
_.size(self.data_store.deleted))
|
||||||
|
) {
|
||||||
|
alertify.confirm('{{ _('Unsaved changes') }}',
|
||||||
|
'{{ _('The data has been modified, but not saved. Are you sure you wish to discard the changes?') }}',
|
||||||
|
function(){
|
||||||
|
// Do nothing as user do not want to save, just continue
|
||||||
|
self._run_query();
|
||||||
|
},
|
||||||
|
function(){
|
||||||
|
// Stop, User wants to save
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
).set('labels', {ok:'Yes', cancel:'No'});
|
||||||
|
} else {
|
||||||
|
self._run_query();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// This function makes the ajax call to execute the sql query.
|
||||||
|
_run_query: function() {
|
||||||
|
var self = this;
|
||||||
self.query_start_time = new Date();
|
self.query_start_time = new Date();
|
||||||
self.rows_affected = 0;
|
self.rows_affected = 0;
|
||||||
|
|
||||||
@ -1698,6 +1730,9 @@ define(
|
|||||||
case "double precision":
|
case "double precision":
|
||||||
col_cell = 'number';
|
col_cell = 'number';
|
||||||
break;
|
break;
|
||||||
|
case "boolean":
|
||||||
|
col_cell = 'boolean';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
col_cell = 'string';
|
col_cell = 'string';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user