[ADD] base res_log display

bzr revid: xmo@openerp.com-20110914121305-mcey8e3t36omkr2k
This commit is contained in:
Xavier Morel 2011-09-14 14:13:05 +02:00
parent 351c9a5a51
commit 74d0339fb0
8 changed files with 53 additions and 11 deletions

View File

@ -1013,6 +1013,21 @@ label.error {
text-decoration: underline;
color: inherit;
}
.openerp .oe-view-manager-logs {
font-size: 85%;
margin: 0.5em 0;
background: #fff;
padding: 0 10px;
color: #4C4C4C;
list-style: none;
}
.openerp .oe-view-manager-logs li:before {
content: '→';
}
.openerp .oe-view-manager-logs a {
text-decoration: none;
color: inherit;
}
.openerp .view-manager-main-sidebar {
width: 180px;

View File

@ -888,6 +888,7 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg
* If that's not the case this method will simply return `false`.
*/
do_action: function(action, on_finished) {
console.log('Widget.do_action', action, on_finished);
if (this.widget_parent) {
return this.widget_parent.do_action(action, on_finished);
}

View File

@ -836,7 +836,7 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({
on_confirmed: function() {
var self = this;
this.view.execute_action(
this.view.do_execute_action(
this.node.attrs, this.view.dataset, this.view.datarecord.id, function () {
self.view.reload();
});

View File

@ -41,8 +41,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @param {void|String} [options.addable="New"] should the new-record button be displayed, and what should its label be. Use ``null`` to hide the button.
* @param {Boolean} [options.sortable=true] is it possible to sort the table by clicking on column headers
* @param {Boolean} [options.reorderable=true] is it possible to reorder list rows
*
* @borrows openerp.web.ActionExecutor#execute_action as #execute_action
*/
init: function(parent, element_id, dataset, view_id, options) {
var self = this;
@ -490,7 +488,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
return field.name === name;
});
if (!action) { return; }
this.execute_action(action, this.dataset, id, callback);
this.do_execute_action(action, this.dataset, id, callback);
},
/**
* Handles the activation of a record (clicking on it)

View File

@ -297,7 +297,11 @@ openerp.web.ViewManager = openerp.web.Widget.extend(/** @lends openerp.web.View
on_remove: function() {
},
on_edit: function() {
}
},
/**
* Called by children view after executing an action
*/
on_action_executed: function () {}
});
openerp.web.ViewManagerAction = openerp.web.ViewManager.extend(/** @lends oepnerp.web.ViewManagerAction# */{
@ -446,6 +450,23 @@ openerp.web.ViewManagerAction = openerp.web.ViewManager.extend(/** @lends oepner
$shortcut_toggle.addClass("oe-shortcut-remove");
}
});
},
/**
* Intercept do_action resolution from children views
*/
on_action_executed: function () {
new openerp.web.DataSet(this, 'res.log')
.call('get', [], this.do_display_log);
},
/**
* @param {Array<Object>} log_records
*/
do_display_log: function (log_records) {
var logs = this.$element.find('ul.oe-view-manager-logs:first').empty();
_(log_records).each(function (record) {
// TODO: fix link: bind action?
logs.append(_.sprintf('<li><a href="#">%s</a></li>', record.name));
});
}
});
@ -721,8 +742,12 @@ openerp.web.View = openerp.web.Widget.extend(/** @lends openerp.web.View# */{
* @param {Object} [record_id] the identifier of the object on which the action is to be applied
* @param {Function} on_closed callback to execute when dialog is closed or when the action does not generate any result (no new action)
*/
execute_action: function (action_data, dataset, record_id, on_closed) {
do_execute_action: function (action_data, dataset, record_id, on_closed) {
var self = this;
var result_handler = function () {
if (on_closed) { on_closed.apply(null, arguments); }
self.widget_parent.on_action_executed.apply(null, arguments);
};
var handler = function (r) {
var action = r.result;
if (action && action.constructor == Object) {
@ -733,9 +758,9 @@ openerp.web.View = openerp.web.Widget.extend(/** @lends openerp.web.View# */{
active_model: dataset.model
});
action.context = new openerp.web.CompoundContext(dataset.get_context(), action.context);
self.do_action(action, on_closed);
} else if (on_closed) {
on_closed(action);
self.do_action(action, result_handler);
} else {
result_handler();
}
};

View File

@ -461,6 +461,9 @@
</button>
</h2>
</t>
<t t-jquery=".oe-view-manager-header" t-operation="after">
<ul class="oe-view-manager-logs"></ul>
</t>
</t>
<t t-name="Sidebar">

View File

@ -333,7 +333,7 @@ openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({
});
})
.delegate('li:not(.oe-done)', 'click', function () {
self.widget_parent.widget_parent.widget_parent.execute_action({
self.widget_parent.widget_parent.widget_parent.do_execute_action({
type: 'object',
name: 'action_launch'
}, self.dataset,

View File

@ -224,7 +224,7 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
},
on_execute_button_click: function (dataset, button_attrs, record_id) {
var self = this;
this.execute_action(
this.do_execute_action(
button_attrs, dataset,
record_id, function () {
var count = 1;