diff --git a/rma_sale/static/src/js/rma_portal_form.js b/rma_sale/static/src/js/rma_portal_form.js new file mode 100644 index 00000000..e904d44a --- /dev/null +++ b/rma_sale/static/src/js/rma_portal_form.js @@ -0,0 +1,45 @@ +/* Copyright 2021 Tecnativa - David Vidal + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + +odoo.define("rma_sale.animation", function(require) { + "use strict"; + + var sAnimation = require("website.content.snippets.animation"); + + // In the customer portal when a RMA operation is selected show the comments + // selector so the user doesn't miss the chance to add his comments + sAnimation.registry.rma_operation_portal = sAnimation.Class.extend({ + selector: ".rma-operation", + start: function() { + this.id = this.el.name.replace("-operation_id", ""); + this.$comment = $("#comment-" + this.id); + this.$comment_input = $("[name='" + this.id + "-description']"); + var _this = this; + this.$el.on("change", function() { + _this._onChangeOperationId(); + }); + }, + _show_comment: function() { + if (this.$comment) { + this.$comment.removeClass("show"); + this.$comment.addClass("show"); + if (this.$comment_input) { + this.$comment_input.focus(); + } + } + }, + _hide_comment: function() { + if (this.$comment) { + this.$comment.removeClass("show"); + } + }, + _onChangeOperationId: function() { + // Toggle comment on or off if an operation is requested + if (this.$el && this.$el.val()) { + this._show_comment(); + } else { + this._hide_comment(); + } + }, + }); +}); diff --git a/rma_sale/views/assets.xml b/rma_sale/views/assets.xml index e946398f..53633488 100644 --- a/rma_sale/views/assets.xml +++ b/rma_sale/views/assets.xml @@ -2,6 +2,10 @@