2023-12-14 03:54:41 +08:00
|
|
|
<template>
|
2024-01-23 18:52:35 +08:00
|
|
|
<div class="sn-open-locally-menu" @mouseenter="fetchLocalAppInfo">
|
|
|
|
<div v-if="!canOpenLocally && (attachment.attributes.wopi && attachment.attributes.urls.edit_asset)">
|
|
|
|
<a :href="`${attachment.attributes.urls.edit_asset}`" 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">
|
|
|
|
{{ attachment.attributes.wopi_context.button_text }}
|
|
|
|
</a>
|
2023-12-14 03:54:41 +08:00
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<MenuDropdown
|
2024-01-22 23:41:10 +08:00
|
|
|
v-if="this.menu.length > 1"
|
2023-12-14 03:54:41 +08:00
|
|
|
class="ml-auto"
|
|
|
|
:listItems="this.menu"
|
2024-01-31 22:15:24 +08:00
|
|
|
:btnClasses="`btn btn-light icon-btn`"
|
2023-12-14 03:54:41 +08:00
|
|
|
:position="'right'"
|
2024-01-22 23:41:10 +08:00
|
|
|
:btnText="i18n.t('attachments.open_in')"
|
|
|
|
:caret="true"
|
2024-02-01 17:15:58 +08:00
|
|
|
@open-locally="openLocally"
|
|
|
|
@open-image-editor="openImageEditor"
|
2023-12-14 03:54:41 +08:00
|
|
|
></MenuDropdown>
|
2024-02-01 17:15:58 +08:00
|
|
|
<a v-else-if="menu.length === 1" class="btn btn-light !bg-sn-white" :href="menu[0].url" :target="menu[0].target" @click="this[this.menu[0].emit]()">
|
|
|
|
{{ menu[0].text }}
|
2024-01-22 23:41:10 +08:00
|
|
|
</a>
|
2023-12-14 03:54:41 +08:00
|
|
|
</div>
|
2024-01-31 22:15:24 +08:00
|
|
|
|
|
|
|
<Teleport to="body">
|
|
|
|
<NoPredefinedAppModal
|
|
|
|
v-if="showNoPredefinedAppModal"
|
|
|
|
:fileName="attachment.attributes.file_name"
|
|
|
|
@confirm="showNoPredefinedAppModal = false"
|
|
|
|
/>
|
|
|
|
<editLaunchingApplicationModal
|
2024-02-01 17:15:58 +08:00
|
|
|
v-if="editAppModal"
|
|
|
|
:fileName="attachment.attributes.file_name"
|
|
|
|
:application="this.localAppName"
|
|
|
|
@cancel="editAppModal = false"
|
|
|
|
/>
|
|
|
|
<UpdateVersionModal
|
|
|
|
v-if="showUpdateVersionModal"
|
|
|
|
@cancel="showUpdateVersionModal = false"
|
2024-01-31 22:15:24 +08:00
|
|
|
/>
|
|
|
|
</Teleport>
|
2023-12-14 03:54:41 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-01-04 07:13:21 +08:00
|
|
|
import OpenLocallyMixin from './mixins/open_locally.js';
|
|
|
|
import MenuDropdown from '../../menu_dropdown.vue';
|
2024-01-23 18:52:35 +08:00
|
|
|
import UpdateVersionModal from '../modal/update_version_modal.vue';
|
2023-12-14 03:54:41 +08:00
|
|
|
|
2024-01-04 07:13:21 +08:00
|
|
|
export default {
|
|
|
|
name: 'OpenLocallyMenu',
|
|
|
|
mixins: [OpenLocallyMixin],
|
2024-01-23 18:52:35 +08:00
|
|
|
components: { MenuDropdown, UpdateVersionModal },
|
2024-01-04 07:13:21 +08:00
|
|
|
props: {
|
2024-01-23 18:52:35 +08:00
|
|
|
attachment: { type: Object, required: true }
|
2024-01-04 07:13:21 +08:00
|
|
|
},
|
|
|
|
created() {
|
2024-01-23 18:52:35 +08:00
|
|
|
this.fetchLocalAppInfo();
|
2024-01-04 07:13:21 +08:00
|
|
|
window.openLocallyMenu = this;
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
delete window.openLocallyMenuComponent;
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
menu() {
|
|
|
|
const menu = [];
|
2023-12-14 03:54:41 +08:00
|
|
|
|
2024-01-23 18:52:35 +08:00
|
|
|
if (this.attachment.attributes.wopi && this.attachment.attributes.urls.edit_asset) {
|
2024-01-04 07:13:21 +08:00
|
|
|
menu.push({
|
2024-01-23 18:52:35 +08:00
|
|
|
text: this.attachment.attributes.wopi_context.button_text,
|
|
|
|
url: this.attachment.attributes.urls.edit_asset,
|
2024-01-22 23:41:10 +08:00
|
|
|
url_target: '_blank'
|
2024-01-17 00:31:12 +08:00
|
|
|
});
|
2024-01-04 07:13:21 +08:00
|
|
|
}
|
2024-01-22 23:41:10 +08:00
|
|
|
|
2024-01-31 22:15:24 +08:00
|
|
|
if (this.attachment.attributes.image_editable && !this.canOpenLocally) {
|
2024-01-22 23:41:10 +08:00
|
|
|
menu.push({
|
|
|
|
text: this.i18n.t('assets.file_preview.edit_in_scinote'),
|
2024-01-24 16:32:31 +08:00
|
|
|
emit: 'openImageEditor'
|
2024-01-22 23:41:10 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-01-04 07:13:21 +08:00
|
|
|
if (this.canOpenLocally) {
|
|
|
|
const text = this.localAppName
|
|
|
|
? this.i18n.t('attachments.open_locally_in', { application: this.localAppName })
|
|
|
|
: this.i18n.t('attachments.open_locally');
|
2023-12-19 16:19:19 +08:00
|
|
|
|
2024-01-04 07:13:21 +08:00
|
|
|
menu.push({
|
|
|
|
text,
|
2024-01-22 23:41:10 +08:00
|
|
|
emit: 'openLocally'
|
2024-01-04 07:13:21 +08:00
|
|
|
});
|
2023-12-14 03:54:41 +08:00
|
|
|
}
|
2024-01-04 07:13:21 +08:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
},
|
|
|
|
},
|
2024-01-22 23:41:10 +08:00
|
|
|
methods: {
|
|
|
|
openImageEditor() {
|
|
|
|
document.getElementById('editImageButton').click();
|
|
|
|
}
|
2024-01-23 18:52:35 +08:00
|
|
|
}
|
2024-01-04 07:13:21 +08:00
|
|
|
};
|
2023-12-14 03:54:41 +08:00
|
|
|
</script>
|