[ADD] "Reset" feature in dashboards

bzr revid: fme@openerp.com-20110606105436-wpo7xyiiy2o6jyzm
This commit is contained in:
Fabien Meghazi 2011-06-06 12:54:36 +02:00
parent 19382763fb
commit 8011b649ee
3 changed files with 17 additions and 3 deletions

View File

@ -489,11 +489,14 @@ class View(openerpweb.Controller):
return {'result': True}
@openerpweb.jsonrequest
def undo_custom(self, request, view_id):
def undo_custom(self, request, view_id, reset=False):
CustomView = request.session.model('ir.ui.view.custom')
vcustom = CustomView.search([('user_id', '=', request.session._uid), ('ref_id' ,'=', view_id)])
if vcustom:
CustomView.unlink([vcustom[0]])
if reset:
CustomView.unlink(vcustom)
else:
CustomView.unlink([vcustom[0]])
return {'result': True}
return {'result': False}

View File

@ -18,6 +18,7 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
// Events
this.$element.find('.oe-dashboard-link-undo').click(this.on_undo);
this.$element.find('.oe-dashboard-link-reset').click(this.on_reset);
this.$element.find('.oe-dashboard-link-add_widget').click(this.on_add_widget);
this.$element.find('.oe-dashboard-link-change_layout').click(this.on_change_layout);
this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(this.on_fold_action);
@ -42,6 +43,12 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
view_id: this.view.fields_view.view_id
}, this.do_reload);
},
on_reset: function() {
this.rpc('/base/view/undo_custom', {
view_id: this.view.fields_view.view_id,
reset: true
}, this.do_reload);
},
on_add_widget: function() {
},
on_change_layout: function() {
@ -112,7 +119,7 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
view_id: this.view.fields_view.view_id,
arch: arch
}, function() {
self.$element.find('.oe-dashboard-link-undo').show();
self.$element.find('.oe-dashboard-link-undo, .oe-dashboard-link-reset').show();
});
},
on_load_action: function(result) {

View File

@ -1,6 +1,10 @@
<template>
<t t-name="DashBoard">
<div class="oe-dashboard-links">
<button type="button" class="button oe-dashboard-link-reset" t-att-style="view.fields_view.custom_view_id ? null : 'display: none'">
<img src="/base/static/src/img/icons/STOCK_GOTO_FIRST.png" width="16" height="16"/>
<span>Reset</span>
</button>
<button type="button" class="button oe-dashboard-link-undo" t-att-style="view.fields_view.custom_view_id ? null : 'display: none'">
<img src="/base/static/src/img/icons/gtk-undo.png" width="16" height="16"/>
<span>Undo</span>