/* This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. */ (function() { 'use strict'; Sao.Tab = Sao.class_(Object, { init: function(attributes) { Sao.Tab.tabs.push(this); this.attributes = jQuery.extend({}, attributes); this.buttons = {}; this.menu_buttons = {}; this.id = 'tab-' + Sao.Tab.counter++; this.name = ''; this.name_el = jQuery(''); this.view_prm = jQuery.when(); }, menu_def: function() { return [ { id: 'switch_', icon: 'tryton-switch', label: Sao.i18n.gettext('Switch'), tooltip: Sao.i18n.gettext('Switch view'), }, { id: 'previous', icon: 'tryton-back', label: Sao.i18n.gettext('Previous'), tooltip: Sao.i18n.gettext('Previous Record') }, { id: 'next', icon: 'tryton-forward', label: Sao.i18n.gettext('Next'), tooltip: Sao.i18n.gettext('Next Record'), }, { id: 'search', icon: 'tryton-search', label: Sao.i18n.gettext('Search'), }, null, { id: 'new_', icon: 'tryton-create', label: Sao.i18n.gettext('New'), tooltip: Sao.i18n.gettext('Create a new record'), }, { id: 'save', icon: 'tryton-save', label: Sao.i18n.gettext('Save'), tooltip: Sao.i18n.gettext('Save this record'), }, { id: 'reload', icon: 'tryton-refresh', label: Sao.i18n.gettext('Reload/Undo'), tooltip: Sao.i18n.gettext('Reload'), }, { id: 'copy', icon: 'tryton-copy', label: Sao.i18n.gettext('Duplicate'), }, { id: 'delete_', icon: 'tryton-delete', label: Sao.i18n.gettext('Delete'), }, null, { id: 'logs', icon: 'tryton-log', label: Sao.i18n.gettext('View Logs...'), }, { id: (this.screen && Sao.common.MODELHISTORY.contains(this.screen.model_name)) ? 'revision': null, icon: 'tryton-history', label: Sao.i18n.gettext('Show revisions...'), }, null, { id: 'attach', icon: 'tryton-attach', label: Sao.i18n.gettext('Attachment'), tooltip: Sao.i18n.gettext('Add an attachment to the record'), dropdown: true, }, { id: 'note', icon: 'tryton-note', label: Sao.i18n.gettext('Note'), tooltip: Sao.i18n.gettext('Add a note to the record'), }, { id: 'action', icon: 'tryton-launch', label: Sao.i18n.gettext('Action'), }, null, { id: 'relate', icon: 'tryton-link', label: Sao.i18n.gettext('Relate'), }, { id: 'print', icon: 'tryton-print', label: Sao.i18n.gettext('Print'), }, { id: 'email', icon: 'tryton-email', label: Sao.i18n.gettext('E-Mail...'), tooltip: Sao.i18n.gettext('Send an e-mail using the record'), }, null, { id: 'export', icon: 'tryton-export', label: Sao.i18n.gettext('Export'), }, { id: 'import', icon: 'tryton-import', label: Sao.i18n.gettext('Import'), }, null, { id: 'close', icon: 'tryton-close', label: Sao.i18n.gettext('Close Tab'), }, ]; }, create_tabcontent: function() { this.el = jQuery('
', { 'class': 'panel panel-default ' + this.class_, }); var toolbar = this.create_toolbar().appendTo(this.el); this.title = toolbar.find('.title'); this.main = jQuery('
', { 'class': 'panel-body row', }).appendTo(this.el); this.content = jQuery('
', { 'class': 'col-xs-12', }).appendTo(this.main); if (this.info_bar) { this.el.append(this.info_bar.el); } }, set_menu: function(menu) { var previous; this.menu_def().forEach(function(item) { var menuitem; if (item) { if (!this[item.id]) { return; } menuitem = jQuery('
  • ', { 'role': 'presentation' }); var link = jQuery('', { 'id': item.id, 'role': 'menuitem', 'href': '#', 'tabindex': -1 }).text(' ' + item.label).prepend( Sao.common.ICONFACTORY.get_icon_img(item.icon, { 'aria-hidden': 'true', })).appendTo(menuitem); this.menu_buttons[item.id] = menuitem; link.click(function(evt) { evt.preventDefault(); this[item.id](); }.bind(this)); } else if (!item && previous) { menuitem = jQuery('
  • ', { 'role': 'separator', 'class': 'divider hidden-xs', }); } else { return; } previous = menuitem; menuitem.appendTo(menu); }.bind(this)); }, create_toolbar: function() { var toolbar = jQuery('