-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOV] attachment_preview: Reorganize JS modules
- Loading branch information
1 parent
38faa14
commit 838485f
Showing
7 changed files
with
233 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
attachment_preview/static/src/js/mail_models/attachment_card.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** @odoo-module **/ | ||
import {query} from "web.rpc"; | ||
import {registerPatch} from "@mail/model/model_core"; | ||
import {showPreview} from "../utils.esm"; | ||
|
||
registerPatch({ | ||
name: "AttachmentCard", | ||
recordMethods: { | ||
/** | ||
* @private | ||
* @param {event} event | ||
*/ | ||
_onPreviewAttachment(event) { | ||
event.preventDefault(); | ||
|
||
var self = this, | ||
$target = $(event.currentTarget), | ||
split_screen = $target.attr("data-target") !== "new", | ||
attachment_id = this.attachment.id; | ||
|
||
query({ | ||
model: "ir.attachment", | ||
method: "get_attachment_extension", | ||
args: [attachment_id], | ||
}).then(function (extension) { | ||
showPreview( | ||
attachment_id, | ||
self.attachment.defaultSource, | ||
extension, | ||
self.attachment.filename, | ||
split_screen, | ||
self.attachmentList.previewableAttachments | ||
); | ||
}); | ||
}, | ||
}, | ||
}); |
67 changes: 67 additions & 0 deletions
67
attachment_preview/static/src/js/mail_models/attachment_list.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** @odoo-module **/ | ||
import {canPreview, getUrl} from "../utils.esm"; | ||
import {query} from "web.rpc"; | ||
import {registerPatch} from "@mail/model/model_core"; | ||
|
||
registerPatch({ | ||
name: "AttachmentList", | ||
lifecycleHooks: { | ||
_created() { | ||
var attachments = _.object( | ||
this.attachments.map((attachment) => { | ||
return attachment.id; | ||
}), | ||
this.attachments.map((attachment) => { | ||
if ( | ||
attachment.defaultSource && | ||
attachment.defaultSource.length > 38 | ||
) { | ||
return { | ||
url: attachment.defaultSource, | ||
extension: attachment.extension, | ||
title: attachment.name, | ||
}; | ||
} | ||
return { | ||
url: "/web/content?id=" + attachment.id + "&download=true", | ||
extension: attachment.extension, | ||
title: attachment.name, | ||
}; | ||
}) | ||
); | ||
|
||
var self = this; | ||
query({ | ||
model: "ir.attachment", | ||
method: "get_attachment_extension", | ||
args: [ | ||
_.map(_.keys(attachments), function (id) { | ||
return parseInt(id, 10); | ||
}), | ||
], | ||
}).then(function (extensions) { | ||
self.previewableAttachments = _.map( | ||
_.keys( | ||
_.pick(extensions, function (extension) { | ||
return canPreview(extension); | ||
}) | ||
), | ||
function (id) { | ||
return { | ||
id: id, | ||
url: attachments[id].url, | ||
extension: extensions[id], | ||
title: attachments[id].title, | ||
previewUrl: getUrl( | ||
id, | ||
attachments[id].url, | ||
extensions[id], | ||
attachments[id].title | ||
), | ||
}; | ||
} | ||
); | ||
}); | ||
}, | ||
}, | ||
}); |
217 changes: 0 additions & 217 deletions
217
attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.