diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/calendar/static/src/js/calendar_controller.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/calendar/static/src/js/calendar_controller.js')
| -rw-r--r-- | addons/calendar/static/src/js/calendar_controller.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/addons/calendar/static/src/js/calendar_controller.js b/addons/calendar/static/src/js/calendar_controller.js new file mode 100644 index 00000000..190125ac --- /dev/null +++ b/addons/calendar/static/src/js/calendar_controller.js @@ -0,0 +1,65 @@ +odoo.define('calendar.CalendarController', function (require) { + "use strict"; + + const Controller = require('web.CalendarController'); + const Dialog = require('web.Dialog'); + const { qweb, _t } = require('web.core'); + + const CalendarController = Controller.extend({ + + _askRecurrenceUpdatePolicy() { + return new Promise((resolve, reject) => { + new Dialog(this, { + title: _t('Edit Recurrent event'), + size: 'small', + $content: $(qweb.render('calendar.RecurrentEventUpdate')), + buttons: [{ + text: _t('Confirm'), + classes: 'btn-primary', + close: true, + click: function () { + resolve(this.$('input:checked').val()); + }, + }], + }).open(); + }); + }, + + // TODO factorize duplicated code + /** + * @override + * @private + * @param {OdooEvent} event + */ + async _onDropRecord(event) { + const _super = this._super; // reference to this._super is lost after async call + if (event.data.record.recurrency) { + const recurrenceUpdate = await this._askRecurrenceUpdatePolicy(); + event.data = _.extend({}, event.data, { + 'recurrenceUpdate': recurrenceUpdate, + }); + } + _super.apply(this, arguments); + }, + + /** + * @override + * @private + * @param {OdooEvent} event + */ + async _onUpdateRecord(event) { + const _super = this._super; // reference to this._super is lost after async call + if (event.data.record.recurrency) { + const recurrenceUpdate = await this._askRecurrenceUpdatePolicy(); + event.data = _.extend({}, event.data, { + 'recurrenceUpdate': recurrenceUpdate, + }); + } + _super.apply(this, arguments); + }, + + }); + + return CalendarController; + +}); |
