diff --git a/index.html b/index.html index 7079f17b14..df21a3e9e7 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,9 @@ this repository contains the full copyright notices and license terms. --> 'view_ids': [3], 'domain': [['parent', '=', null]] }); - $('#menu').html(form.el); + form.view_prm.done(function() { + jQuery('#menu').append(form.screen.el.detach()); + }); }); }); diff --git a/src/action.js b/src/action.js index e6daa9c805..009f5a6e36 100644 --- a/src/action.js +++ b/src/action.js @@ -127,4 +127,20 @@ }; return prm.pipe(exec_action); }; + + Sao.Action.evaluate = function(action, atype, record) { + action = jQuery.extend({}, action); + switch (atype) { + case 'print': + case 'action': + // TODO + break; + case 'relate': + // TODO + break; + default: + throw new Error('Action type ' + atype + ' is not supported'); + } + return action; + }; }()); diff --git a/src/tab.js b/src/tab.js index cf779dd318..a47eb19cd4 100644 --- a/src/tab.js +++ b/src/tab.js @@ -5,7 +5,32 @@ Sao.Tab = Sao.class_(Object, { init: function() { - } + this.buttons = {}; + }, + create_toolbar: function() { + var toolbar = jQuery('
', { + 'class': 'ui-widget-header ui-corner-all' + }); + var add_button = function(tool) { + var click_func = function() { + this[tool[4]](); + }; + var button = jQuery('').button({ + id: tool[0], + text: tool[2], + icons: { + primary: tool[1] + }, + label: tool[2] + }) + .click(click_func.bind(this)); + toolbar.append(button); + // TODO tooltip + this.buttons[tool[0]] = button; + }; + this.toolbar_def.forEach(add_button.bind(this)); + return toolbar; + } }); Sao.Tab.counter = 0; @@ -51,14 +76,93 @@ var el = jQuery('', { 'class': 'form' }); + // TODO title + var toolbar = this.create_toolbar(); + el.append(toolbar); this.el = el; - this.screen.load_next_view().done(function() { - el.html(screen.el); + this.view_prm = this.screen.load_next_view().done(function() { + el.append(screen.el); }).done(function() { screen.search_filter().done(function() { screen.display(); }); }); + }, + // TODO translate labels + toolbar_def: [ + ['new', 'ui-icon-document', 'New', 'Create a new record', 'new_'], + ['save', 'ui-icon-disk', 'Save', 'Save this record', 'save'], + ['switch', 'ui-icon-arrow-4-diag', 'Switch', 'Switch view', + 'switch'], + ['reload', 'ui-icon-refresh', 'Reload', 'Reload', 'reload'], + ['previous', 'ui-icon-arrowthick-1-w', 'Previous', + 'Previous Record', 'previous'], + ['next', 'ui-icon-arrowthick-1-e', 'Next', 'Next Record', 'next'], + ['attach', 'ui-icon-pin-s', 'Attachment', + 'Add an attachment to the record', 'attach'] + ], + create_toolbar: function() { + var toolbar = Sao.Tab.Form._super.create_toolbar.call(this); + var screen = this.screen; + var buttons = this.buttons; + var prm = screen.model.execute('view_toolbar_get', [], + screen.context); + prm.done(function(toolbars) { + // TODO translation + [ + ['action', 'ui-icon-gear', 'Action', 'Launch action'], + ['relate', 'ui-icon-arrowreturn-1-e', 'Relate', + 'Open related records'], + ['print', 'ui-icon-print', 'Print', 'Print report'] + ].forEach(function(menu_action) { + var button = jQuery('').button({ + id: menu_action[0], + text: menu_action[2], + icons: { + primary: menu_action[1], + secondary: 'ui-icon-triangle-1-s' + }, + label: menu_action[2] + }); + buttons[menu_action[0]] = button; + toolbar.append(button); + var menu = jQuery('