Skip to content

Commit

Permalink
Merge branch 'develop' into features/custom-docx-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
aignatov-bio committed Nov 14, 2024
2 parents 1f1ab08 + 162b64e commit d860a45
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
61 changes: 32 additions & 29 deletions app/javascript/vue/shared/content/attachments/open_locally_menu.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<template>
<div class="sn-open-locally-menu flex" @mouseenter="fetchLocalAppInfo">
<div v-if="(!canOpenLocally) && (attachment.attributes.wopi && attachment.attributes.urls.edit_asset)">
<a :href="editWopiSupported ? attachment.attributes.urls.edit_asset : null" target="_blank"
class="btn btn-light"
:class="{ 'disabled': !editWopiSupported }"
:title="editWopiSupported ? null : attachment.attributes.wopi_context.title"
style="pointer-events: all"
>
{{ attachment.attributes.wopi_context.button_text }}
</a>
</div>
<div v-else-if="!usesWebIntegration">
<MenuDropdown
v-if="this.menu.length > 1"
class="ml-auto"
:listItems="this.menu"
:btnClasses="`btn btn-light icon-btn`"
:position="'right'"
:btnText="i18n.t('attachments.open_in')"
:caret="true"
@open-locally="openLocally"
@open-image-editor="openImageEditor"
></MenuDropdown>
<a v-else-if="menu.length === 1" class="btn btn-light" :href="menu[0].url" :target="menu[0].url_target" @click="this[this.menu[0].emit]()">
{{ menu[0].text }}
<template v-if="canEdit">
<div v-if="(!canOpenLocally) && (attachment.attributes.wopi && attachment.attributes.urls.edit_asset)">
<a :href="editWopiSupported ? attachment.attributes.urls.edit_asset : null" target="_blank"
class="btn btn-light"
:class="{ 'disabled': !editWopiSupported }"
:title="editWopiSupported ? null : attachment.attributes.wopi_context.title"
style="pointer-events: all"
>
{{ attachment.attributes.wopi_context.button_text }}
</a>
</div>
</div>
<div v-else-if="!usesWebIntegration">
<MenuDropdown
v-if="this.menu.length > 1"
class="ml-auto"
:listItems="this.menu"
:btnClasses="`btn btn-light icon-btn`"
:position="'right'"
:btnText="i18n.t('attachments.open_in')"
:caret="true"
@open-locally="openLocally"
@open-image-editor="openImageEditor"
></MenuDropdown>
<a v-else-if="menu.length === 1" class="btn btn-light" :href="menu[0].url" :target="menu[0].url_target" @click="this[this.menu[0].emit]()">
{{ menu[0].text }}
</a>
</div>
</template>
<a @click="fileVersionsModal = true" class="btn btn-light"><i class="sn-icon sn-icon-history-search"></i>{{ i18n.t('assets.context_menu.versions') }}</a>

<Teleport to="body">
Expand Down Expand Up @@ -70,7 +72,8 @@ export default {
mixins: [OpenLocallyMixin],
components: { MenuDropdown, UpdateVersionModal, FileVersionsModal },
props: {
attachment: { type: Object, required: true }
attachment: { type: Object, required: true },
canEdit: { type: Boolean, default: true }
},
data() {
return {
Expand Down Expand Up @@ -131,11 +134,11 @@ export default {
document.getElementById('editImageButton').click();
},
refreshPreview() {
const imageElement = document.querySelector('.file-preview-container .asset-image');
const filePreview = document.querySelector('.file-preview-container');
if (!imageElement) return;
if (!filePreview) return;
$('#filePreviewModal').modal('hide');
window.location.reload();
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions app/views/shared/file_preview/_content.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
<%= t('assets.file_preview.edit_in_scinote') %>
</button>
<% end %>
<div id="openLocallyMenu" data-behaviour="vue">
<open-locally-menu :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
</div>
<% end %>
<div id="openLocallyMenu" data-behaviour="vue">
<open-locally-menu :can-edit="<%= can_edit && !preview %>" :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
</div>
<a class="btn btn-light file-download-link" href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>" data-turbolinks="false">
<span class="sn-icon sn-icon-export"></span> <%= t('Download')%>
</a>
Expand Down

0 comments on commit d860a45

Please sign in to comment.