mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 02:14:29 +08:00
Merge pull request #7915 from artoscinote/ma_SCI_11043
Add file editing & versioning to inventories [SCI-11043]
This commit is contained in:
commit
98d70d6c8a
3 changed files with 30 additions and 10 deletions
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<div class="sn-open-locally-menu" @mouseenter="fetchLocalAppInfo">
|
||||
<div v-if="(!canOpenLocally || disableLocalOpen) && (attachment.attributes.wopi && attachment.attributes.urls.edit_asset)">
|
||||
<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="block whitespace-nowrap rounded px-3 py-2.5 hover:!text-sn-blue hover:no-underline cursor-pointer hover:bg-sn-super-light-grey"
|
||||
class="btn btn-light"
|
||||
:class="{ 'disabled': !editWopiSupported }"
|
||||
:title="editWopiSupported ? null : attachment.attributes.wopi_context.title"
|
||||
style="pointer-events: all"
|
||||
|
@ -26,6 +26,7 @@
|
|||
{{ menu[0].text }}
|
||||
</a>
|
||||
</div>
|
||||
<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">
|
||||
<NoPredefinedAppModal
|
||||
|
@ -47,6 +48,13 @@
|
|||
v-if="showUpdateVersionModal"
|
||||
@close="showUpdateVersionModal = false"
|
||||
/>
|
||||
<FileVersionsModal
|
||||
v-if="fileVersionsModal"
|
||||
:versionsUrl="attachment.attributes.urls.versions"
|
||||
:restoreVersionUrl="attachment.attributes.urls.restore_version"
|
||||
@close="fileVersionsModal = false"
|
||||
@fileVersionRestored="refreshPreview"
|
||||
/>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -55,14 +63,19 @@
|
|||
import OpenLocallyMixin from './mixins/open_locally.js';
|
||||
import MenuDropdown from '../../menu_dropdown.vue';
|
||||
import UpdateVersionModal from '../modal/update_version_modal.vue';
|
||||
import FileVersionsModal from '../../file_versions_modal.vue';
|
||||
|
||||
export default {
|
||||
name: 'OpenLocallyMenu',
|
||||
mixins: [OpenLocallyMixin],
|
||||
components: { MenuDropdown, UpdateVersionModal },
|
||||
components: { MenuDropdown, UpdateVersionModal, FileVersionsModal },
|
||||
props: {
|
||||
attachment: { type: Object, required: true },
|
||||
disableLocalOpen: { type: Boolean, default: false }
|
||||
attachment: { type: Object, required: true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fileVersionsModal: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchLocalAppInfo();
|
||||
|
@ -92,7 +105,7 @@ export default {
|
|||
});
|
||||
}
|
||||
|
||||
if (this.canOpenLocally && !this.disableLocalOpen) {
|
||||
if (this.canOpenLocally) {
|
||||
const text = this.localAppName
|
||||
? this.i18n.t('attachments.open_locally_in', { application: this.localAppName })
|
||||
: this.i18n.t('attachments.open_locally');
|
||||
|
@ -116,6 +129,13 @@ export default {
|
|||
methods: {
|
||||
openImageEditor() {
|
||||
document.getElementById('editImageButton').click();
|
||||
},
|
||||
refreshPreview() {
|
||||
const imageElement = document.querySelector('.file-preview-container .asset-image');
|
||||
|
||||
if (!imageElement) return;
|
||||
|
||||
window.ActiveStoragePreviews.reCheckPreview({ target: imageElement });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<% if can_edit && !preview %>
|
||||
<% if wopi_enabled? && wopi_file?(asset) %>
|
||||
<div id="openLocallyMenu" data-behaviour="vue">
|
||||
<open-locally-menu :disable-local-open="<%= asset.repository_asset_value.present? %>" :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
|
||||
<open-locally-menu :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
|
||||
</div>
|
||||
<% elsif asset.file.metadata[:asset_type] == 'marvinjs' %>
|
||||
<button class="btn btn-light marvinjs-edit-button"
|
||||
|
@ -40,7 +40,7 @@
|
|||
</button>
|
||||
<% end %>
|
||||
<div id="openLocallyMenu" data-behaviour="vue">
|
||||
<open-locally-menu :disable-local-open="<%= asset.repository_asset_value.present? %>" :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
|
||||
<open-locally-menu :attachment="<%= { attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json }.to_json %>" />
|
||||
</div>
|
||||
<% end %>
|
||||
<a class="btn btn-light file-download-link" href="<%= rails_blob_path(asset.file, disposition: 'attachment') %>" data-turbolinks="false">
|
||||
|
|
|
@ -4013,7 +4013,7 @@ en:
|
|||
inline_html: "Large"
|
||||
thumbnail_html: "Thumbnail"
|
||||
list_html: "List"
|
||||
versions: "Versions"
|
||||
versions: "Version history"
|
||||
file_versions_modal:
|
||||
title: "Version history"
|
||||
download: "Download"
|
||||
|
|
Loading…
Add table
Reference in a new issue