diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-08-19 09:55:26 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-21 17:30:13 +0000 |
| commit | b0845c0f2b48d6c7029a34ae50fc95876630e7ed (patch) | |
| tree | cab4c50786ae087fdf6dec70b0c12ddc0c39c62d /addons/website_event/static/src | |
| parent | d697966585e9686f4bfce8049c1d0a21abe8a279 (diff) | |
[REM] website_event_online: merge into website_event
PURPOSE
Clean organization and models linked to Event Online feature introduced in
semi stable saas-13.3 at odoo/odoo@981f95bbf46658eda9f2d33751b9310cc67d86aa and odoo/enterprise@14722028ae0773c3710ea48ce48ff44703e83b5a
Also clean website event menu not being available in website event but only
in website event track, which implies some extra-code to manage it.
In short: merge website_event_online in website_event, website_event_track
_(online/session) in website_event_track.
RATIONALE
_online modules have been added to extend content of website_event and
website_event_track without having any impact on those module. First step
of cleaning is to move this content directly in base module.
track_session module is mainly a rewrite of track module. Second step of
cleaning is to move its content directly in website_event_track.
SPECIFICATIONS
Move remaining content of website event online to website event.
Update dependencies accordingly.
LINKS
Task ID-2319779
COM odoo/odoo#56067
ENT odoo/enterprise#12520
UPG odoo/upgrade#1654
Diffstat (limited to 'addons/website_event/static/src')
3 files changed, 264 insertions, 0 deletions
diff --git a/addons/website_event/static/src/js/display_timer_widget.js b/addons/website_event/static/src/js/display_timer_widget.js new file mode 100644 index 00000000000..5f61273661f --- /dev/null +++ b/addons/website_event/static/src/js/display_timer_widget.js @@ -0,0 +1,111 @@ +odoo.define('website_event.display_timer_widget', function (require) { +'use strict'; + +var core = require('web.core'); +var _t = core._t; +var publicWidget = require('web.public.widget'); + +publicWidget.registry.displayTimerWidget = publicWidget.Widget.extend({ + selector: '.o_display_timer', + + /** + * This widget allows to display a dom element at the end of a certain time laps. + * There are 2 timers available: + * - The main-timer: display the DOM element (using the displayClass) at the end of this timer. + * - The pre-timer: additional timer to display the main-timer. This pre-timer can be invisible or visible, + * depending of the startCountdownDisplay option. Once the pre-timer is over, + the main-timer is displayed. + * @override + */ + start: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + self.options = self.$target.data(); + self.preCountdownDisplay = self.options["preCountdownDisplay"]; + self.preCountdownTime = self.options["preCountdownTime"]; + self.preCountdownText = self.options["preCountdownText"]; + + self.mainCountdownTime = self.options["mainCountdownTime"]; + self.mainCountdownText = self.options["mainCountdownText"]; + self.mainCountdownDisplay = self.options["mainCountdownDisplay"]; + + self.displayClass = self.options["displayClass"]; + + if (self.preCountdownDisplay) { + $(self.$el).parent().removeClass('d-none'); + } + + self._checkTimer(); + self.interval = setInterval(function () { self._checkTimer(); }, 1000); + }); + }, + + /** + * This method removes 1 second to the current timer (pre-timer or main-timer) + * and call the method to update the DOM, unless main-timer is over. In that last case, + * the DOM element to show is displayed. + * + * @private + */ + _checkTimer: function () { + var now = new Date(); + + var remainingPreSeconds = this.preCountdownTime - (now.getTime()/1000); + if (remainingPreSeconds <= 1) { + this.$('.o_countdown_text').text(this.mainCountdownText); + if (this.mainCountdownDisplay) { + $(this.$el).parent().removeClass('d-none'); + } + var remainingMainSeconds = this.mainCountdownTime - (now.getTime()/1000); + if (remainingMainSeconds <= 1) { + clearInterval(this.interval); + $(this.displayClass).removeClass('d-none'); + $(this.$el).parent().addClass('d-none'); + } else { + this._updateCountdown(remainingMainSeconds); + } + } else { + this._updateCountdown(remainingPreSeconds); + } + }, + + /** + * This method update the DOM to display the remaining time. + * from seconds, the method extract the number of days, hours, minutes and seconds and + * override the different DOM elements values. + * + * @private + */ + _updateCountdown: function (remainingTime) { + var remainingSeconds = remainingTime; + var days = Math.floor(remainingSeconds / 86400); + + remainingSeconds = remainingSeconds % 86400; + var hours = Math.floor(remainingSeconds / 3600); + + remainingSeconds = remainingSeconds % 3600; + var minutes = Math.floor(remainingSeconds / 60); + + remainingSeconds = Math.floor(remainingSeconds % 60); + + this.$("span.o_timer_days").text(days); + this.$("span.o_timer_hours").text(this._zeroPad(hours, 2)); + this.$("span.o_timer_minutes").text(this._zeroPad(minutes, 2)); + this.$("span.o_timer_seconds").text(this._zeroPad(remainingSeconds, 2)); + }, + + /** + * Small tool to add leading zéros to the given number, in function of the needed number of leading zéros. + * + * @private + */ + _zeroPad: function (num, places) { + var zero = places - num.toString().length + 1; + return new Array(+(zero > 0 && zero)).join("0") + num; + }, + +}); + +return publicWidget.registry.countdownWidget; + +}); diff --git a/addons/website_event/static/src/js/register_toaster_widget.js b/addons/website_event/static/src/js/register_toaster_widget.js new file mode 100644 index 00000000000..891f61554c7 --- /dev/null +++ b/addons/website_event/static/src/js/register_toaster_widget.js @@ -0,0 +1,31 @@ +odoo.define('website_event.register_toaster_widget', function (require) { +'use strict'; + +let core = require('web.core'); +let _t = core._t; +let publicWidget = require('web.public.widget'); + +publicWidget.registry.RegisterToasterWidget = publicWidget.Widget.extend({ + selector: '.o_wevent_register_toaster', + + /** + * This widget allows to display a toast message on the page. + * + * @override + */ + start: function () { + const message = this.$el.data('message'); + if (message && message.length) { + this.displayNotification({ + title: _t("Register"), + message: message, + type: 'info' + }); + } + return this._super.apply(this, arguments); + }, +}); + +return publicWidget.registry.RegisterToasterWidget; + +}); diff --git a/addons/website_event/static/src/scss/website_event_templates.scss b/addons/website_event/static/src/scss/website_event_templates.scss new file mode 100644 index 00000000000..390536d6f97 --- /dev/null +++ b/addons/website_event/static/src/scss/website_event_templates.scss @@ -0,0 +1,122 @@ +// Color tags according to assigned background color. + +.o_wevent_index, .o_wevent_event { + + // Simple colored tags according to assigned background color + @for $size from 1 through length($o-colors) { + .o_tag_color_#{$size - 1} { + @if $size == 1 { + & { + background-color: white; + color: nth($o-colors, $size); + box-shadow: inset 0 0 0 2px nth($o-colors, $size); + } + &::after { + background-color: nth($o-colors, $size); + } + } @else { + &, &::after { + background-color: nth($o-colors, $size); + color: $white; + } + } + } + } + + // Complex colored tags according to assigned background color with hover effect + @for $size from 1 through length($o-colors) { + .o_tag_color_hovered_#{$size - 1} { + $background-color: white; + // no color selected + @if $size == 1 { + & { + color: black; + background-color: $background-color; + box-shadow: inset 0 0 0 1px nth($o-colors, $size); + } + } @else { + $background-color: nth($o-colors, $size); + & { + color: white; + background-color: $background-color; + } + } + @at-root a#{&} { + &:hover { + background-color: darken($background-color, 20%); + } + } + } + } + + /* + * COMMON TO ALL ONLINE-* PAGES + */ + + .o_wevent_online { + // unpublished badge: put opacity to distinguish form other badges + .o_wevent_online_badge_unpublished{ + opacity: 0.4; + } + + &.o_wevent_online_bg { + @if (color('body') == $o-portal-default-body-bg) { + @extend .bg-100; + } + } + + .o_wevent_online_page_container { + // Widescreen mode + @include media-breakpoint-up(md) { + &:not(.container) { + padding-left: 0.5rem; + padding-right: 0.5rem; + } + } + + // Main panel + .o_wevent_online_page_main { + border: 1px solid $border-color; + + @include media-breakpoint-up(md) { + border-top-width: 0; + } + + .o_wevent_online_page_avatar { + min-width: 64px; + + img { + max-width: 96px; + } + } + } + + // Left panel + .o_wevent_online_page_aside { + + // Left panel: content display + .o_wevent_online_page_aside_content { + border: 1px solid $border-color; + + @include media-breakpoint-up(md) { + border-top-width: 0; + } + + li:not(.nav-item) { + border-bottom: 1px solid $border-color; + &:first-child { + border-top: 1px solid $border-color; + } + &:last-child { + border-bottom: 0px; + } + } + + .o_wevent_online_page_aside_collapse:not(.collapsed) { + transform: rotate(180deg); + } + } + } + } + } +} |
