summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/calendar
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:28 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 14:08:33 +0000
commit18e5416636b19b0953b1e6e26bfaeab1ebecce4c (patch)
tree5be75af26f1707a5b8b2184545719f3628d2980f /addons/web/static/src/js/views/calendar
parentfbf347498f1cc7b74ef373179b7bcae201715c24 (diff)
[REF] web: Adapt views/actions to new control panel
Some web actions/controllers/viewsl have been adapted to properly instantiate the newly refactored control panel and update it accordingly. We needed to adapt the starting mechanism of actions and controllers to ensure that the control panel instantiation did not delay the loading of any widget. Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/calendar')
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_controller.js54
1 files changed, 14 insertions, 40 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_controller.js b/addons/web/static/src/js/views/calendar/calendar_controller.js
index d59ea076188..dddfc122c00 100644
--- a/addons/web/static/src/js/views/calendar/calendar_controller.js
+++ b/addons/web/static/src/js/views/calendar/calendar_controller.js
@@ -37,6 +37,9 @@ var CalendarController = AbstractController.extend({
updateRecord: '_onUpdateRecord',
viewUpdated: '_onViewUpdated',
}),
+ events: _.extend({}, AbstractController.prototype.events, {
+ today_button_click: '_onTodayButtonClicked'
+ }),
/**
* @override
* @param {Widget} parent
@@ -60,34 +63,16 @@ var CalendarController = AbstractController.extend({
// The quickCreating attribute ensures that we don't do several create
this.quickCreating = false;
},
- /**
- * Overrides to unbind handler on the control panel mobile 'Today' button.
- *
- * @override
- */
- destroy: function () {
- this._super.apply(this, arguments);
- if (this.$todayButton) {
- this.$todayButton.off();
- }
- },
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
- * @override
- * @returns {string}
- */
- getTitle: function () {
- return this._title;
- },
- /**
* Render the buttons according to the CalendarView.buttons template and
* add listeners on it. Set this.$buttons with the produced jQuery element
*
- * @param {jQueryElement} [$node] a jQuery node where the rendered buttons
+ * @param {jQuery} [$node] a jQuery node where the rendered buttons
* should be inserted. $node may be undefined, in which case the Calendar
* inserts them into this.options.$buttons or into a div of its template
*/
@@ -120,25 +105,6 @@ var CalendarController = AbstractController.extend({
this.$('.o_calendar_buttons').replaceWith(this.$buttons);
}
},
- /**
- * In mobile, we want to display a special 'Today' button on the bottom
- * right corner of the control panel. This is the pager area, and as there
- * is no pager in Calendar views, we fool the system by defining a fake
- * pager (which is actually our button) such that it will be inserted in the
- * desired place.
- *
- * @todo get rid of this hack once the ControlPanel layout will be reworked
- *
- * @param {jQueryElement} $node the button should be appended to this
- * element to be displayed in the bottom right corner of the control panel
- */
- renderPager: function ($node) {
- if (config.device.isMobile) {
- this.$todayButton = $(QWeb.render('CalendarView.TodayButtonMobile'));
- this.$todayButton.on('click', this._move.bind(this, 'today'));
- $node.append(this.$todayButton);
- }
- },
//--------------------------------------------------------------------------
// Private
@@ -424,7 +390,14 @@ var CalendarController = AbstractController.extend({
event.data.data.on_save = self.quick.destroy.bind(self.quick);
self._onOpenCreate(event.data);
self.quickCreating = false;
- })
+ });
+ },
+ /**
+ * In mobile, we display a special 'Today' button on the bottom right corner
+ * of the control panel. Its click events are handled here.
+ */
+ _onTodayButtonClicked: function () {
+ this._move('today');
},
/**
* @private
@@ -446,7 +419,8 @@ var CalendarController = AbstractController.extend({
this.$buttons.find('.active').removeClass('active');
this.$buttons.find('.o_calendar_button_' + this.mode).addClass('active');
}
- this._setTitle(this.displayName + ' (' + event.data.title + ')');
+ const title = `${this.displayName} (${event.data.title})`;
+ return this.updateControlPanel({ title });
},
});