[MERGE] trunk.

bzr revid: vda@tinyerp.com-20110602050810-ekg55hod3zryzbwi
This commit is contained in:
vda (OpenERP)
2011-06-02 10:38:10 +05:30
5 changed files with 73 additions and 17 deletions
+21
View File
@@ -456,6 +456,8 @@ class DataGroup(openerpweb.Controller):
dict(request.context, group_by=group_by_fields))
class View(openerpweb.Controller):
_cp_path = "/base/view"
def fields_view_get(self, request, model, view_id, view_type,
transform=True, toolbar=False, submenu=False):
Model = request.session.model(model)
@@ -471,6 +473,25 @@ class View(openerpweb.Controller):
fvg['arch'] = Xml2Json.convert_element(xml)
return fvg
@openerpweb.jsonrequest
def add_custom(self, request, view_id, arch):
CustomView = request.session.model('ir.ui.view.custom')
CustomView.create({
'user_id': request.session._uid,
'ref_id': view_id,
'arch': arch
})
return {'result': True}
@openerpweb.jsonrequest
def undo_custom(self, request, view_id):
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]])
return {'result': True}
return {'result': False}
def normalize_attrs(self, elem, context):
""" Normalize @attrs, @invisible, @required, @readonly and @states, so
the client only has to deal with @attrs.
+1 -1
View File
@@ -371,7 +371,7 @@ openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.b
} else {
error_callback(response.error);
}
} else {
} else if (success_callback) {
success_callback(response["result"], textStatus, jqXHR);
}
},
@@ -18,6 +18,15 @@
.openerp .oe-dashboard-action .oe-dashboard-action-header:hover {
cursor: move;
}
.openerp .oe-dashboard-action .ui-icon {
cursor: pointer;
}
.openerp .oe-dashboard-action .ui-icon:hover {
background-color: #ccc;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.openerp .oe-dashboard-action .oe-dashboard-action-header .ui-icon {
float: right;
@@ -10,22 +10,18 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
start: function() {
var self = this;
this._super.apply(this, arguments);
this.$element.find(".oe-dashboard-column").sortable({
connectWith: ".oe-dashboard-column",
scroll: false
}).disableSelection().bind('sortstop', self.do_save_dashboard);
// Events
this.$element.find('.oe-dashboard-link-undo').click(this.on_undo);
this.$element.find('.oe-dashboard-link-add_widget').click(this.on_add_widget);
this.$element.find('.oe-dashboard-link-edit_layout').click(this.on_edit_layout);
this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(function() {
$(this).toggleClass('ui-icon-minusthick').toggleClass('ui-icon-plusthick');
$(this).parents('.oe-dashboard-action:first .oe-dashboard-action-content').toggle();
});
$('.oe-dashboard-column .ui-icon-closethick').click(function() {
$(this).parents('.oe-dashboard-action:first').remove();
self.do_save_dashboard();
});
this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(this.on_fold_action);
this.$element.find('.oe-dashboard-column .ui-icon-closethick').click(this.on_close_action);
this.actions_attrs = {};
// Init actions
@@ -41,13 +37,28 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
});
});
},
on_undo: function() {
this.rpc('/base/view/undo_custom', {
view_id: this.view.fields_view.view_id
}, this.do_reload);
},
on_add_widget: function() {
},
on_edit_layout: function() {
},
on_fold_action: function(e) {
var $e = $(e.currentTarget);
$e.toggleClass('ui-icon-minusthick ui-icon-plusthick');
$e.parents('.oe-dashboard-action:first').find('.oe-dashboard-action-content').toggle();
},
on_close_action: function(e) {
$(e.currentTarget).parents('.oe-dashboard-action:first').remove();
this.do_save_dashboard();
},
do_save_dashboard: function() {
var self = this;
var board = {
form_title : this.view.fields_view.arch.attrs.string,
style : this.$element.find('.oe-dashboard').attr('data-layout'),
columns : []
};
@@ -59,7 +70,13 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
});
board.columns.push(actions);
});
var xml = QWeb.render('DashBoard.xml', board);
var arch = QWeb.render('DashBoard.xml', board);
this.rpc('/base/view/add_custom', {
view_id: this.view.fields_view.view_id,
arch: arch
}, function() {
self.$element.find('.oe-dashboard-link-undo').show();
});
},
on_load_action: function(result) {
var action = result.result;
@@ -76,6 +93,10 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
},
render: function() {
return QWeb.render(this.template, this);
},
do_reload: function() {
this.view.view_manager.stop();
this.view.view_manager.start();
}
});
openerp.base.form.DashBoardLegacy = openerp.base.form.DashBoard.extend({
@@ -1,6 +1,9 @@
<template>
<t t-name="DashBoard">
<div class="oe-dashboard-links">
<button type="button" class="button oe-dashboard-link-undo" t-att-style="view.fields_view.custom_view_id ? null : 'display: none'">
Undo
</button>
<button type="button" class="button oe-dashboard-link-add_widget">
Add Widget
</button>
@@ -40,10 +43,12 @@
</div>
</t>
<t t-name="DashBoard.xml">
<board t-att-style="style">
<column t-foreach="columns" t-as="column">
<action t-foreach="column" t-as="action" t-att="action"/>
</column>
</board>
<form t-att-string="form_title">
<board t-att-style="style">
<column t-foreach="columns" t-as="column">
<action t-foreach="column" t-as="action" t-att="action"/>
</column>
</board>
</form>
</t>
</template>