diff --git a/libraries.txt b/libraries.txt
index 968a487cd..3fc8feb7a 100644
--- a/libraries.txt
+++ b/libraries.txt
@@ -15,5 +15,7 @@ Require.js 2.1.18 BSD/MIT http://requirejs.org/
Underscore.js 1.8.3 MIT http://underscorejs.org/
Underscore.string 387ab72d49 MIT http://epeli.github.io/underscore.string/
Backform.js 5859b4f9db MIT https://github.com/AmiliaApp/backform
+Backbone 1.1.2 MIT http://backbonejs.org
font-Awesome 4.3 SIL OFL http://fortawesome.github.io/Font-Awesome/
font-mfizz 1.2 MIT http://fizzed.com/oss/font-mfizz
+backgrid.js 0.3.5 MIT http://backgridjs.com/
diff --git a/web/pgadmin/browser/server_groups/templates/server_groups/server_groups.js b/web/pgadmin/browser/server_groups/templates/server_groups/server_groups.js
index 1632d79a1..7600fbf5a 100644
--- a/web/pgadmin/browser/server_groups/templates/server_groups/server_groups.js
+++ b/web/pgadmin/browser/server_groups/templates/server_groups/server_groups.js
@@ -32,8 +32,13 @@ function($, _, pgAdmin, Backbone) {
name: null
},
schema: [
- {id: 'id', label: 'ID', type: 'int', group: null, mode: ['properties']},
- {id: 'name', label:'Name', type: 'text', group: null, mode: ['properties', 'edit', 'create']}
+ {
+ id: 'id', label: 'ID', type: 'int', group: null,
+ mode: ['properties']
+ },{
+ id: 'name', label:'Name', type: 'text', group: null,
+ mode: ['properties', 'edit', 'create']
+ }
],
validate: function(attrs, options) {
if (!this.isNew() && 'id' in this.changed) {
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 85ec212d5..38822bd5a 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -52,8 +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],
- [{ data: d, browser: obj, item: i }]);
+ obj.Nodes[d._type], [i]);
}
}
};
@@ -442,10 +441,8 @@ OWNER TO helpdesk;\n';
typeof obj.Nodes[d._type].callbacks[eventName] ==
'function') {
return obj.Nodes[d._type].callbacks[eventName].apply(
- obj.Nodes[d._type], [{
- data: d, browser: obj, item: item,
- eventName: eventName, options: options
- }]);
+ obj.Nodes[d._type], [item, eventName, options]
+ );
}
}
switch (eventName) {
@@ -618,7 +615,8 @@ OWNER TO helpdesk;\n';
},
messages: {
'server_lost': '{{ _('Connection to the server has been lost!') }}',
- 'click_for_detailed_msg': '{{ _('%s
click here for details!') }}'
+ 'click_for_detailed_msg': '{{ _('%s
click here for details!') }}',
+ 'general_cateogty': '{{ _('General') }}'
}
});
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index 61b22fcbc..0e1f2c7ce 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -46,38 +46,6 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
return child;
};
- // Defines - which control needs to be instantiated in different modes.
- // i.e. Node properties, create, edit, etc.
- var controlType = {
- 'properties': {
- 'int': 'uneditable-input',
- 'text': 'uneditable-input',
- 'numeric': 'uneditable-input',
- 'date': 'date',
- 'boolean': 'bool-text',
- 'options': Backform.ReadonlyOptionControl,
- 'multiline': 'textarea'
- },
- 'edit': {
- 'int': 'input',
- 'text': 'input',
- 'numeric': 'input',
- 'date': 'date',
- 'boolean': 'boolean',
- 'options': 'select',
- 'multiline': 'textarea'
- },
- 'create': {
- 'int': 'input',
- 'text': 'input',
- 'numeric': 'input',
- 'date': 'date',
- 'boolean': 'boolean',
- 'options': 'select',
- 'multiline': 'textarea'
- }
- };
-
_.extend(pgAdmin.Browser.Node, {
// Node type
type: undefined,
@@ -115,9 +83,9 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
//
// Used to generate view for the particular node properties, edit,
// creation.
- getView: function(type, el, node, formType, callback) {
+ getView: function(type, el, node, formType, callback, data) {
- if (!this.type || this.type == '' || !type in controlType)
+ if (!this.type || this.type == '')
// We have no information, how to generate view for this type.
return null;
@@ -131,62 +99,25 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
// node.
return null;
- var opts = {};
+ var attrs = {};
// In order to get the object data from the server, we must set
// object-id in the model (except in the create mode).
if (type !== 'create') {
- opts[this.model.idAttribute || 'id'] = node._id;
+ attrs[this.model.idAttribute || 'id'] = node._id;
}
// We know - which data model to be used for this object.
- var newModel = new (this.model.extend({urlRoot: urlBase}))(opts);
+ var newModel = new (this.model.extend({urlRoot: urlBase}))(attrs, {
+ onChangeData: data,
+ onChangeCallback: callback
+ }),
+ groups = Backform.generateViewSchema(newModel, type);
// 'schema' has the information about how to generate the form.
- if (newModel.schema && _.isArray(newModel.schema)) {
- var groups = {};
-
- _.each(newModel.schema, function(f) {
- // Do we understand - what control, we're creating
- // here?
- if (f && f.mode && _.isObject(f.mode) &&
- _.indexOf(f.mode, type) != -1 &&
- type in controlType) {
- // Each field is kept in specified group, or in
- // 'General' category.
- var group = f.group || '{{ _("General") }}';
-
- // Generate the empty group list (if not exists)
- if (!groups[group]) {
- groups[group] = [];
- }
-
- // Temporarily store in dictionaly format for
- // utilizing it later.
- groups[group].push({
- name: f.id, label: f.label,
- control: controlType[type][f.type],
- // Do we need to show this control in this mode?
- visible: f.show && newModel[f.show] &&
- typeof newModel[f.show] == "function" ?
- newModel[f.show] : f.show,
- // This can be disabled in some cases (if not hidden)
- disabled: (type == 'properties' ? true : (
- f.disabled && newModel[f.disabled] &&
- typeof newModel[f.disabled] == "function" ?
- newModel[f.disabled] : undefined)),
- options: f.options
- });
- }
- });
-
- // Do we have fields to genreate controls, which we
- // understand?
- if (_.isEmpty(groups)) {
- return null;
- }
-
+ if (groups) {
var fields = [];
+
// This will contain the actual view
var view;
@@ -214,34 +145,24 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
// This is definetely not in create mode
newModel.fetch()
.success(function(res, msg, xhr) {
- if (res) {
- // We got the latest attributes of the
- // object. Render the view now.
- view.render();
- if (typeof(callback) != "undefined") {
- callback(view);
- }
- }
+ // We got the latest attributes of the
+ // object. Render the view now.
+ view.render();
})
- .error(function(m, jqxhr) {
+ .error(function(jqxhr, error, message) {
// TODO:: We may not want to continue from here
- console.log(arguments);
Alertify.pgNotifier(
- "error", jqxhr,
+ error, jqxhr,
S(
"{{ _("Error fetching the properties - %%s!") }}"
- ).sprintf(jqxhr.statusText).value()
+ ).sprintf(message).value()
);
});
} else {
// Yay - render the view now!
view.render();
- if (typeof(callback) != "undefined") {
- callback(view);
- }
}
}
-
return view;
}
@@ -475,7 +396,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
null).show()
},
// Callback called - when a node is selected in browser tree.
- selected: function(o) {
+ selected: function(item) {
// Show the information about the selected node in the below panels,
// which are visible at this time:
// + Properties
@@ -483,53 +404,54 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
// + Dependents
// + Dependencies
// + Statistics
+ var b = pgBrowser,
+ t = b.tree,
+ d = t.itemData(item);
// Update the menu items
- pgAdmin.Browser.enable_disable_menus.apply(o.browser, [o.item]);
+ pgAdmin.Browser.enable_disable_menus.apply(b, [item]);
- if (o && o.data && o.browser) {
- var br = o.browser;
- if ('properties' in br.panels &&
- br.panels['properties'] &&
- br.panels['properties'].panel &&
- br.panels['properties'].panel.isVisible()) {
+ if (d && b) {
+ if ('properties' in b.panels &&
+ b.panels['properties'] &&
+ b.panels['properties'].panel &&
+ b.panels['properties'].panel.isVisible()) {
// Show object properties (only when the 'properties' tab
// is active).
- this.showProperties(o.item, o.data,
- pgBrowser.panels['properties'].panel);
+ this.showProperties(item, d, b.panels['properties'].panel);
}
- if ('sql' in br.panels &&
- br.panels['sql'] &&
- br.panels['sql'].panel &&
- br.panels['sql'].panel.isVisible()) {
+ if ('sql' in b.panels &&
+ b.panels['sql'] &&
+ b.panels['sql'].panel &&
+ b.panels['sql'].panel.isVisible()) {
// TODO:: Show reverse engineered query for this object (when 'sql'
// tab is active.)
}
- if ('statistics' in br.panels &&
- br.panels['statistics'] &&
- br.panels['statistics'].panel &&
- br.panels['statistics'].panel.isVisible()) {
+ if ('statistics' in b.panels &&
+ b.panels['statistics'] &&
+ b.panels['statistics'].panel &&
+ b.panels['statistics'].panel.isVisible()) {
// TODO:: Show statistics for this object (when the 'statistics'
// tab is active.)
}
- if ('dependencies' in br.panels &&
- br.panels['dependencies'] &&
- br.panels['dependencies'].panel &&
- br.panels['dependencies'].panel.isVisible()) {
+ if ('dependencies' in b.panels &&
+ b.panels['dependencies'] &&
+ b.panels['dependencies'].panel &&
+ b.panels['dependencies'].panel.isVisible()) {
// TODO:: Show dependencies for this object (when the
// 'dependencies' tab is active.)
}
- if ('dependents' in br.panels &&
- br.panels['dependents'] &&
- br.panels['dependents'].panel &&
- br.panels['dependents'].panel.isVisible()) {
+ if ('dependents' in b.panels &&
+ b.panels['dependents'] &&
+ b.panels['dependents'].panel &&
+ b.panels['dependents'].panel.isVisible()) {
// TODO:: Show dependents for this object (when the 'dependents'
// tab is active.)
}
}
},
- refresh_node: function(args) {
- this.callbacks.selected();
+ refresh_node: function(item) {
+ this.callbacks.selected(undefined, item);
}
},
/**********************************************************************
@@ -544,7 +466,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
tree = pgAdmin.Browser.tree,
j = panel.$container.find('.obj_properties').first(),
view = j.data('obj-view'),
- content = $('