summaryrefslogtreecommitdiff
path: root/addons/google_calendar/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/google_calendar/static/src')
-rw-r--r--addons/google_calendar/static/src/js/google_calendar.js33
-rw-r--r--addons/google_calendar/static/src/js/google_calendar_popover.js26
-rw-r--r--addons/google_calendar/static/src/xml/google_calendar_popover.xml8
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>