diff --git a/g2p_program_assessment/models/assessment.py b/g2p_program_assessment/models/assessment.py
index 7a7d3157..4dd62c11 100644
--- a/g2p_program_assessment/models/assessment.py
+++ b/g2p_program_assessment/models/assessment.py
@@ -23,6 +23,7 @@ class G2PProgramAssessment(models.Model):
program_membership_id = fields.Many2one("g2p.program_membership")
entitlement_id = fields.Many2one("g2p.entitlement")
+ is_comment = fields.Boolean(default=False)
@api.model
def post_assessment(
@@ -30,6 +31,7 @@ def post_assessment(
body,
res_model,
res_ids,
+ is_comment=False,
subject=None,
message_type="comment",
subtype_id=None,
@@ -72,6 +74,7 @@ def post_assessment(
"name": message.subject,
"remarks_id": message.id,
self.get_res_field_name(res_model): res_ids[i],
+ "is_comment": is_comment,
}
for i, message in enumerate(messages)
]
@@ -162,6 +165,7 @@ def get_rendering_context(self, res_model, res_id):
"author_id": assess.author_id.id,
"assessment_date": assess.assessment_date,
"body": assess.remarks_id.body,
+ "is_comment": assess.is_comment,
}
for assess in self.search(
[(self.get_res_field_name(res_model), "=", res_id)],
diff --git a/g2p_program_assessment/static/src/js/g2p_assessment.js b/g2p_program_assessment/static/src/js/g2p_assessment.js
index 1514a0ca..3f3e88bc 100644
--- a/g2p_program_assessment/static/src/js/g2p_assessment.js
+++ b/g2p_program_assessment/static/src/js/g2p_assessment.js
@@ -14,8 +14,10 @@ var G2PAssessmentWizardWidget = AbstractField.extend({
tagName: "div",
events: {
"click button.o_ChatterTopbar_buttonAddAssess": "triggerAddAssessment",
+ "click button.o_ChatterTopbar_buttonAddComment": "triggerAddComment",
"click button.o_Composer_buttonCancel": "triggerAddAssessment",
"click button.o_Composer_buttonSubmit": "submitAssessment",
+ // "click button.o_Composer_buttonSubmit": "submitComment",
"keyup textarea.o_ComposerTextInput_textarea": "triggerButtonSubmitEnable",
},
init: function () {
@@ -32,6 +34,8 @@ var G2PAssessmentWizardWidget = AbstractField.extend({
} else if (this.nodeOptions.not_readonly_field) {
this.readonly = !this.recordData[this.nodeOptions.not_readonly_field];
}
+ this.showAddCommentsButton = this.nodeOptions.show_add_comments_button != false;
+ this.showAddAssessmentsButton = this.nodeOptions.show_add_assessments_button != false;
console.log(this);
this.assessmentAddMode = 0;
this.assessmentAddModeStarted = 0;
@@ -39,34 +43,40 @@ var G2PAssessmentWizardWidget = AbstractField.extend({
_render: async function () {
return this.$el.html(qweb.render("g2p_assessments_list", await this._getRenderingContext()));
},
- triggerAddAssessment: function () {
+ triggerAddComment: function (e) {
+ return this.triggerAddAssessment(e, true);
+ },
+ triggerAddAssessment: function (e, is_comment = false) {
if (this.assessmentAddModeStarted === 0) {
this.assessmentAddMode = 1;
this.assessmentAddModeStarted = 1;
- this.$(".o_ChatterTopbar_buttonAddAssess").addClass("o_invisible_modifier");
+ this.$(".o_Composer_header_buttons").addClass("o_invisible_modifier");
this.$(".o_Composer").replaceWith(
qweb.render("g2p_assessments_add", {author_partner_id: session.partner_id})
);
- return;
- }
- if (this.assessmentAddMode === 0) {
+ } else if (this.assessmentAddMode === 0) {
this.assessmentAddMode = 1;
this.$(".o_Composer_Assessment").removeClass("o_invisible_modifier");
- this.$(".o_ChatterTopbar_buttonAddAssess").addClass("o_invisible_modifier");
+ this.$(".o_Composer_header_buttons").addClass("o_invisible_modifier");
} else {
this.assessmentAddMode = 0;
this.$(".o_Composer_Assessment").addClass("o_invisible_modifier");
- this.$(".o_ChatterTopbar_buttonAddAssess").removeClass("o_invisible_modifier");
+ this.$(".o_Composer_header_buttons").removeClass("o_invisible_modifier");
}
+ console.log("trigger ", is_comment);
+ if (is_comment) this.$(".o_Composer_Assessment").addClass("o_Composer_Comment");
+ else this.$(".o_Composer_Assessment").removeClass("o_Composer_Comment");
},
submitAssessment: function () {
var self = this;
+ const is_comment = this.$(".o_Composer_Assessment").hasClass("o_Composer_Comment");
+ console.log(is_comment);
let textareaBody = this.$("textarea.o_ComposerTextInput_textarea")[0].value;
textareaBody = textareaBody.replace(/(?:\r\n|\r|\n)/g, "
");
this._rpc({
model: "g2p.program.assessment",
method: "post_assessment",
- args: [textareaBody, this.resModel, this.resId],
+ args: [textareaBody, this.resModel, this.resId, is_comment],
}).then(function () {
self.assessmentAddMode = 0;
self.assessmentAddModeStarted = 0;
@@ -91,6 +101,8 @@ var G2PAssessmentWizardWidget = AbstractField.extend({
});
res.readonly = this.readonly;
res.resModel = this.resModel;
+ res.showAddCommentsButton = this.showAddCommentsButton;
+ res.showAddAssessmentsButton = this.showAddAssessmentsButton;
return res;
},
});
diff --git a/g2p_program_assessment/static/src/scss/g2p_assessment.scss b/g2p_program_assessment/static/src/scss/g2p_assessment.scss
index 18bad224..9c91c4c3 100644
--- a/g2p_program_assessment/static/src/scss/g2p_assessment.scss
+++ b/g2p_program_assessment/static/src/scss/g2p_assessment.scss
@@ -23,6 +23,9 @@
margin-bottom: 0.4%;
}
+.o_Message.o_Message_Assessment.o_message_highlight {
+ background: #ffffff 0% 0% no-repeat padding-box;
+}
.o_ChatterTopbar_buttonAddAssess {
border-radius: 10px;
border: 1px solid #0000001a;
@@ -33,12 +36,15 @@
}
.o_Composer_Assessment {
- background: #ffffff 0% 0% no-repeat padding-box;
+ background: #f8f9fa 0% 0% no-repeat padding-box;
box-shadow: 0px 2px 5px #0000001a;
border-radius: 10px;
border: 1px solid #0000001a;
padding: 2% 1% 2% 1%;
}
+.o_Composer_Assessment.o_Composer_Comment {
+ background: #ffffff 0% 0% no-repeat padding-box;
+}
.o_Composer_Assessment .o_Message_sidebar {
margin-right: 1%;
@@ -75,3 +81,10 @@
.o_Composer_buttonCancelText {
color: #e27d21;
}
+.o_ChatterTopbar_buttonAddComment {
+ border-radius: 10px;
+ border: 1px solid #e27d21;
+}
+.o_ChatterTopbar_buttonAddCommentText {
+ color: #e27d21;
+}
diff --git a/g2p_program_assessment/static/src/xml/g2p_assessment_templates.xml b/g2p_program_assessment/static/src/xml/g2p_assessment_templates.xml
index 604a827b..6569f4b1 100644
--- a/g2p_program_assessment/static/src/xml/g2p_assessment_templates.xml
+++ b/g2p_program_assessment/static/src/xml/g2p_assessment_templates.xml
@@ -37,12 +37,22 @@