}
- */
- _renderRow: function (resId) {
- var self = this;
- var defs = [];
- var record = this._getRecord(resId);
- var $nameTD = $('', {
- class: _.contains(this.filteredResIDs, resId) ? 'o_activity_filter_' + this.activeFilter : '',
- });
- var activityRecord = new ActivityRecord(this, record, { qweb: this.qweb });
- defs.push(activityRecord.appendTo($nameTD));
-
- var $cells = _.map(this.state.activity_types, function (node) {
- var activity_type_id = node[0];
- var activity_group = self.state.grouped_activities[resId];
- activity_group = activity_group && activity_group[activity_type_id] || {count: 0, ids: [], state: false};
-
- var $td = $(QWeb.render('mail.ActivityViewRow', {
- resId: resId,
- activityGroup: activity_group,
- activityTypeId: activity_type_id,
- widget: self,
- }));
- if (activity_group.state) {
- var record = self.getKanbanActivityData(activity_group, resId);
- var widget = new KanbanActivity(self, "activity_ids", record, {});
- var def = widget.appendTo($td).then(function () {
- // replace clock by closest deadline
- var $date = $('');
- // split the year/month/day to create a date (to have a date, no tz, instead of a datetime, tz dependant)
- var splitDate = activity_group.o_closest_deadline.split('-');
- // the value representing the month, ranges from 0 for January up to 11 for December.
- var date = new Date(splitDate[0], splitDate[1]-1, splitDate[2]);
- // To remove year only if current year
- if (moment().year() === moment(date).year()) {
- $date.text(date.toLocaleDateString(moment().locale(), { day: 'numeric', month: 'short' }));
- } else {
- $date.text(moment(date).format('ll'));
- }
- $td.find('a').html($date);
- if (activity_group.count > 1) {
- $td.find('a').append($(' ', {
- class: 'badge badge-light badge-pill border-0 ' + activity_group.state,
- text: activity_group.count,
- }));
- }
- });
- defs.push(def);
- }
- return $td;
- });
- return Promise.all(defs).then(function () {
- var $tr = $(' ', {class: 'o_data_row'}).attr('data-res-id', resId)
- .append($nameTD)
- .append($cells);
- return $tr;
- });
- },
+ };
+ }
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
-
/**
* @private
* @param {MouseEvent} ev
*/
- _onEmptyCell: function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
-
- var data = $(ev.currentTarget).data();
- this.trigger_up('empty_cell_clicked', data);
- },
- /**
- * @private
- * @param {MouseEvent} ev
- */
- _onRecordSelector: function (ev) {
- ev.stopPropagation();
- this.trigger_up('schedule_activity');
- },
- /**
- * @private
- * @override
- * @param {MouseEvent} ev
- */
- _onSenMailTemplateClicked: function (ev) {
- var $target = $(ev.currentTarget);
- var templateID = $target.data('template-id');
- var activityTypeID = $target.closest('th').data('activity-type-id');
- this.trigger_up('send_mail_template', {
- activityTypeID: activityTypeID,
- templateID: templateID,
+ _onEmptyCellClicked(ev) {
+ this.trigger('empty_cell_clicked', {
+ resId: parseInt(ev.currentTarget.dataset.resId, 10),
+ activityTypeId: parseInt(ev.currentTarget.dataset.activityTypeId, 10),
});
- },
+ }
/**
- * Rearrange body part of table based on active filter.
- *
* @private
- * @param {OdooEvent} ev
+ * @param {MouseEvent} ev
*/
- _onSetProgressBarState: function (ev) {
- var self = this;
-
- this.$('th[class*="o_activity_filter_"]').attr('class', 'o_activity_type_cell');
- this.$('.o_kanban_counter_progress div').removeClass('active progress-bar-striped');
-
- var data = ev.data;
- var arrangedRecords = this.state.activity_res_ids;
- this.activeFilter = data.values.activeFilter;
- if (this.activeFilter) {
- var filteredResIds = _.map(_.keys(_.pick(this.state.grouped_activities, function (act) {
- return act[data.columnID] && act[data.columnID].state === self.activeFilter;
- })), Number);
- arrangedRecords = _.union(_.intersection(this.state.activity_res_ids, filteredResIds), this.state.activity_res_ids);
- this.filteredResIDs = filteredResIds;
- }
- var defs = _.map(arrangedRecords, this._renderRow.bind(this));
- Promise.all(defs).then(function ($rows) {
- self.$('tbody').html($rows);
+ _onSendMailTemplateClicked(ev) {
+ this.trigger('send_mail_template', {
+ activityTypeID: parseInt(ev.currentTarget.dataset.activityTypeId, 10),
+ templateID: parseInt(ev.currentTarget.dataset.templateId, 10),
});
-
- if (this.activeFilter) {
- var $header = this.$('th.o_activity_type_cell[data-activity-type-id=' + data.columnID + ']');
- $header.addClass('o_activity_filter_' + this.activeFilter);
+ }
+ /**
+ * @private
+ * @param {CustomEvent} ev
+ */
+ _onSetProgressBarState(ev) {
+ if (ev.detail.values.activeFilter) {
+ this.activeFilter.state = ev.detail.values.activeFilter;
+ this.activeFilter.activityTypeId = ev.detail.columnID;
+ this.activeFilter.resIds = Object.entries(this.props.grouped_activities)
+ .filter(([, resIds]) => ev.detail.columnID in resIds &&
+ resIds[ev.detail.columnID].state === ev.detail.values.activeFilter)
+ .map(([key]) => parseInt(key));
+ } else {
+ this.activeFilter.state = null;
+ this.activeFilter.activityTypeId = null;
+ this.activeFilter.resIds = [];
}
- },
-});
+ }
+}
+
+ActivityRenderer.components = {
+ ActivityRecordAdapter,
+ ActivityCellAdapter,
+ KanbanColumnProgressBarAdapter,
+};
+ActivityRenderer.template = 'mail.ActivityRenderer';
return ActivityRenderer;
diff --git a/addons/mail/static/src/js/views/activity/activity_view.js b/addons/mail/static/src/js/views/activity/activity_view.js
index b21a68215d1..e2e3ededfe3 100644
--- a/addons/mail/static/src/js/views/activity/activity_view.js
+++ b/addons/mail/static/src/js/views/activity/activity_view.js
@@ -1,16 +1,17 @@
odoo.define('mail.ActivityView', function (require) {
"use strict";
-var ActivityController = require('mail.ActivityController');
-var ActivityModel = require('mail.ActivityModel');
-var ActivityRenderer = require('mail.ActivityRenderer');
-var BasicView = require('web.BasicView');
-var core = require('web.core');
-var view_registry = require('web.view_registry');
+const ActivityController = require('mail.ActivityController');
+const ActivityModel = require('mail.ActivityModel');
+const ActivityRenderer = require('mail.ActivityRenderer');
+const BasicView = require('web.BasicView');
+const core = require('web.core');
+const RendererWrapper = require('web.RendererWrapper');
+const view_registry = require('web.view_registry');
-var _lt = core._lt;
+const _lt = core._lt;
-var ActivityView = BasicView.extend({
+const ActivityView = BasicView.extend({
accesskey: "a",
display_name: _lt('Activity'),
icon: 'fa-clock-o',
@@ -33,6 +34,15 @@ var ActivityView = BasicView.extend({
this.loadParams.limit = false;
this.rendererParams.templates = _.findWhere(this.arch.children, { 'tag': 'templates' });
+ this.controllerParams.title = this.arch.attrs.string;
+ },
+ /**
+ *
+ * @override
+ */
+ getRenderer(parent, state) {
+ state = Object.assign({}, state, this.rendererParams);
+ return new RendererWrapper(null, this.config.Renderer, state);
},
});
diff --git a/addons/mail/static/src/xml/activity_view.xml b/addons/mail/static/src/xml/activity_view.xml
index 2db197373b7..c40d6d73b7d 100644
--- a/addons/mail/static/src/xml/activity_view.xml
+++ b/addons/mail/static/src/xml/activity_view.xml
@@ -1,54 +1,93 @@
-
+
|
-
+ |
-
+
-
+
+
|
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+
|
-
+
- |
+ |
Schedule activity
|
-
-
-
-
- No data to display
-
-
-
-
-
+
diff --git a/addons/mail/static/tests/activity_tests.js b/addons/mail/static/tests/activity_tests.js
index 6c3c297ba5a..c32702d8c45 100644
--- a/addons/mail/static/tests/activity_tests.js
+++ b/addons/mail/static/tests/activity_tests.js
@@ -263,7 +263,8 @@ QUnit.test('activity view: batch send mail on activity', async function (assert)
QUnit.test('activity view: activity widget', async function (assert) {
assert.expect(16);
- var activity = await createView({
+
+ const params = {
View: ActivityView,
model: 'task',
data: this.data,
@@ -313,7 +314,10 @@ QUnit.test('activity view: activity widget', async function (assert) {
}
},
},
- });
+ };
+
+ owl.Component.env = testUtils.mock.getMockedOwlEnv(params);
+ var activity = await createView(params);
var today = activity.$('table tbody tr:first td:nth-child(2).today');
var dropdown = today.find('.dropdown-menu.o_activity');
diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml
index 24fab6e97b4..f2f5ee4e905 100644
--- a/addons/mail/views/mail_templates.xml
+++ b/addons/mail/views/mail_templates.xml
@@ -79,6 +79,7 @@
+
diff --git a/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js b/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js
index 3e9197d3fa2..752d2b2dc6c 100644
--- a/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js
+++ b/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js
@@ -80,28 +80,32 @@ var KanbanColumnProgressBar = Widget.extend({
// This should be executed when the progressbar is fully rendered
// and is in the DOM, this happens to be always the case with
// current use of progressbars
-
- var subgroupCounts = {};
- let allSubgroupCount = 0;
- _.each(self.colors, function (val, key) {
- var subgroupCount = self.columnState.progressBarValues.counts[key] || 0;
- if (self.activeFilter === key && subgroupCount === 0) {
- self.activeFilter = false;
- }
- subgroupCounts[key] = subgroupCount;
- allSubgroupCount += subgroupCount;
- });
- subgroupCounts.__false = self.columnState.count - allSubgroupCount;
-
- self.groupCount = self.columnState.count;
- self.subgroupCounts = subgroupCounts;
- self.prevTotalCounterValue = self.totalCounterValue;
- self.totalCounterValue = self.sumField ? (self.columnState.aggregateValues[self.sumField] || 0) : self.columnState.count;
-
+ self.computeCounters();
self._notifyState();
self._render();
});
},
+ /**
+ * Computes the count of each sub group and the total count
+ */
+ computeCounters() {
+ const subgroupCounts = {};
+ let allSubgroupCount = 0;
+ for (const key of Object.keys(this.colors)) {
+ const subgroupCount = this.columnState.progressBarValues.counts[key] || 0;
+ if (this.activeFilter === key && subgroupCount === 0) {
+ this.activeFilter = false;
+ }
+ subgroupCounts[key] = subgroupCount;
+ allSubgroupCount += subgroupCount;
+ };
+ subgroupCounts.__false = this.columnState.count - allSubgroupCount;
+
+ this.groupCount = this.columnState.count;
+ this.subgroupCounts = subgroupCounts;
+ this.prevTotalCounterValue = this.totalCounterValue;
+ this.totalCounterValue = this.sumField ? (this.columnState.aggregateValues[this.sumField] || 0) : this.columnState.count;
+ },
//--------------------------------------------------------------------------
// Private
@@ -187,6 +191,7 @@ var KanbanColumnProgressBar = Widget.extend({
$bar.css('width', '');
}
});
+ this.$('.progress-bar').css('min-width', '');
this.$('.progress-bar.o_bar_has_records').css('min-width', barMinWidth + '%');
// Display and animate the counter number
diff --git a/addons/web/static/tests/helpers/test_env.js b/addons/web/static/tests/helpers/test_env.js
index fabe52ff444..d934bd3ac84 100644
--- a/addons/web/static/tests/helpers/test_env.js
+++ b/addons/web/static/tests/helpers/test_env.js
@@ -58,6 +58,7 @@ odoo.define('web.test_env', async function (require) {
device: Object.assign({
isMobile: false,
}, env.device),
+ isDebug: env.isDebug || (() => false),
qweb: new owl.QWeb({ templates: session.owlTemplates }),
services: Object.assign({
ajax: { // for legacy subwidgets
| |