1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
odoo.define('website_event_meet.website_event_meet_meeting_room', function (require) {
'use strict';
const publicWidget = require('web.public.widget');
const core = require('web.core');
const Dialog = require('web.Dialog');
const _t = core._t;
publicWidget.registry.websiteEventMeetingRoom = publicWidget.Widget.extend({
selector: '.o_wevent_meeting_room_card',
xmlDependencies: ['/website_event_meet/static/src/xml/website_event_meeting_room.xml'],
events: {
'click .o_wevent_meeting_room_delete': '_onDeleteClick',
'click .o_wevent_meeting_room_duplicate': '_onDuplicateClick',
'click .o_wevent_meeting_room_is_pinned': '_onPinClick',
},
start: function () {
this._super.apply(this, arguments);
this.meetingRoomId = parseInt(this.$el.data('meeting-room-id'));
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* Delete the meeting room.
*
* @private
*/
_onDeleteClick: async function (event) {
event.preventDefault();
event.stopPropagation();
Dialog.confirm(
this,
_t("Are you sure you want to close this room ?"),
{
confirm_callback: async () => {
await this._rpc({
model: 'event.meeting.room',
method: 'write',
args: [this.meetingRoomId, {is_published: false}],
context: this.context,
});
// remove the element so we do not need to refresh the page
this.$el.remove();
}
},
);
},
/**
* Duplicate the room.
*
* @private
*/
_onDuplicateClick: function (event) {
event.preventDefault();
event.stopPropagation();
Dialog.confirm(
this,
_t("Are you sure you want to duplicate this room ?"),
{
confirm_callback: async () => {
await this._rpc({
model: 'event.meeting.room',
method: 'copy',
args: [this.meetingRoomId],
context: this.context,
});
window.location.reload();
}
},
);
},
/**
* Pin/unpin the room.
*
* @private
*/
_onPinClick: async function (event) {
event.preventDefault();
event.stopPropagation();
const pinnedButtonClass = "o_wevent_meeting_room_pinned";
const isPinned = event.currentTarget.classList.contains(pinnedButtonClass);
await this._rpc({
model: 'event.meeting.room',
method: 'write',
args: [this.meetingRoomId, {is_pinned: !isPinned}],
context: this.context,
});
// TDE FIXME: addclass ?
if (isPinned) {
event.currentTarget.classList.remove(pinnedButtonClass);
} else {
event.currentTarget.classList.add(pinnedButtonClass);
}
}
});
return publicWidget.registry.websiteEventMeetingRoom;
});
|