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 | |
| 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')
3 files changed, 66 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 { diff --git a/addons/google_calendar/static/src/js/google_calendar_popover.js b/addons/google_calendar/static/src/js/google_calendar_popover.js new file mode 100644 index 00000000000..89296d62113 --- /dev/null +++ b/addons/google_calendar/static/src/js/google_calendar_popover.js @@ -0,0 +1,26 @@ +odoo.define('google_calendar.GoogleCalendarPopover', function(require) { + "use strict"; + + const CalendarPopover = require('web.CalendarPopover'); + + const GoogleCalendarPopover = CalendarPopover.include({ + events: _.extend({}, CalendarPopover.prototype.events, { + 'click .o_cw_popover_archive_g': '_onClickPopoverGArchive', + }), + + isGEventSyncedAndArchivable() { + return this.event.extendedProps.record.google_id; + }, + + isEventDeletable() { + return !this.isGEventSyncedAndArchivable() && this._super(); + }, + + _onClickPopoverGArchive: function (ev) { + ev.preventDefault(); + this.trigger_up('archive_event', {id: this.event.id}); + }, + }) + + return GoogleCalendarPopover; +}); diff --git a/addons/google_calendar/static/src/xml/google_calendar_popover.xml b/addons/google_calendar/static/src/xml/google_calendar_popover.xml new file mode 100644 index 00000000000..641b1fcc60a --- /dev/null +++ b/addons/google_calendar/static/src/xml/google_calendar_popover.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates> + <t t-extend="Calendar.attendee.status.popover"> + <t t-jquery=".o_cw_popover_edit" t-operation="after"> + <a t-if="widget.isGEventSyncedAndArchivable() and widget.isEventDetailsVisible()" href="#" class="btn btn-secondary o_cw_popover_archive_g">Archive</a> + </t> + </t> +</templates> |
