From 81a4924d6b0cb1b75268518ecec7d517e219df96 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Mon, 22 Jan 2024 16:41:10 +0100 Subject: [PATCH] Fix Open menu in attachment preview screen [SCI-9757] --- .../content/attachments/open_locally_menu.vue | 46 +++++++++++++------ .../shared/file_preview/_content.html.erb | 5 +- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/app/javascript/vue/shared/content/attachments/open_locally_menu.vue b/app/javascript/vue/shared/content/attachments/open_locally_menu.vue index 43d1498aa..e89e2d8dc 100644 --- a/app/javascript/vue/shared/content/attachments/open_locally_menu.vue +++ b/app/javascript/vue/shared/content/attachments/open_locally_menu.vue @@ -1,21 +1,27 @@ @@ -32,23 +38,28 @@ export default { data: { type: String, required: true }, }, created() { - window.openLocallyMenu = this; - this.attachment = JSON.parse(this.data); - }, - beforeUnmount() { - delete window.openLocallyMenuComponent; + this.attachment = { attributes: JSON.parse(this.data) }; + this.fetchLocalAppInfo(); }, computed: { menu() { const menu = []; - if (this.attachment.wopi && this.attachment.urls.edit_asset) { + if (this.attachment.attributes.wopi && this.attachment.attributes.urls.edit_asset) { menu.push({ - text: this.attachment.wopi_context.button_text, - url: this.attachment.urls.edit_asset, - url_target: '_blank', + text: this.attachment.attributes.wopi_context.button_text, + url: this.attachment.attributes.urls.edit_asset, + url_target: '_blank' }); } + + if (this.attachment.attributes.image_editable) { + menu.push({ + text: this.i18n.t('assets.file_preview.edit_in_scinote'), + emit: 'openImageEditor' + }); + } + if (this.canOpenLocally) { const text = this.localAppName ? this.i18n.t('attachments.open_locally_in', { application: this.localAppName }) @@ -56,12 +67,17 @@ export default { menu.push({ text, - emit: 'open_locally', + emit: 'openLocally' }); } return menu; }, }, + methods: { + openImageEditor() { + document.getElementById('editImageButton').click(); + } + } }; diff --git a/app/views/shared/file_preview/_content.html.erb b/app/views/shared/file_preview/_content.html.erb index 31fd8e0d8..51130f3e5 100644 --- a/app/views/shared/file_preview/_content.html.erb +++ b/app/views/shared/file_preview/_content.html.erb @@ -27,7 +27,7 @@ <% elsif asset.editable_image? %> - +
+ +
<% end %> <% end %>