diff options
| author | Xavier Morel <xmo@openerp.com> | 2011-07-14 13:58:43 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2011-07-14 13:58:43 +0200 |
| commit | 4e47ceb281800da5305588e02ecbce7107d7ea66 (patch) | |
| tree | 2c70df971e6db0eb0ddd799bd87a60af7fc9c4b2 /addons/base_dashboard/static/src | |
| parent | e35bb246d352965474076c23efb0dc5460b9e474 (diff) | |
[IMP] category-based todos display in config widget
Also use todos-provided progress method to build a more precise progressbar
bzr revid: xmo@openerp.com-20110714115843-fhqbwcxg3hlljsmv
Diffstat (limited to 'addons/base_dashboard/static/src')
| -rw-r--r-- | addons/base_dashboard/static/src/js/dashboard.js | 34 | ||||
| -rw-r--r-- | addons/base_dashboard/static/src/xml/base_dashboard.xml | 28 |
2 files changed, 36 insertions, 26 deletions
diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 3a1ef94f6d7..0c58bb2878d 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -284,32 +284,38 @@ openerp.base_dashboard.ConfigOverview = openerp.base.View.extend({ this._super(parent_or_session, element_id); this.dataset = new openerp.base.DataSetSearch( this.session, 'ir.actions.todo'); + this.dataset.domain = ['|', ['type', '=', 'recurring'], + '&', ['type', '!=', 'special'], + ['state', '=', 'open']]; }, start: function () { - this.dataset.read_slice(['state', 'action_id'], undefined, undefined, - this.on_records_loaded); + $.when(this.dataset.read_slice(['state', 'action_id', 'category_id']), + this.dataset.call('progress')).then(this.on_records_loaded); }, - on_records_loaded: function (records) { - var self = this, - done_records = _(records).filter(function (record) { - return record.state === 'done';}), - done_ratio = done_records.length / records.length; - this.$element.html(QWeb.render('ConfigOverview', { - completion: done_ratio * 100, - todos: _(records).map(function (record) { + on_records_loaded: function (read_response, progress_response) { + var records = read_response[0].records, + progress = progress_response[0]; + + var grouped_todos = _(records).chain() + .map(function (record) { return { action: record.action_id[0], name: record.action_id[1], - state: record.state, - done: record.state === 'done', - skipped: record.state === 'skip', - to_do: (record.state !== 'done' && record.state !== 'skip') + done: record.state !== 'open', + to_do: record.state === 'open', + category: record['category_id'][1] || "Uncategorized" } }) + .groupBy(function (record) {return record.category}) + .value(); + this.$element.html(QWeb.render('ConfigOverview', { + completion: 100 * progress.done / progress.total, + groups: grouped_todos })); var $progress = this.$element.find('div.oe-config-progress'); $progress.progressbar({value: $progress.data('completion')}); + var self = this; // allow for executing to-do and skipped action this.$element.find('div.oe-dashboard-config-overview ul') .delegate('li.ui-state-error', 'click', function () { diff --git a/addons/base_dashboard/static/src/xml/base_dashboard.xml b/addons/base_dashboard/static/src/xml/base_dashboard.xml index bca78998532..8d751f5ac81 100644 --- a/addons/base_dashboard/static/src/xml/base_dashboard.xml +++ b/addons/base_dashboard/static/src/xml/base_dashboard.xml @@ -66,19 +66,23 @@ </t> <div t-name="ConfigOverview" class="oe-dashboard-config-overview"> <div class="oe-config-progress" t-att-data-completion="completion"/> - <ul> + <dl> + <t t-foreach="groups" t-as="category"> + <dt><t t-esc="category"/></dt> + <dd><ul> + <li t-foreach="category_value" t-as="todo" + t-att-class="todo.to_do ? 'ui-state-error ui-priority-primary' : ''" + t-att-data-action="todo.action"> + <span t-if="todo.done" class="ui-icon ui-icon-circle-check"/> + <span t-if="todo.to_do" class="ui-icon ui-icon-circle-close"/> + <span t-att-class="todo.to_do ? 'ui-state-error-text' : ''"> + <t t-esc="todo.name"/> + </span> + </li> + </ul></dd> + </t> - <li t-foreach="todos" t-as="todo" - t-att-class="!todo.done ? 'ui-state-error ' + (todo.skipped ? 'ui-priority-secondary' : 'ui-priority-primary') : ''" - t-att-data-action="todo.action"> - <span t-if="todo.done" class="ui-icon ui-icon-circle-check"/> - <span t-if="todo.skipped" class="ui-icon ui-icon-circle-minus"/> - <span t-if="todo.to_do" class="ui-icon ui-icon-circle-close"/> - <span t-att-class="!todo.done ? 'ui-state-error-text' : ''"> - <t t-esc="todo.name"/> - </span> - </li> - </ul> + </dl> </div> <div t-name="ApplicationTiles" class="oe-dashboard-home-tiles"> <table width="100%"> |
