[merge]
bzr revid: nicolas.vanhoren@openerp.com-20110825171612-ieb6ggnm5wugb50y
This commit is contained in:
commit
de1fc9e3c5
|
@ -382,10 +382,19 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
|||
* re-renders the content of the list view
|
||||
*/
|
||||
reload_content: function () {
|
||||
var self = this;
|
||||
this.records.reset();
|
||||
this.$element.find('.oe-listview-content').append(
|
||||
this.groups.render(
|
||||
$.proxy(this, 'compute_aggregates')));
|
||||
this.groups.render(function () {
|
||||
if (self.dataset.index == null) {
|
||||
var has_one = false;
|
||||
self.records.each(function () { has_one = true; });
|
||||
if (has_one) {
|
||||
self.dataset.index = 0;
|
||||
}
|
||||
}
|
||||
self.compute_aggregates();
|
||||
}));
|
||||
},
|
||||
/**
|
||||
* Event handler for a search, asks for the computation/folding of domains
|
||||
|
@ -398,8 +407,8 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
|||
*/
|
||||
do_search: function (domains, contexts, groupbys) {
|
||||
return this.rpc('/base/session/eval_domain_and_context', {
|
||||
domains: domains,
|
||||
contexts: contexts,
|
||||
domains: [this.dataset.get_domain()].concat(domains),
|
||||
contexts: [this.dataset.get_context()].concat(contexts),
|
||||
group_by_seq: groupbys
|
||||
}, $.proxy(this, 'do_actual_search'));
|
||||
},
|
||||
|
@ -1039,25 +1048,25 @@ openerp.base.ListView.Groups = openerp.base.Class.extend( /** @lends openerp.bas
|
|||
var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name');
|
||||
var options = { offset: page * limit, limit: limit };
|
||||
dataset.read_slice(fields, options , function (records) {
|
||||
if (!self.datagroup.openable) {
|
||||
view.configure_pager(dataset);
|
||||
} else {
|
||||
var pages = Math.ceil(dataset.ids.length / limit);
|
||||
self.$row
|
||||
.find('.oe-pager-state')
|
||||
.text(_.sprintf('%d/%d', page + 1, pages))
|
||||
.end()
|
||||
.find('button[data-pager-action=previous]')
|
||||
.attr('disabled', page === 0)
|
||||
.end()
|
||||
.find('button[data-pager-action=next]')
|
||||
.attr('disabled', page === pages - 1);
|
||||
}
|
||||
if (!self.datagroup.openable) {
|
||||
view.configure_pager(dataset);
|
||||
} else {
|
||||
var pages = Math.ceil(dataset.ids.length / limit);
|
||||
self.$row
|
||||
.find('.oe-pager-state')
|
||||
.text(_.sprintf('%d/%d', page + 1, pages))
|
||||
.end()
|
||||
.find('button[data-pager-action=previous]')
|
||||
.attr('disabled', page === 0)
|
||||
.end()
|
||||
.find('button[data-pager-action=next]')
|
||||
.attr('disabled', page === pages - 1);
|
||||
}
|
||||
|
||||
self.records.add(records, {silent: true});
|
||||
list.render();
|
||||
d.resolve(list);
|
||||
});
|
||||
self.records.add(records, {silent: true});
|
||||
list.render();
|
||||
d.resolve(list);
|
||||
});
|
||||
return d.promise();
|
||||
},
|
||||
setup_resequence_rows: function (list, dataset) {
|
||||
|
|
|
@ -1,11 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import openerpweb
|
||||
|
||||
WIDGET_CONTENT_PATTERN = """<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>[[Widget %(id)d]]</title></head>
|
||||
<body>
|
||||
%(content)s
|
||||
<script type="text/javascript">
|
||||
var load = window.onload;
|
||||
window.onload = function () {
|
||||
if (load) {
|
||||
load();
|
||||
}
|
||||
window.frameElement.style.height = document.height + 'px';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
class Widgets(openerpweb.openerpweb.Controller):
|
||||
_cp_path = '/base_dashboard/widgets'
|
||||
|
||||
@openerpweb.httprequest
|
||||
def content(self, request, widget_id):
|
||||
return request.session.model('res.widget').read(
|
||||
return WIDGET_CONTENT_PATTERN % request.session.model('res.widget').read(
|
||||
[widget_id], ['content'], request.session.eval_context(request.context)
|
||||
)[0]['content']
|
||||
)[0]
|
||||
|
|
|
@ -321,7 +321,7 @@ openerp.base_dashboard.ConfigOverview = openerp.base.View.extend({
|
|||
$progress.progressbar({value: $progress.data('completion')});
|
||||
|
||||
var self = this;
|
||||
this.$element.find('div.oe-dashboard-config-overview ul')
|
||||
this.$element.find('dl')
|
||||
.delegate('input', 'click', function (e) {
|
||||
// switch todo status
|
||||
e.stopImmediatePropagation();
|
||||
|
@ -372,39 +372,36 @@ openerp.base_dashboard.ApplicationTiles = openerp.base.View.extend({
|
|||
}
|
||||
});
|
||||
openerp.base.client_actions.add(
|
||||
'board.home.widgets', 'openerp.base_dashboard.Widgets');
|
||||
openerp.base_dashboard.Widgets = openerp.base.View.extend({
|
||||
template: 'HomeWidgets',
|
||||
start: function () {
|
||||
return new openerp.base.DataSetSearch(
|
||||
this, 'res.widget.user', null,
|
||||
['|', ['user_id', '=', false],
|
||||
['user_id', '=', parseInt(this.session.uid, 10)]])
|
||||
.read_slice(['widget_id', 'user_id'], {}, this.on_widgets_list_loaded);
|
||||
'board.home.widgets', 'openerp.base_dashboard.Widget');
|
||||
openerp.base_dashboard.Widget = openerp.base.View.extend(/** @lends openerp.base_dashboard.Widgets# */{
|
||||
template: 'HomeWidget',
|
||||
/**
|
||||
* Initializes a "HomeWidget" client widget: handles the display of a given
|
||||
* res.widget objects in an OpenERP view (mainly a dashboard).
|
||||
*
|
||||
* @constructs
|
||||
* @extends openerp.base.View
|
||||
* @param {Object} parent
|
||||
* @param {Object} options
|
||||
* @param {Number} options.widget_id
|
||||
*/
|
||||
init: function (parent, options) {
|
||||
this._super(parent);
|
||||
this.widget_id = options.widget_id;
|
||||
},
|
||||
on_widgets_list_loaded: function (user_widgets) {
|
||||
var self = this;
|
||||
var widget_user = {};
|
||||
_(user_widgets).each(function (widget) {
|
||||
widget['widget_id'] = widget['widget_id'][0];
|
||||
widget_user[widget['widget_id']] = {
|
||||
removable: widget['user_id'] !== false,
|
||||
user_widget_id: widget['id']
|
||||
};
|
||||
});
|
||||
new openerp.base.DataSetSearch(this, 'res.widget')
|
||||
.read_ids(_(user_widgets).pluck('widget_id'), ['title'], function (widgets) {
|
||||
_(widgets).each(function (widget) {
|
||||
_.extend(widget, widget_user[widget['id']]);
|
||||
});
|
||||
var url = _.sprintf(
|
||||
'/base_dashboard/widgets/content?session_id=%s&widget_id=',
|
||||
self.session.session_id);
|
||||
self.$element.html(QWeb.render('HomeWidgets', {
|
||||
widgets: widgets,
|
||||
url: url
|
||||
}));
|
||||
});
|
||||
start: function () {
|
||||
return new openerp.base.DataSet(this, 'res.widget').read_ids(
|
||||
[this.widget_id], ['title'], this.on_widget_loaded);
|
||||
},
|
||||
on_widget_loaded: function (widgets) {
|
||||
var widget = widgets[0];
|
||||
var url = _.sprintf(
|
||||
'/base_dashboard/widgets/content?session_id=%s&widget_id=%d',
|
||||
this.session.session_id, widget.id);
|
||||
this.$element.html(QWeb.render('HomeWidget.content', {
|
||||
widget: widget,
|
||||
url: url
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -107,10 +107,9 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div t-name="HomeWidgets" class="oe-dashboard-home-widgets"/>
|
||||
<div t-name="HomeWidgets.content" class="oe-dashboard-home-widgets-widget"
|
||||
t-foreach="widgets" t-as="widget">
|
||||
<div t-name="HomeWidget" class="oe-dashboard-home-widget"/>
|
||||
<t t-name="HomeWidget.content">
|
||||
<h3><t t-esc="widget.title"/></h3>
|
||||
<iframe width="100%" frameborder="0" t-att-src="url + widget.id"/>
|
||||
</div>
|
||||
<iframe width="100%" frameborder="0" t-att-src="url"/>
|
||||
</t>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue