mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-21 16:27:39 -06:00
Resolved few undo action on UI tabs - tabs were not getting activated
during undo-redo action. Also, resolved the focus losing issue, which closing the subnode editor using undo action. Also, resolved an issue related to 'beforeopen' failed on server node, due to api changes on tree events.
This commit is contained in:
parent
30c560f33b
commit
45596dffa0
@ -112,16 +112,14 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
return false;
|
||||
},
|
||||
/* Connect the server (if not connected), before opening this node */
|
||||
beforeopen: function(o) {
|
||||
var data = o.data;
|
||||
|
||||
beforeopen: function(item, data, browser) {
|
||||
if(!data || data._type != 'server') {
|
||||
return false;
|
||||
}
|
||||
|
||||
o.browser.tree.addIcon(o.item, {icon: data.icon});
|
||||
browser.tree.addIcon(item, {icon: data.icon});
|
||||
if (!data.connected) {
|
||||
connect_to_server(this, data, o.browser.tree, o.item);
|
||||
connect_to_server(this, data, browser.tree, item);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -52,7 +52,7 @@ OWNER TO helpdesk;\n';
|
||||
if (d && obj.Nodes[d._type].callbacks['selected'] &&
|
||||
_.isFunction(obj.Nodes[d._type].callbacks['selected'])) {
|
||||
return obj.Nodes[d._type].callbacks['selected'].apply(
|
||||
obj.Nodes[d._type], [i]);
|
||||
obj.Nodes[d._type], [i, d, obj]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -441,7 +441,7 @@ OWNER TO helpdesk;\n';
|
||||
typeof obj.Nodes[d._type].callbacks[eventName] ==
|
||||
'function') {
|
||||
return obj.Nodes[d._type].callbacks[eventName].apply(
|
||||
obj.Nodes[d._type], [item, eventName, options]
|
||||
obj.Nodes[d._type], [item, d, obj, options, eventName]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -475,6 +475,7 @@ OWNER TO helpdesk;\n';
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// There are some scripts which needed to be loaded immediately,
|
||||
|
@ -400,7 +400,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||
null).show()
|
||||
},
|
||||
// Callback called - when a node is selected in browser tree.
|
||||
selected: function(item) {
|
||||
selected: function(item, data, browser) {
|
||||
// Show the information about the selected node in the below panels,
|
||||
// which are visible at this time:
|
||||
// + Properties
|
||||
@ -408,9 +408,9 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||
// + Dependents
|
||||
// + Dependencies
|
||||
// + Statistics
|
||||
var b = pgBrowser,
|
||||
var b = browser || pgBrowser,
|
||||
t = b.tree,
|
||||
d = t.itemData(item);
|
||||
d = data || t.itemData(item);
|
||||
|
||||
// Update the menu items
|
||||
pgAdmin.Browser.enable_disable_menus.apply(b, [item]);
|
||||
@ -847,6 +847,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||
|
||||
if (self.handler && self.handler.undoMgr) {
|
||||
self.handler.undoMgr.merge(self.undoMgr);
|
||||
self.handler.ignoreTabChange = 0;
|
||||
}
|
||||
|
||||
self.undoMgr.addUndoType("pg-sub-node:opened", {
|
||||
@ -871,21 +872,28 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||
}
|
||||
});
|
||||
self.undoMgr.addUndoType("pg-sub-node:closed", {
|
||||
"handler": (self.handler || self),
|
||||
"on": function (cell, index) {
|
||||
return {
|
||||
"object": cell,
|
||||
"object": {'cell': cell, 'index': index},
|
||||
"before": null,
|
||||
"after": null,
|
||||
"options": index
|
||||
"options": this.handler
|
||||
}
|
||||
},
|
||||
"undo": function (cell, before, after, opts) {
|
||||
if (cell && cell.enterEditMode &&
|
||||
_.isFunction(cell.enterEditMode)) {
|
||||
cell.enterEditMode();
|
||||
cell.currentEditor.objectView.$el
|
||||
.find('.nav-tabs').first()
|
||||
.find('a[data-tab-index="' + opts + '"]').tab('show');
|
||||
"undo": function (obj, before, after, opts) {
|
||||
if (obj.cell && obj.cell.enterEditMode &&
|
||||
_.isFunction(obj.cell.enterEditMode)) {
|
||||
obj.cell.enterEditMode();
|
||||
var tabs = obj.cell.currentEditor.objectView.$el
|
||||
.find('.nav-tabs').first();
|
||||
var tab = tabs.find('a[data-tab-index="' + obj.index + '"]');
|
||||
if (tab.length) {
|
||||
opts.ignoreTabChange++;
|
||||
tab.tab('show');
|
||||
tabs.find('li').removeClass('active');
|
||||
tab.parent().addClass('active');
|
||||
}
|
||||
}
|
||||
},
|
||||
"redo": function (cell, before, after, opts) {
|
||||
@ -895,30 +903,58 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||
}
|
||||
}
|
||||
});
|
||||
(self.handler || self).ignoreTabChange = 0;
|
||||
self.undoMgr.addUndoType("pg-property-tab-changed", {
|
||||
"ignore": false,
|
||||
'mgr': self.undoMgr,
|
||||
"on": function (tabs) {
|
||||
if (!this.ignore && !this.mgr.stack.isCurrentlyUndoRedoing) {
|
||||
'handler': (self.handler || self),
|
||||
"on": function (obj) {
|
||||
if (!this.handler.ignoreTabChange &&
|
||||
!this.mgr.stack.isCurrentlyUndoRedoing) {
|
||||
return {
|
||||
"object": tabs,
|
||||
"object": obj,
|
||||
"before": null,
|
||||
"after": null,
|
||||
"options": this
|
||||
"options": this.handler
|
||||
}
|
||||
}
|
||||
this.igonre = false;
|
||||
this.handler.ignoreTabChange--;
|
||||
},
|
||||
"undo": function (obj, before, after, opts) {
|
||||
if (obj.hidden) {
|
||||
opts.ignore = true;
|
||||
$(obj.hidden).tab('show');
|
||||
var m = obj.model;
|
||||
if (obj.collection) {
|
||||
m = obj.collection.models[obj.index];
|
||||
}
|
||||
var panelEl = m && m.panelEl;
|
||||
if (panelEl) {
|
||||
var tabs = panelEl.find('.nav-tabs').first(),
|
||||
tab = tabs.find('a[data-tab-index="' + obj.hidden + '"]');
|
||||
if (tab.length) {
|
||||
opts.ignoreTabChange++;
|
||||
tab.tab('show');
|
||||
tabs.find('li').removeClass('active');
|
||||
tab.parent().addClass('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"redo": function (obj, before, after, opts) {
|
||||
if (obj.shown) {
|
||||
opts.ignore = true;
|
||||
$(obj.shown).tab('show');
|
||||
var m = obj.model;
|
||||
if (obj.collection) {
|
||||
m = obj.collection.models[obj.index];
|
||||
}
|
||||
var panelEl = m && m.panelEl;
|
||||
if (panelEl) {
|
||||
var tabs = panelEl.find('.nav-tabs').first(),
|
||||
tab = tabs.find('a[data-tab-index="' + obj.shown + '"]');
|
||||
if (tab.length) {
|
||||
opts.ignoreTabChange++;
|
||||
tab.tab('show');
|
||||
tabs.find('li').removeClass('active');
|
||||
tab.parent().addClass('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -181,12 +181,13 @@
|
||||
controls = this.controls,
|
||||
tmpls = this.template,
|
||||
self = this,
|
||||
idx=0;
|
||||
idx=1;
|
||||
|
||||
this.$el
|
||||
.empty()
|
||||
.attr('role', 'tabpanel')
|
||||
.attr('class', this.tabPanelClassName());
|
||||
m.panelEl = this.$el;
|
||||
|
||||
var tabHead = $('<ul class="nav nav-tabs" role="tablist"></ul>')
|
||||
.appendTo(this.$el);
|
||||
@ -208,12 +209,15 @@
|
||||
controls.push(cntr);
|
||||
});
|
||||
tabHead.find('a[data-toggle="tab"]').on('hidden.bs.tab', function() {
|
||||
self.hidden_tab = this;
|
||||
self.hidden_tab = $(this).data('tabIndex');
|
||||
});
|
||||
tabHead.find('a[data-toggle="tab"]').on('shown.bs.tab', function() {
|
||||
self.shown_tab = this;
|
||||
self.curr_tab_index = $(this).data('tabIndex');
|
||||
m.trigger('pg-property-tab-changed', {'shown': self.shown_tab, 'hidden': self.hidden_tab});
|
||||
self.shown_tab = $(this).data('tabIndex');
|
||||
m.trigger('pg-property-tab-changed', {
|
||||
'collection': m.collection, 'model': m,
|
||||
'index': _.indexOf(m.collection.models, m),
|
||||
'shown': self.shown_tab, 'hidden': self.hidden_tab
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -139,6 +139,7 @@
|
||||
|
||||
editorOptions['el'] = $(this.el);
|
||||
editorOptions['columns_length'] = this.column.collection.length;
|
||||
editorOptions['el'].attr('tabindex' , 1);
|
||||
|
||||
this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) {
|
||||
if (column.get("name") == this.column.get("name"))
|
||||
@ -163,6 +164,8 @@
|
||||
this.$el.empty();
|
||||
this.$el.html("<i class='fa fa-pencil-square-o'></i>");
|
||||
this.delegateEvents();
|
||||
if (this.grabFocus)
|
||||
this.$el.focus();
|
||||
return this;
|
||||
},
|
||||
exitEditMode: function() {
|
||||
@ -173,6 +176,7 @@
|
||||
this.model.trigger(
|
||||
"pg-sub-node:closed", this, index
|
||||
);
|
||||
this.grabFocus = true;
|
||||
},
|
||||
events: {
|
||||
'click': function(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user