2022-05-18 17:12:53 +08:00
|
|
|
<template>
|
|
|
|
<div ref="modal" @keydown.esc="cancel"
|
|
|
|
class="modal add-file-modal"
|
2022-05-24 17:30:15 +08:00
|
|
|
:class="{ 'draging-file' : dragingFile }"
|
2022-05-18 17:12:53 +08:00
|
|
|
role="dialog" aria-hidden="true" tabindex="-1">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
<h2 class="modal-title">
|
|
|
|
{{ i18n.t("protocols.steps.attachments.file_modal.title") }}
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="file-drop-zone"
|
|
|
|
@drop.prevent="dropFile"
|
|
|
|
@dragenter.prevent="dragingFile = true"
|
|
|
|
@dragleave.prevent="dragingFile = false"
|
|
|
|
@dragover.prevent
|
|
|
|
>
|
|
|
|
<input type="file" class="hidden" ref=fileSelector @change="uploadFiles" multiple />
|
2022-07-12 16:43:01 +08:00
|
|
|
<div class="title btn btn-light" @click="$refs.fileSelector.click()" tabindex="0" @keyup.enter="$refs.fileSelector.click()">
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-import"></i>
|
2022-05-18 17:12:53 +08:00
|
|
|
{{ i18n.t("protocols.steps.attachments.file_modal.drag_zone_title") }}
|
|
|
|
</div>
|
|
|
|
<div class="description">
|
|
|
|
{{ i18n.t("protocols.steps.attachments.file_modal.drag_zone_description") }}
|
|
|
|
</div>
|
2022-05-26 20:48:57 +08:00
|
|
|
<StorageUsage v-if="step.attributes.storage_limit" :step="step"/>
|
2022-05-18 17:12:53 +08:00
|
|
|
<div class="available-storage"></div>
|
|
|
|
<div class="drop-notification">
|
|
|
|
{{ i18n.t("protocols.steps.attachments.file_modal.drag_zone_notification", {position: step.attributes.position + 1}) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-17 15:33:20 +08:00
|
|
|
<div class="divider" v-if="step.attributes.marvinjs_enabled || step.attributes.wopi_enabled || step.attributes.open_vector_editor_context.new_sequence_asset_url">
|
2022-05-18 17:12:53 +08:00
|
|
|
{{ i18n.t("protocols.steps.attachments.file_modal.or") }}
|
|
|
|
</div>
|
|
|
|
<div class="integrations-container">
|
2022-07-28 15:56:09 +08:00
|
|
|
<div class="integration-block wopi" v-if="step.attributes.wopi_enabled">
|
|
|
|
<a @click="openWopiFileModal" class="create-wopi-file-btn btn btn-light" tabindex="0" @keyup.enter="openWopiFileModal">
|
|
|
|
<img :src="step.attributes.wopi_context.icon"/>
|
|
|
|
{{ i18n.t('assets.create_wopi_file.button_text') }}
|
|
|
|
</a>
|
|
|
|
</div>
|
2023-08-17 15:33:20 +08:00
|
|
|
<div class="integration-block" v-if="step.attributes.open_vector_editor_context.new_sequence_asset_url">
|
|
|
|
<a @click="openOVEditor" class="open-vector-editor-button btn btn-light">
|
|
|
|
<img :src="step.attributes.open_vector_editor_context.icon"/>
|
|
|
|
{{ i18n.t('open_vector_editor.new_sequence') }}
|
|
|
|
</a>
|
|
|
|
</div>
|
2022-05-18 17:12:53 +08:00
|
|
|
<div class="integration-block marvinjs" v-if="step.attributes.marvinjs_enabled">
|
|
|
|
<a
|
|
|
|
class="new-marvinjs-upload-button btn btn-light"
|
|
|
|
:data-object-id="step.id"
|
2023-09-29 21:35:33 +08:00
|
|
|
:data-marvin-url="step.attributes.marvinjs_context?.marvin_js_asset_url"
|
2022-05-18 17:12:53 +08:00
|
|
|
data-object-type="Step"
|
2022-05-24 17:30:15 +08:00
|
|
|
@click="openMarvinJsModal"
|
2022-07-06 20:31:55 +08:00
|
|
|
tabindex="0"
|
|
|
|
@keyup.enter="openMarvinJsModal"
|
2022-05-18 17:12:53 +08:00
|
|
|
>
|
|
|
|
<span class="new-marvinjs-upload-icon">
|
|
|
|
<img :src="step.attributes.marvinjs_context.icon"/>
|
|
|
|
</span>
|
2023-08-17 15:33:20 +08:00
|
|
|
{{ i18n.t('marvinjs.new_li_button') }}
|
2022-05-18 17:12:53 +08:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
2023-06-19 21:45:22 +08:00
|
|
|
<button type='button' class='btn btn-secondary' @click="cancel">
|
2022-05-18 17:12:53 +08:00
|
|
|
{{ i18n.t('general.cancel') }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-05-26 20:48:57 +08:00
|
|
|
import StorageUsage from '../storage_usage.vue'
|
|
|
|
|
2022-08-01 19:14:04 +08:00
|
|
|
import WopiFileModal from './mixins/wopi_file_modal.js'
|
|
|
|
|
2022-05-18 17:12:53 +08:00
|
|
|
export default {
|
|
|
|
name: 'fileModal',
|
|
|
|
props: {
|
|
|
|
step: Object
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-08-01 19:14:04 +08:00
|
|
|
dragingFile: false,
|
|
|
|
attachmentsChanged: false
|
2022-05-18 17:12:53 +08:00
|
|
|
}
|
|
|
|
},
|
2022-05-26 20:48:57 +08:00
|
|
|
components: {StorageUsage},
|
2022-08-01 19:14:04 +08:00
|
|
|
mixins: [WopiFileModal],
|
2022-05-18 17:12:53 +08:00
|
|
|
mounted() {
|
|
|
|
$(this.$refs.modal).modal('show');
|
2022-07-21 20:28:21 +08:00
|
|
|
MarvinJsEditor.initNewButton('.add-file-modal .new-marvinjs-upload-button', () => {
|
2022-08-01 19:14:04 +08:00
|
|
|
this.attachmentsChanged = true;
|
|
|
|
$(this.$refs.modal).modal('hide');
|
2022-05-24 17:30:15 +08:00
|
|
|
});
|
2022-06-22 00:20:52 +08:00
|
|
|
$(this.$refs.modal).on('hidden.bs.modal', () => {
|
2022-07-06 17:43:30 +08:00
|
|
|
global.removeEventListener('paste', this.onImageFilePaste, false);
|
2022-08-01 19:14:04 +08:00
|
|
|
|
|
|
|
if (this.attachmentsChanged) {
|
|
|
|
this.$emit('attachmentsChanged');
|
|
|
|
} else {
|
|
|
|
this.cancel();
|
|
|
|
}
|
2022-06-22 00:20:52 +08:00
|
|
|
});
|
2022-07-06 17:43:30 +08:00
|
|
|
global.addEventListener('paste', this.onImageFilePaste, false);
|
2022-05-18 17:12:53 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cancel() {
|
2022-08-05 16:46:14 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2022-08-01 19:14:04 +08:00
|
|
|
this.$nextTick(() => this.$emit('cancel'));
|
2022-05-18 17:12:53 +08:00
|
|
|
},
|
2022-07-06 17:43:30 +08:00
|
|
|
onImageFilePaste (pasteEvent) {
|
|
|
|
if (pasteEvent.clipboardData !== false) {
|
|
|
|
let items = pasteEvent.clipboardData.items
|
|
|
|
for (let i = 0; i < items.length; i += 1) {
|
|
|
|
if (items[i].type.indexOf('image') !== -1) {
|
|
|
|
this.$emit('copyPasteImageModal', items[i]);
|
|
|
|
$(this.$refs.modal).modal('hide');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-05-18 17:12:53 +08:00
|
|
|
dropFile(e) {
|
2022-07-12 21:24:12 +08:00
|
|
|
e.stopPropagation();
|
2022-05-18 17:12:53 +08:00
|
|
|
if (e.dataTransfer && e.dataTransfer.files.length) {
|
|
|
|
this.$emit('files', e.dataTransfer.files);
|
2022-08-01 19:14:04 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2022-05-18 17:12:53 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
uploadFiles() {
|
2022-05-19 14:51:39 +08:00
|
|
|
this.$emit('files', this.$refs.fileSelector.files);
|
2022-08-01 19:14:04 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2023-02-24 17:48:47 +08:00
|
|
|
this.$parent.$parent.$nextTick(() => {
|
|
|
|
this.$parent.$el.scrollIntoView(false)
|
|
|
|
});
|
2022-05-24 17:13:47 +08:00
|
|
|
},
|
2022-05-24 17:30:15 +08:00
|
|
|
openMarvinJsModal() {
|
|
|
|
},
|
2022-05-24 17:13:47 +08:00
|
|
|
openWopiFileModal() {
|
2022-08-01 19:14:04 +08:00
|
|
|
this.initWopiFileModal(this.step, (_e, data, status) => {
|
|
|
|
if (status === 'success') {
|
2022-08-10 20:02:09 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2022-08-01 19:14:04 +08:00
|
|
|
this.$emit('attachmentUploaded', data);
|
|
|
|
} else {
|
|
|
|
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
2022-05-24 17:13:47 +08:00
|
|
|
}
|
2022-08-01 19:14:04 +08:00
|
|
|
});
|
2023-08-02 20:13:04 +08:00
|
|
|
},
|
|
|
|
openOVEditor() {
|
|
|
|
$(this.$refs.modal).modal('hide');
|
2023-08-17 15:33:20 +08:00
|
|
|
window.showIFrameModal(this.step.attributes.open_vector_editor_context.new_sequence_asset_url);
|
2022-05-18 17:12:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|