',
- '
',
- '',
- '',
- ''
- ].join("\n")),
-
// This function is used to render the template.
render: function() {
var self = this;
- // Render header only.
- self.$el.empty();
- self.$el.html(self.template());
-
$('.editor-title').text(self.editor_title);
var filter = self.$el.find('#sql_filter');
@@ -306,40 +187,22 @@ define(
theme: 'pgadmin'
});
- var sub_panel = new pgAdmin.Browser.Panel({
- name: 'sub_panel',
+ var sql_panel = new pgAdmin.Browser.Panel({
+ name: 'sql_panel',
title: false,
width: '100%',
- height:'100%',
+ height:'20%',
isCloseable: false,
isPrivate: true
});
- sub_panel.load(main_docker);
- panel = main_docker.addPanel('sub_panel', wcDocker.DOCK.LEFT);
-
- // Create a Splitter to divide sql code and data output
- var hSplitter = new wcSplitter(
- "#editor-panel", panel,
- wcDocker.ORIENTATION.VERTICAL
- );
- hSplitter.scrollable(0, false, false);
- hSplitter.scrollable(1, true, true);
-
- // Initialize this splitter with a layout in each pane.
- hSplitter.initLayouts(wcDocker.LAYOUT.SIMPLE, wcDocker.LAYOUT.SIMPLE);
+ //sql_panel.load(main_docker);
+ sql_panel.load(main_docker);
+ var sql_panel_obj = main_docker.addPanel('sql_panel', wcDocker.DOCK.TOP);
- // By default, the splitter splits down the middle, we split the main panel by 80%.
- hSplitter.pos(0.25);
-
- var text_container = $('');
-
- // Add text_container at the top half of the splitter
- hSplitter.left().addItem(text_container);
-
- // Add data output panel at the bottom half of the splitter
var output_container = $('');
- hSplitter.right().addItem(output_container);
+ var text_container = $('').append(output_container);
+ sql_panel_obj.layout().addItem(text_container);
self.query_tool_obj = CodeMirror.fromTextArea(text_container.get(0), {
lineNumbers: true,
@@ -350,15 +213,6 @@ define(
mode: "text/x-sql"
});
- // Create wcDocker for tab set.
- var docker = new wcDocker(
- '#output-panel', {
- allowContextMenu: false,
- allowCollapse: false,
- themePath: '{{ url_for('static', filename='css/wcDocker/Themes') }}',
- theme: 'pgadmin'
- });
-
// Create panels for 'Data Output', 'Explain', 'Messages' and 'History'
var data_output = new pgAdmin.Browser.Panel({
name: 'data_output',
@@ -401,16 +255,16 @@ define(
})
// Load all the created panels
- data_output.load(docker);
- explain.load(docker);
- messages.load(docker);
- history.load(docker);
+ data_output.load(main_docker);
+ explain.load(main_docker);
+ messages.load(main_docker);
+ history.load(main_docker);
// Add all the panels to the docker
- self.data_output_panel = docker.addPanel('data_output', wcDocker.DOCK.LEFT);
- self.explain_panel = docker.addPanel('explain', wcDocker.DOCK.STACKED, self.data_output_panel);
- self.messages_panel = docker.addPanel('messages', wcDocker.DOCK.STACKED, self.data_output_panel);
- self.history_panel = docker.addPanel('history', wcDocker.DOCK.STACKED, self.data_output_panel);
+ self.data_output_panel = main_docker.addPanel('data_output', wcDocker.DOCK.BOTTOM, sql_panel_obj);
+ self.explain_panel = main_docker.addPanel('explain', wcDocker.DOCK.STACKED, self.data_output_panel);
+ self.messages_panel = main_docker.addPanel('messages', wcDocker.DOCK.STACKED, self.data_output_panel);
+ self.history_panel = main_docker.addPanel('history', wcDocker.DOCK.STACKED, self.data_output_panel);
self.render_history_grid();
},
@@ -659,24 +513,24 @@ define(
},
// Callback function for copy button click.
- on_copy: function() {
+ on_copy_row: function() {
var self = this;
// Trigger the copy signal to the SqlEditorController class
self.handler.trigger(
- 'pgadmin-sqleditor:button:copy',
+ 'pgadmin-sqleditor:button:copy_row',
self,
self.handler
);
},
// Callback function for paste button click.
- on_paste: function() {
+ on_paste_row: function() {
var self = this;
// Trigger the paste signal to the SqlEditorController class
self.handler.trigger(
- 'pgadmin-sqleditor:button:paste',
+ 'pgadmin-sqleditor:button:paste_row',
self,
self.handler
);
@@ -822,8 +676,8 @@ define(
self.on('pgadmin-sqleditor:button:exclude_filter', self._exclude_filter, self);
self.on('pgadmin-sqleditor:button:remove_filter', self._remove_filter, self);
self.on('pgadmin-sqleditor:button:apply_filter', self._apply_filter, self);
- self.on('pgadmin-sqleditor:button:copy', self._copy, self);
- self.on('pgadmin-sqleditor:button:paste', self._paste, self);
+ self.on('pgadmin-sqleditor:button:copy_row', self._copy_row, self);
+ self.on('pgadmin-sqleditor:button:paste_row', self._paste_row, self);
self.on('pgadmin-sqleditor:button:limit', self._set_limit, self);
self.on('pgadmin-sqleditor:button:flash', self._refresh, self);
self.on('pgadmin-sqleditor:button:cancel-query', self._cancel_query, self);
@@ -1024,15 +878,6 @@ define(
else
self.can_edit = true;
- /* If user can edit the data then we should enabled
- * Copy Row, Paste Row and 'Add New Row' buttons.
- */
- if (self.can_edit) {
- $("#btn-add-row").prop('disabled', false);
- $("#btn-copy").prop('disabled', false);
- $("#btn-paste").prop('disabled', false);
- }
-
/* If user can filter the data then we should enabled
* Filter and Limit buttons.
*/
@@ -1076,6 +921,7 @@ define(
self.collection.on('backgrid:editing', self.on_cell_editing, self);
self.collection.on('backgrid:row:selected', self.on_row_selected, self);
self.collection.on('backgrid:row:deselected', self.on_row_deselected, self);
+ self.listenTo(self.collection, "reset", self.collection_reset_callback);
// Show message in message and history tab in case of query tool
self.total_time = self.get_query_run_time(self.query_start_time, self.query_end_time);
@@ -1092,6 +938,29 @@ define(
self.trigger('pgadmin-sqleditor:loading-icon:hide');
},
+ collection_reset_callback: function() {
+ var self = this
+
+ /* If user can edit the data and current page is the
+ * last page of the paginator then we should enabled
+ * Copy Row, Paste Row and 'Add New Row' buttons.
+ */
+ if (self.can_edit &&
+ self.collection.state.currentPage != undefined &&
+ self.collection.state.lastPage != undefined &&
+ self.collection.state.currentPage == self.collection.state.lastPage)
+ {
+ $("#btn-add-row").prop('disabled', false);
+ $("#btn-copy-row").prop('disabled', false);
+ $("#btn-paste-row").prop('disabled', false);
+ }
+ else {
+ $("#btn-add-row").prop('disabled', true);
+ $("#btn-copy-row").prop('disabled', true);
+ $("#btn-paste-row").prop('disabled', true);
+ }
+ },
+
// This function creates the columns as required by the backgrid
_fetch_column_metadata: function(data) {
var colinfo = data.colinfo,
@@ -1728,7 +1597,7 @@ define(
},
// This function will copy the selected row.
- _copy: function() {
+ _copy_row: function() {
var self = this;
// Save the selected model as copied model for future use
@@ -1737,7 +1606,7 @@ define(
},
// This function will paste the selected row.
- _paste: function() {
+ _paste_row: function() {
var self = this;
new_model = null;
if ('copied_model' in self && self.copied_model != null) {
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/create.sql b/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/create.sql
deleted file mode 100644
index 7c17616..0000000
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/create.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-{# Insert the new row with primary keys (specified in primary_keys) #}
-INSERT INTO {{ conn|qtIdent(nsp_name, object_name) }} (
-{% for col in data_to_be_saved %}
-{% if not loop.first %}, {% endif %}{{ conn|qtIdent(col) }}{% endfor %}
-) VALUES (
-{% for col in data_to_be_saved %}
-{% if not loop.first %}, {% endif %}{{ data_to_be_saved[col]|qtLiteral }}{% endfor %}
-);
\ No newline at end of file
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/insert.sql b/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/insert.sql
new file mode 100644
index 0000000..7c17616
--- /dev/null
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/9.1_plus/insert.sql
@@ -0,0 +1,8 @@
+{# Insert the new row with primary keys (specified in primary_keys) #}
+INSERT INTO {{ conn|qtIdent(nsp_name, object_name) }} (
+{% for col in data_to_be_saved %}
+{% if not loop.first %}, {% endif %}{{ conn|qtIdent(col) }}{% endfor %}
+) VALUES (
+{% for col in data_to_be_saved %}
+{% if not loop.first %}, {% endif %}{{ data_to_be_saved[col]|qtLiteral }}{% endfor %}
+);
\ No newline at end of file
',
- '',
- '
',
- '',
- '',
- '',
- '
',
- '',
- '',
- '
',
- '',
- '',
- '',
- '',
- '
',
- '',
- '',
- '
',
- '',
- '',
- '',
- '',
- '',
- '
',
- '',
- '',
- '',
- '',
- '
',
- '',
- '',
- '
',
- ' }})