summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/attachment_viewer
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/mail/static/src/models/attachment_viewer
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/mail/static/src/models/attachment_viewer')
-rw-r--r--addons/mail/static/src/models/attachment_viewer/attachment_viewer.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js
new file mode 100644
index 00000000..8a96946c
--- /dev/null
+++ b/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js
@@ -0,0 +1,59 @@
+odoo.define('mail/static/src/models/attachment_viewer/attachment_viewer.js', function (require) {
+'use strict';
+
+const { registerNewModel } = require('mail/static/src/model/model_core.js');
+const { attr, many2many, many2one } = require('mail/static/src/model/model_field.js');
+
+function factory(dependencies) {
+
+ class AttachmentViewer extends dependencies['mail.model'] {
+
+ //----------------------------------------------------------------------
+ // Public
+ //----------------------------------------------------------------------
+
+ /**
+ * Close the attachment viewer by closing its linked dialog.
+ */
+ close() {
+ const dialog = this.env.models['mail.dialog'].find(dialog => dialog.record === this);
+ if (dialog) {
+ dialog.delete();
+ }
+ }
+ }
+
+ AttachmentViewer.fields = {
+ /**
+ * Angle of the image. Changes when the user rotates it.
+ */
+ angle: attr({
+ default: 0,
+ }),
+ attachment: many2one('mail.attachment'),
+ attachments: many2many('mail.attachment', {
+ inverse: 'attachmentViewer',
+ }),
+ /**
+ * Determine whether the image is loading or not. Useful to diplay
+ * a spinner when loading image initially.
+ */
+ isImageLoading: attr({
+ default: false,
+ }),
+ /**
+ * Scale size of the image. Changes when user zooms in/out.
+ */
+ scale: attr({
+ default: 1,
+ }),
+ };
+
+ AttachmentViewer.modelName = 'mail.attachment_viewer';
+
+ return AttachmentViewer;
+}
+
+registerNewModel('mail.attachment_viewer', factory);
+
+});