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/website_event_meet/static | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_event_meet/static')
6 files changed, 367 insertions, 0 deletions
diff --git a/addons/website_event_meet/static/src/js/customize_options.js b/addons/website_event_meet/static/src/js/customize_options.js new file mode 100644 index 00000000..4d8ccbd3 --- /dev/null +++ b/addons/website_event_meet/static/src/js/customize_options.js @@ -0,0 +1,69 @@ +odoo.define('website_event_meet.set_customize_options', function (require) { +"use strict"; + +let EventSpecificOptions = require('website_event.set_customize_options').EventSpecificOptions; + +EventSpecificOptions.include({ + xmlDependencies: (EventSpecificOptions.prototype.xmlDependencies || []) + .concat([ + '/website_event_meet/static/src/xml/customize_options.xml', + ]), + + events: _.extend({}, EventSpecificOptions.prototype.events, { + 'change #allow-room-creation': '_onAllowRoomCreationChange', + }), + + start: function () { + this.$allowRoomCreationInput = this.$('#allow-room-creation'); + this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + _onAllowRoomCreationChange: function () { + let checkboxValue = this.$allowRoomCreationInput.is(':checked'); + this._toggleAllowRoomCreation(checkboxValue); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + _getCheckboxFields: function () { + let fields = this._super(); + fields = _.union(fields, ['meeting_room_allow_creation']); + return fields; + }, + + _getCheckboxFieldMatch: function (checkboxField) { + if (checkboxField === 'meeting_room_allow_creation') { + return this.$allowRoomCreationInput; + } + return this._super(checkboxField); + }, + + _initCheckboxCallback: function (rpcData) { + this._super(rpcData); + if (rpcData[0]['meeting_room_allow_creation']) { + let submenuInput = this._getCheckboxFieldMatch('meeting_room_allow_creation'); + submenuInput.attr('checked', 'checked'); + } + }, + + _toggleAllowRoomCreation: async function (val) { + await this._rpc({ + model: this.modelName, + method: 'write', + args: [[this.eventId], { + meeting_room_allow_creation: val + }], + }); + + this._reloadEventPage(); + }, + +}); + +}); diff --git a/addons/website_event_meet/static/src/js/website_event_create_meeting_room_button.js b/addons/website_event_meet/static/src/js/website_event_create_meeting_room_button.js new file mode 100644 index 00000000..c64537a5 --- /dev/null +++ b/addons/website_event_meet/static/src/js/website_event_create_meeting_room_button.js @@ -0,0 +1,59 @@ +odoo.define('website_event_meet.website_event_create_room_button', function (require) { +'use strict'; + +const publicWidget = require('web.public.widget'); +const core = require('web.core'); +const QWeb = core.qweb; + +publicWidget.registry.websiteEventCreateMeetingRoom = publicWidget.Widget.extend({ + selector: '.o_wevent_create_room_button', + xmlDependencies: ['/website_event_meet/static/src/xml/website_event_meeting_room.xml'], + events: { + 'click': '_onClickCreate', + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + _onClickCreate: async function () { + if (!this.$createModal) { + const langs = await this._rpc({ + route: "/event/active_langs", + }); + + this.$createModal = $(QWeb.render( + 'event_meet_create_room_modal', + { + csrf_token: odoo.csrf_token, + eventId: this.$el.data("eventId"), + defaultLangCode: this.$el.data("defaultLangCode"), + langs: langs, + } + )); + + this.$createModal.appendTo(this.$el.parentNode); + } + + this.$createModal.modal('show'); + }, + + //-------------------------------------------------------------------------- + // Override + //-------------------------------------------------------------------------- + + /** + * Remove the create modal from the DOM, to avoid issue when editing the template + * with the website editor. + * + * @override + */ + destroy: function () { + $('.o_wevent_create_meeting_room_modal').remove(); + this._super.apply(this, arguments); + }, +}); + +return publicWidget.registry.websiteEventMeetingRoom; + +}); diff --git a/addons/website_event_meet/static/src/js/website_event_meeting_room.js b/addons/website_event_meet/static/src/js/website_event_meeting_room.js new file mode 100644 index 00000000..774a186e --- /dev/null +++ b/addons/website_event_meet/static/src/js/website_event_meeting_room.js @@ -0,0 +1,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; + +}); diff --git a/addons/website_event_meet/static/src/scss/event_meet_templates.scss b/addons/website_event_meet/static/src/scss/event_meet_templates.scss new file mode 100644 index 00000000..ddd9e030 --- /dev/null +++ b/addons/website_event_meet/static/src/scss/event_meet_templates.scss @@ -0,0 +1,59 @@ +.o_wemeet_index { + + /* + * COMMON + */ + + /* + * Meet Room PAGE + */ + + .o_wevent_online_page_container { + + // Jitsi container + #o_wemeet_jitsi_iframe { + height: 85vh; + } + } +} + +/* + * MEETING MODAL (JS / XML WIDGET) + */ + +.o_wevent_create_meeting_room_modal .modal-dialog { + top: 25%; + max-width: 500px; + height: auto; +} + +/* TDE FIXME: reorganize css cleanly */ +.o_wevent_meeting_room_is_pinned { + transition: 0.2s; + + // the icon must be filled with white when the meeting room is not pinned + color: white; + -webkit-text-stroke: 1px $o-main-text-color; + -webkit-text-fill-color: transparent; + + &.o_wevent_meeting_room_pinned { + // the icon must be filled with black when the meeting room is pinned + -webkit-text-fill-color: $o-main-text-color; + } +} + +.o_wevent_meeting_room_corner_ribbon { + width: 200px; + background: #e43; + top: 25px; + left: -50px; + text-align: center; + line-height: 50px; + letter-spacing: 1px; + color: #f0f0f0; + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); + z-index: 1; + position: absolute; + opacity: 0.6; +} diff --git a/addons/website_event_meet/static/src/xml/customize_options.xml b/addons/website_event_meet/static/src/xml/customize_options.xml new file mode 100644 index 00000000..7be9b617 --- /dev/null +++ b/addons/website_event_meet/static/src/xml/customize_options.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<templates xml:space="preserve"> + <t t-extend="website_event.customize_options"> + <t t-jquery="a[name='display-website-menu']" t-operation="after"> + <a t-if="window.document.location.pathname.endsWith('/community')" class="dropdown-item" href="#" name="allow-room-creation" role="menuitem"> + <label class="o_switch" for="allow-room-creation"> + <input id="allow-room-creation" type="checkbox"/> + <span/> + Allow Room Creation + </label> + </a> + </t> + </t> +</templates> diff --git a/addons/website_event_meet/static/src/xml/website_event_meeting_room.xml b/addons/website_event_meet/static/src/xml/website_event_meeting_room.xml new file mode 100644 index 00000000..b742d989 --- /dev/null +++ b/addons/website_event_meet/static/src/xml/website_event_meeting_room.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<templates xml:space="preserve"> + <t t-name="event_meet_create_room_modal"> + <div class="modal fade o_wevent_create_meeting_room_modal" role="dialog"> + <div class="modal-dialog"> + <div class="modal-content border-0"> + <main class="modal-body p-3"> + <form t-attf-action="/event/#{eventId}/meeting_room_create" + id="o_wevent_create_meeting_room_form" + class="text-dark" + method="POST"> + <h2>Launch a new topic</h2> + <p>Be sure you are ready to spend at least 10 minutes in the room if you want to initiate a new topic.</p> + <div class="row m-2"> + <label class="col-4 mt-2 text-left">Room Topic</label> + <input class="form-control col-8" maxlength="50" name="name" placeholder="e.g. Finance" required="1"/> + </div> + <div class="row m-2"> + <label class="col-4 mt-2 text-left">Short Summary</label> + <input class="form-control col-8" maxlength="200" name="summary" placeholder="e.g. Let's talk about Corporate Finance" required="1"/> + </div> + <div class="row m-2"> + <label class="col-4 mt-2 text-left">Target People</label> + <input class="form-control col-8" maxlength="30" name="audience" placeholder="e.g. Accountants"/> + </div> + <div class="row m-2"> + <label class="col-4 mt-2 text-left">Language</label> + <select class="o_wevent_create_meeting_room_lang form-control col-8" name="lang_code" required="1"> + <option t-foreach="langs" t-as="language" t-att-value="language[0]" t-esc="language[1]" + t-att-selected="language[0] == defaultLangCode and 'selected' or None"/> + </select> + </div> + <div class="row m-2"> + <label class="col-4 mt-2 text-left">Capacity</label> + <select class="form-control col-8" name="capacity" required="1"> + <option value="4">4</option> + <option selected="selected" value="8">8</option> + <option value="12">12</option> + <option value="16">16</option> + <option value="20">20</option> + </select> + </div> + <input name="event" t-att-value="event" type="hidden"/> + <input name="csrf_token" t-att-value="csrf_token" type="hidden"/> + </form> + </main> + <footer class="modal-footer justify-content-start"> + <button class="btn btn-primary" form="o_wevent_create_meeting_room_form" type="submit">Create</button> + <button class="btn bg-white text-primary" role="button" data-dismiss="modal">Discard</button> + </footer> + </div> + </div> + </div> + </t> +</templates> |
