summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views
diff options
context:
space:
mode:
authorPriyanka Kakadiya <pka@odoo.com>2019-09-05 09:27:16 +0000
committerAaron Bohy <aab@odoo.com>2020-01-24 12:38:47 +0000
commit8e48ba3eb59939cb5f8bdb715afa5e520b532a00 (patch)
treef31fdcd59cc7e9bf6e7ddcbc95cc661557bef8a4 /addons/web/static/src/js/views
parent9dfb1262a57fee05502aef6b7f67988a2045b185 (diff)
[IMP] web: show start time of regular event in calendar
With this commit, the start time of single day events is displayed in the calendar view, in month mode. This only applies to non allday events. This can be disabled by setting (already existing) option 'hide_time' to true on the calendar arch. task-2058477 Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views')
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_model.js1
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_renderer.js19
2 files changed, 17 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_model.js b/addons/web/static/src/js/views/calendar/calendar_model.js
index 0fe12456e46..2f2c6339ac6 100644
--- a/addons/web/static/src/js/views/calendar/calendar_model.js
+++ b/addons/web/static/src/js/views/calendar/calendar_model.js
@@ -728,6 +728,7 @@ return AbstractModel.extend({
r.allDay = true;
r.start = date_start.format('YYYY-MM-DD');
r.end = date_stop.startOf('day').format('YYYY-MM-DD');
+ r.showTime = true;
}
return r;
diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js
index a22f39ec4ec..f563f793203 100644
--- a/addons/web/static/src/js/views/calendar/calendar_renderer.js
+++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js
@@ -422,7 +422,6 @@ return AbstractRenderer.extend({
element.find('.fc-content').after($('<div/>', {class: 'fc-bg'}));
}
- // For month view: Show background for all-day/multidate events only
if (view.name === 'month' && event.record) {
var start = event.r_start || event.start;
var end = event.r_end || event.end;
@@ -430,7 +429,12 @@ return AbstractRenderer.extend({
// note: add & remove 1 min to avoid issues with 00:00
var isSameDayEvent = start.clone().add(1, 'minute').isSame(end.clone().subtract(1, 'minute'), 'day');
if (!event.record.allday && isSameDayEvent) {
+ // For month view: do not show background for non allday, single day events
element.addClass('o_cw_nobg');
+ if (event.showTime && !self.hideTime) {
+ const displayTime = start.format(self._getDbTimeFormat());
+ element.find('.fc-content .fc-time').text(displayTime);
+ }
}
}
@@ -662,6 +666,16 @@ return AbstractRenderer.extend({
return Promise.resolve(prom);
},
/**
+ * Returns the time format from database parameters (only hours and minutes).
+ * FIXME: this looks like a weak heuristic...
+ *
+ * @private
+ * @returns {string}
+ */
+ _getDbTimeFormat: function () {
+ return _t.database.parameters.time_format.search('%H') !== -1 ? 'HH:mm' : 'hh:mm a';
+ },
+ /**
* Prepare context to display in the popover.
*
* @private
@@ -686,8 +700,7 @@ return AbstractRenderer.extend({
// Do not display timing if the event occur across multiple days. Otherwise use user's timing preferences
if (!this.hideTime && !eventData.record.allday && isSameDayEvent) {
- // Fetch user's preferences
- var dbTimeFormat = _t.database.parameters.time_format.search('%H') != -1 ? 'HH:mm': 'hh:mm a';
+ var dbTimeFormat = this._getDbTimeFormat();
context.eventTime.time = start.clone().format(dbTimeFormat) + ' - ' + end.clone().format(dbTimeFormat);