Skip to content

Commit

Permalink
[MIG] dms_attachment_link: Migration to 17.0
Browse files Browse the repository at this point in the history
TT50055
  • Loading branch information
victoralmau committed Oct 11, 2024
1 parent 5bb5f5c commit 49bed24
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
2 changes: 1 addition & 1 deletion dms_attachment_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Dms Attachment Link",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Document Management",
"website": "https://github.com/OCA/dms",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
58 changes: 27 additions & 31 deletions dms_attachment_link/static/src/js/dms_attachment_link.esm.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
/** @odoo-module **/

import {registerPatch} from "@mail/model/model_core";
import {Chatter} from "@mail/core/web/chatter";
import {patch} from "@web/core/utils/patch";

registerPatch({
name: "AttachmentBoxView",
recordMethods: {
_onAddDmsFile() {
this.env.services.action.doAction(
"dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
{
additionalContext: {
active_id: this.chatter.thread.id,
active_ids: [this.chatter.thread.id],
active_model: this.chatter.threadModel,
},
onClose: this._onAddedDmsFile.bind(this),
}
);
},
_onAddedDmsFile() {
this.chatter.refresh();
},
patch(Chatter.prototype, {
_onAddDmsFile() {
this.action.doAction(
"dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
{
additionalContext: {
active_id: this.state.thread.id,
active_ids: [this.state.thread.id],
active_model: this.state.thread.model,
},
onClose: async () => {
await this._onAddedDmsFile();
},
}
);
},
});

registerPatch({
name: "Chatter",
recordMethods: {
/**
* Handles click on the attach button.
*/
async onClickButtonAddAttachments() {
await this.onClickButtonToggleAttachments();
},
onClickAddAttachments(ev) {
ev.stopPropagation();
this.state.isAttachmentBoxOpened = !this.state.isAttachmentBoxOpened;
if (this.state.isAttachmentBoxOpened) {
this.rootRef.el.scrollTop = 0;
this.state.thread.scrollTop = "bottom";
}
},
async _onAddedDmsFile() {
this.reloadParentView();
},
});
11 changes: 4 additions & 7 deletions dms_attachment_link/static/src/xml/chatter.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2023 Tecnativa - Víctor Martínez
<!-- Copyright 2023-2024 Tecnativa - Víctor Martínez
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates id="template" xml:space="preserve">
<t t-inherit="mail.AttachmentBox" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_AttachmentBox_content')]" position="attributes">
<attribute name="class" add="d-block text-center" separator=" " />
</xpath>
<xpath expr="//button[hasclass('o_AttachmentBox_buttonAdd')]" position="after">
<t t-inherit="mail.Chatter" t-inherit-mode="extension">
<xpath expr="//FileUploader//button" position="after">
<button
class="o_add_dms_file_button btn btn-link"
type="button"
t-on-click.stop.prevent="attachmentBoxView._onAddDmsFile"
t-on-click.stop.prevent="_onAddDmsFile"
>
<i class="fa fa-plus-square" />
Add DMS File
Expand Down

0 comments on commit 49bed24

Please sign in to comment.