354
* Waits until the new database is done creating, then unblocks the UI and
355
* logs the user in as admin
357
* @param {Number} db_creation_id identifier for the db-creation operation, used to fetch the current installation progress
358
* @param {Object} info info fields for this database creation
359
* @param {String} info.db name of the database being created
360
* @param {String} info.password super-admin password for the database
362
wait_for_newdb: function (db_creation_id, info) {
364
self.rpc('/web/database/progress', {
366
password: info.password
367
}, function (result) {
368
var progress = result[0];
369
// I'd display a progress bar, but turns out the progress status
370
// the server report kind-of blows goats: it's at 0 for ~75% of
371
// the installation, then jumps to 75%, then jumps down to either
372
// 0 or ~40%, then back up to 75%, then terminates. Let's keep that
373
// mess hidden behind a not-very-useful but not overly weird
376
setTimeout(function () {
377
self.wait_for_newdb(db_creation_id, info);
382
var admin = result[1][0];
383
setTimeout(function () {
384
self.getParent().do_login(
385
info.db, admin.login, admin.password);
392
354
* Blocks UI and replaces $.unblockUI by a noop to prevent third parties
393
355
* from unblocking the UI
427
389
self.$option_id.find("form[name=create_db_form]").validate({
428
390
submitHandler: function (form) {
429
391
var fields = $(form).serializeArray();
431
392
self.rpc("/web/database/create", {'fields': fields}, function(result) {
434
self.display_error(result);
437
393
if (self.db_list) {
438
394
self.db_list.push(self.to_object(fields)['db_name']);
439
395
self.db_list.sort();
440
396
self.getParent().set_db_list(self.db_list);
442
399
var form_obj = self.to_object(fields);
443
self.wait_for_newdb(result, {
444
password: form_obj['super_admin_pwd'],
445
db: form_obj['db_name']
400
self.getParent().do_login(
403
form_obj['create_admin_pwd']);
677
635
init: function() {
678
636
this._super.apply(this, arguments);
679
637
this.has_been_loaded = $.Deferred();
638
this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
681
640
start: function() {
682
641
this._super.apply(this, arguments);
683
642
this.$secondary_menus = this.getParent().$element.find('.oe_secondary_menus_container');
684
643
this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
644
$('html').bind('click', this.do_hide_more);
686
646
do_reload: function() {
694
654
on_loaded: function(data) {
695
656
this.data = data;
696
657
this.renderElement();
658
this.limit_entries();
697
659
this.$element.on('click', 'a[data-menu]', this.on_menu_click);
660
this.$element.on('click', 'a.oe_menu_more_link', function() {
661
self.$element.find('.oe_menu_more').toggle();
698
664
this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
699
665
// Hide second level submenus
700
666
this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
701
667
this.has_been_loaded.resolve();
669
limit_entries: function() {
670
var maximum_visible_links = this.maximum_visible_links;
671
if (maximum_visible_links === 'auto') {
672
maximum_visible_links = this.auto_limit_entries();
674
if (maximum_visible_links < this.data.data.children.length) {
675
var $more = $(QWeb.render('Menu.more')),
676
$index = this.$element.find('li').eq(maximum_visible_links - 1);
678
$more.find('.oe_menu_more').append($index.next().nextAll());
681
auto_limit_entries: function() {
682
// TODO: auto detect overflow and bind window on resize
683
var width = $(window).width();
684
return Math.floor(width / 125);
686
do_hide_more: function() {
687
this.$element.find('.oe_menu_more').hide();
704
690
* Opens a given menu by id, as if a user had browsed to that menu by hand
705
691
* except does not trigger any event on the way
857
844
var func = new openerp.web.Model("res.users").get_func("read");
858
845
return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
859
// TODO: Only show company if multicompany in use
860
self.$element.find('.oe_topbar_name').text(res.name + '/' + res.company_id[1]);
846
// TODO: Show company if multicompany is in use
847
var topbar_name = _.str.sprintf("%s (%s)", res.name, openerp.connection.db, res.company_id[1]);
848
self.$element.find('.oe_topbar_name').text(topbar_name);
861
849
return self.shortcut_load();