Allow to create sub-menu/menu-group by specify the same category in

multiple menu-items (not just the 'create' menu-group).

Moved all the main menu/context menu generation implementation in the
'menu' javascript menu.

In this implementation, if more than one menu-items specify same type
of categories, they will be created withing that group, otherwise - it
will be created separately (unless 'single' property of that category is
set to true).

We can also provide icon, priority, separator(s) above/below it for the
individual sub-menu too using pgAdmin.Browser.add_menu_category
function(...).
This commit is contained in:
Ashesh Vashi
2016-03-21 23:56:06 +05:30
parent 79d6d50dcc
commit 87f9834951
7 changed files with 395 additions and 152 deletions

View File

@@ -10,7 +10,7 @@
"""Browser integration functions for the Test module."""
MODULE_NAME = 'test'
from flask.ext.security import login_required
from flask import render_template, url_for, current_app
from flask import url_for, current_app
from flask.ext.babel import gettext
from pgadmin.utils import PgAdminModule
from pgadmin.utils.menu import MenuItem
@@ -22,32 +22,37 @@ class TestModule(PgAdminModule):
return {'file_items': [
MenuItem(name='mnu_generate_test_html',
label=gettext('Generated Test HTML'),
priority=100,
priority=2,
url=url_for('test.generated')),
MenuItem(name='mnu_test_alert',
label=gettext('Test Alert'),
priority=200,
module='pgAdmin.Test',
category=gettext('alertify'),
callback='test_alert'),
MenuItem(name='mnu_test_confirm',
label=gettext('Test Confirm'),
priority=300,
module='pgAdmin.Test',
category=gettext('alertify'),
callback='test_confirm'),
MenuItem(name='mnu_test_dialog',
label=gettext('Test Dialog'),
priority=400,
module='pgAdmin.Test',
category=gettext('alertify'),
callback='test_dialog'),
MenuItem(name='mnu_test_prompt',
label=gettext('Test Prompt'),
priority=500,
module='pgAdmin.Test',
category=gettext('alertify'),
callback='test_prompt'),
MenuItem(name='mnu_test_notifier',
label=gettext('Test Notifier'),
priority=600,
module='pgAdmin.Test',
category=gettext('alertify'),
callback='test_notifier'),
MenuItem(name='mnu_test_disabled',
label=gettext('Test Disabled'),

View File

@@ -3,6 +3,9 @@ define(
function($, alertify, pgAdmin, pgServer, ServerGroup) {
pgAdmin = pgAdmin || window.pgAdmin || {};
if (pgAdmin.Test)
return pgAdmin.Test;
pgAdmin.Test = {
test_alert: function() {
alertify.alert(
@@ -66,19 +69,31 @@ define(
alertify.myAlert('Dialog Test 2',
'This is another test dialog from Alertify!', 'This is dialog 2');
},
init: function() {
if (this.initialized)
return;
this.initialized = true;
// Add the alertify category
pgAdmin.Browser.add_menu_category(
'alertify', 'Alertify', 3, 'fa fa-film', true, true
);
pgServer.on(
'server-connected', function() {
console.log(arguments);
console.log('Yay - we connected the server!');
},
{'a': 'test'});
ServerGroup.on('browser-node.loaded', function() {
console.log('I know that the server-group has been expanded!');
}, pgAdmin.Test);
}
};
pgServer.on(
'server-connected', function() {
console.log(arguments);
console.log('Yay - we connected the server!');
},
{'a': 'test'});
ServerGroup.on('browser-node.loaded', function() {
console.log('I know that the server-group has been expanded!');
}, pgAdmin.Test);
return pgAdmin.Test;
});