diff --git a/base_tier_validation/models/tier_definition.py b/base_tier_validation/models/tier_definition.py index dc0edbd..58ea86c 100644 --- a/base_tier_validation/models/tier_definition.py +++ b/base_tier_validation/models/tier_definition.py @@ -18,9 +18,9 @@ class TierDefinition(models.Model): return res name = fields.Char( - string='Description', + string="Description", required=True, - default=_get_default_name, + default=lambda self: self._get_default_name(), translate=True, ) model_id = fields.Many2one( diff --git a/base_tier_validation/models/tier_validation.py b/base_tier_validation/models/tier_validation.py index c72e7e8..97dd158 100644 --- a/base_tier_validation/models/tier_validation.py +++ b/base_tier_validation/models/tier_validation.py @@ -23,10 +23,6 @@ class TierValidation(models.AbstractModel): domain=lambda self: [('model', '=', self._name)], auto_join=True, ) - review_ids_dropdown = fields.One2many( - related='review_ids', - help="Field needed to display the dropdown menu correctly" - ) validated = fields.Boolean( compute="_compute_validated_rejected", search="_search_validated", @@ -174,6 +170,7 @@ class TierValidation(models.AbstractModel): def validate_tier(self): for rec in self: rec._validate_tier() + self._update_counter() @api.multi def reject_tier(self): @@ -188,6 +185,7 @@ class TierValidation(models.AbstractModel): 'reviewed_date': fields.Datetime.now(), }) rec._notify_rejected_review() + self._update_counter() def _notify_rejected_review_body(self): return _('A review was rejected by %s.') % (self.env.user.name) @@ -230,6 +228,7 @@ class TierValidation(models.AbstractModel): rec.mapped('review_ids').unlink() self._update_counter() + @api.model def _update_counter(self): notifications = [] channel = 'base.tier.validation' diff --git a/base_tier_validation/static/src/js/review_widget.js b/base_tier_validation/static/src/js/review_widget.js index cdc454e..65077a6 100644 --- a/base_tier_validation/static/src/js/review_widget.js +++ b/base_tier_validation/static/src/js/review_widget.js @@ -55,4 +55,4 @@ odoo.define('base_tier_validation.ReviewField', function (require) { return ReviewField; - }); \ No newline at end of file + }); diff --git a/base_tier_validation/static/src/js/systray.js b/base_tier_validation/static/src/js/systray.js index 9b658e0..fcfce37 100644 --- a/base_tier_validation/static/src/js/systray.js +++ b/base_tier_validation/static/src/js/systray.js @@ -6,24 +6,24 @@ odoo.define('tier_validation.systray', function (require) { var session = require('web.session'); var SystrayMenu = require('web.SystrayMenu'); var Widget = require('web.Widget'); - var bus = require('bus.bus').bus; - - var chat_manager = require('mail.chat_manager'); + var BusService = require('bus.BusService'); var QWeb = core.qweb; var ReviewMenu = Widget.extend({ template:'tier.validation.ReviewMenu', events: { - "click": "_onReviewMenuClick", - "click .o_mail_channel_preview": "_onReviewFilterClick", + "show.bs.dropdown": "_onReviewMenuShow", + 'click .o_mail_activity_action': '_onReviewActionClick', + 'click .o_mail_preview': '_onReviewFilterClick', }, start: function () { - this.$reviews_preview = this.$('.o_mail_navbar_dropdown_channels'); + this.$reviews_preview = this.$('.o_mail_systray_dropdown_items'); this._updateReviewPreview(); var channel = 'base.tier.validation'; - bus.add_channel(channel); - bus.on('notification', this, this._updateReviewPreview); + this.call('bus_service', 'addChannel', channel); + this.call('bus_service', 'startPolling'); + this.call('bus_service', 'onNotification', this, this._updateReviewPreview); return this._super(); }, @@ -50,12 +50,15 @@ odoo.define('tier_validation.systray', function (require) { }); }, /** - * Check wether activity systray dropdown is open or not + * Get particular model view to redirect on click of review on that model. * @private - * @returns {boolean} + * @param {string} model */ - _isOpen: function () { - return this.$el.hasClass('open'); + _getReviewModelViewID: function (model) { + return this._rpc({ + model: model, + method: 'get_activity_view_id' + }); }, /** * Update(render) activity system tray view on activity updation. @@ -90,8 +93,20 @@ odoo.define('tier_validation.systray', function (require) { } }, - + //------------------------------------------------------------ // Handlers + //------------------------------------------------------------ + + /** + * Redirect to specific action given its xml id + * @private + * @param {MouseEvent} ev + */ + _onReviewActionClick: function (ev) { + ev.stopPropagation(); + var actionXmlid = $(ev.currentTarget).data('action_xmlid'); + this.do_action(actionXmlid); + }, /** * Redirect to particular model view @@ -118,18 +133,13 @@ odoo.define('tier_validation.systray', function (require) { * @private * @param {MouseEvent} event */ - _onReviewMenuClick: function () { - if (!this._isOpen()) { - this._updateReviewPreview(); - } + _onReviewMenuShow: function () { + this._updateReviewPreview(); }, }); SystrayMenu.Items.push(ReviewMenu); - // to test activity menu in qunit test cases we need it - return { - ReviewMenu: ReviewMenu, - }; -}); \ No newline at end of file + return ReviewMenu; +}); diff --git a/base_tier_validation/static/src/less/systray.less b/base_tier_validation/static/src/less/systray.less deleted file mode 100644 index 24a43f5..0000000 --- a/base_tier_validation/static/src/less/systray.less +++ /dev/null @@ -1,113 +0,0 @@ -// Navbar icon and dropdown -.o_tier_navbar_item { - > a { - opacity: 1; - > i { - font-size: larger; - } - } - &.o_no_notification > a { - opacity: 0.5; - > i { - .o-transform(translateY(0px)); - } - .o_notification_counter { - display: none; - } - } - &.open .o_tier_navbar_dropdown { - .o-flex-display(); - .o-flex-flow(column, nowrap); - } - .o_notification_counter { - .o-position-absolute(@top: 20%, @right: 1px); - background: @odoo-brand-optional; - color: white; - padding: 0em 0.3em; - font-size: 0.7em; - } - .o_tier_navbar_dropdown { - width: 350px; - padding: 0; - - .o_spinner { - .o-flex-display(); - .o-align-items(center); - .o-justify-content(center); - color: @odoo-main-text-color; - height: 50px; - } - - .o_tier_navbar_dropdown_channels { - .o-flex(0, 1, auto); - max-height: 400px; - min-height: 50px; - overflow-y: auto; - - @media (min-width: @screen-sm-min) { - .o_tier_channel_preview { - height: 50px; - padding: 5px; - .o_tier_channel_image { - width: 40px; - } - .o_channel_info { - margin-left: 10px; - .o_channel_title { - .o_last_message_date { - padding-top: 2px; - font-size: x-small; - margin-left: 10px; - } - } - } - } - } - } - .o_no_review { - cursor: initial; - .o-align-items(center); - color: grey; - opacity: 0.5; - padding: 3px; - } - } -} - -.o_no_chat_window .o_tier_navbar_dropdown .o_new_message { - display: none; // hide 'new message' button if chat windows are disabled -} - -// Mobile rules -// Goal: mock the design of Discuss in mobile -@media (max-width: @screen-xs-max) { - .o_tier_navbar_item { - .o_notification_counter { - top: 10%; - } - .o_tier_navbar_dropdown { - position: relative; - .o_tier_navbar_dropdown_top { - padding: 5px; - } - .o_tier_navbar_mobile_header { - padding: 5px; - height: 44px; - border-bottom: 1px solid #ebebeb; - box-shadow: 0 0 2px @gray-lighter-darker; - } - .o_tier_navbar_dropdown_channels { - max-height: none; - padding-bottom: 52px; // leave space for tabs - } - .o_tier_mobile_tabs { - position: fixed; - bottom: 0px; - left: 0px; - right: 0px; - background-color: white; - color: @odoo-main-text-color; - } - } - } -} diff --git a/base_tier_validation/static/src/less/review.less b/base_tier_validation/static/src/scss/review.scss similarity index 96% rename from base_tier_validation/static/src/less/review.less rename to base_tier_validation/static/src/scss/review.scss index e47e821..660061f 100644 --- a/base_tier_validation/static/src/less/review.less +++ b/base_tier_validation/static/src/scss/review.scss @@ -1,4 +1,4 @@ ul.o_review { min-width: 600px; max-width: 800px -} \ No newline at end of file +} diff --git a/base_tier_validation/static/src/scss/systray.scss b/base_tier_validation/static/src/scss/systray.scss new file mode 100644 index 0000000..5edc3a8 --- /dev/null +++ b/base_tier_validation/static/src/scss/systray.scss @@ -0,0 +1,141 @@ +// Navbar icon and dropdown +.o_tier_navbar_item { + > a { + opacity: 1; + > i { + font-size: larger; + } + } + &.o_no_notification > a { + opacity: 0.5; + > i { + transform: translateY(0px); + } + .o_notification_counter { + display: none; + } + } + &.show .o_tier_systray_dropdown { + display: flex; + flex-flow: column nowrap; + } + .o_notification_counter { + margin-top: -0.8rem; + margin-right: 0; + margin-left: -0.6rem; + background: #00A09D; + color: white; + vertical-align: super; + font-size: 0.7em; + } + .o_tier_systray_dropdown { + direction: ltr; + width: 350px; + padding: 0; + + .o_spinner { + display: flex; + align-items: center; + justify-content: center; + color: $o-main-text-color; + height: 50px; + } + + .o_tier_systray_dropdown_top { + display: flex; + flex: 0 0 auto; + justify-content: space-between; + border-bottom: 1px solid gray('400'); + box-shadow: 0 0 2px gray('400'); + .o_filter_button, .o_new_message { + padding: 5px; + } + .o_filter_button { + color: $o-main-color-muted; + &:hover, &.active { + color: $o-brand-primary; + } + &.active { + cursor: default; + font-weight: bold; + } + } + } + + .o_tier_systray_dropdown_items { + flex: 0 1 auto; + max-height: 400px; + min-height: 50px; + overflow-y: auto; + + @include media-breakpoint-up(md) { + .o_tier_preview { + min-height: 50px; + padding: 5px; + .o_tier_preview_image { + width: 40px; + height: 40px; + } + .o_preview_info { + margin-left: 10px; + .o_preview_title { + .o_last_message_date { + padding-top: 2px; + font-size: x-small; + margin-left: 10px; + } + } + } + } + } + } + .o_activity_filter_button { + padding: 2px; + } + .o_no_activity { + cursor: initial; + align-items: center; + color: grey; + opacity: 0.5; + padding: 3px; + } + } +} + +.o_no_thread_window .o_tier_systray_dropdown .o_new_message { + display: none; // hide 'new message' button if chat windows are disabled +} + +// Mobile rules +// Goal: mock the design of Discuss in mobile +@include media-breakpoint-down(sm) { + .o_tier_systray_item { + .o_notification_counter { + top: 10%; + } + .o_tier_systray_dropdown { + position: relative; + .o_tier_systray_dropdown_top { + padding: 5px; + } + .o_tier_systray_mobile_header { + padding: 5px; + height: 44px; + border-bottom: 1px solid #ebebeb; + box-shadow: 0 0 2px gray('400'); + } + .o_tier_systray_dropdown_items { + max-height: none; + padding-bottom: 52px; // leave space for tabs + } + .o_tier_mobile_tabs { + position: fixed; + bottom: 0px; + left: 0px; + right: 0px; + background-color: white; + color: $o-main-text-color; + } + } + } +} diff --git a/base_tier_validation/static/src/xml/systray.xml b/base_tier_validation/static/src/xml/systray.xml index 55962d1..1cf8fd6 100644 --- a/base_tier_validation/static/src/xml/systray.xml +++ b/base_tier_validation/static/src/xml/systray.xml @@ -3,38 +3,50 @@ -
  • +
  • +
    -
    -
    - +
    +
    + Review
    -
    -
    - +
    +
    + +
    + + + +
    - 0 Pending + 0 Pending
    + -
  • -
  • - +
  • diff --git a/base_tier_validation/static/src/xml/tier_review_template.xml b/base_tier_validation/static/src/xml/tier_review_template.xml index d8821b8..9755007 100644 --- a/base_tier_validation/static/src/xml/tier_review_template.xml +++ b/base_tier_validation/static/src/xml/tier_review_template.xml @@ -3,7 +3,7 @@