diff options
| author | Aurélien (avd) <avd@odoo.com> | 2021-02-04 13:22:15 +0000 |
|---|---|---|
| committer | Aurélien (avd) <avd@odoo.com> | 2021-02-04 14:09:10 +0000 |
| commit | 0564b4a6dacf449e2a87dfdd58bb48b4e79ebfab (patch) | |
| tree | ca13cdd44b47a3f82d4acb079f98af378f327a67 /addons/google_calendar/static/src/js/google_calendar.js | |
| parent | 506755ef8ced187c0f5cd2fa600e7bb1e1fc0fe3 (diff) | |
[IMP] google_calendar: allow to archive from calendar view
Change Delete secondary button on calendar popover to Archive
for synced calendar event. This makes it easier to delete synced
calendar events.
Diffstat (limited to 'addons/google_calendar/static/src/js/google_calendar.js')
| -rw-r--r-- | addons/google_calendar/static/src/js/google_calendar.js | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/addons/google_calendar/static/src/js/google_calendar.js b/addons/google_calendar/static/src/js/google_calendar.js index c7157aa359e..ec8313e0e9e 100644 --- a/addons/google_calendar/static/src/js/google_calendar.js +++ b/addons/google_calendar/static/src/js/google_calendar.js @@ -9,6 +9,7 @@ const CalendarRenderer = require('calendar.CalendarRenderer'); const CalendarController = require('calendar.CalendarController'); const CalendarModel = require('calendar.CalendarModel'); const viewRegistry = require('web.view_registry'); +const session = require('web.session'); var _t = core._t; @@ -71,11 +72,21 @@ const GoogleCalendarModel = CalendarModel.include({ return result }); }, + + archiveRecords: function (ids, model) { + return this._rpc({ + model: model, + method: 'action_archive', + args: [ids], + context: session.user_context, + }); + }, }) const GoogleCalendarController = CalendarController.include({ custom_events: _.extend({}, CalendarController.prototype.custom_events, { syncGoogleCalendar: '_onGoogleSyncCalendar', + archiveRecord: '_onArchiveRecord', }), @@ -119,13 +130,28 @@ const GoogleCalendarController = CalendarController.include({ self.reload(); } }).then(event.data.on_always, event.data.on_always); - } + }, + + _onArchiveRecord: function (ev) { + var self = this; + Dialog.confirm(this, _t("Are you sure you want to archive this record ?"), { + confirm_callback: function () { + self.model.archiveRecords([ev.data.id], self.modelName).then(function () { + self.reload(); + }); + } + }); + }, }); const GoogleCalendarRenderer = CalendarRenderer.include({ events: _.extend({}, CalendarRenderer.prototype.events, { 'click .o_google_sync_button': '_onGoogleSyncCalendar', }), + + custom_events: _.extend({}, CalendarRenderer.prototype.custom_events, { + archive_event: '_onArchiveEvent', + }), //-------------------------------------------------------------------------- // Private @@ -173,6 +199,11 @@ const GoogleCalendarRenderer = CalendarRenderer.include({ }, }); }, + + _onArchiveEvent: function (ev) { + this._unselectEvent(); + this.trigger_up('archiveRecord', {id: parseInt(ev.data.id, 10)}); + } }); return { |
