mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 23:16:15 +08:00
Add marvinJS integration [SCI-6831] (#4113)
This commit is contained in:
parent
6c797f5825
commit
c33b426c03
|
@ -167,6 +167,8 @@ var MarvinJsEditorApi = (function() {
|
||||||
}
|
}
|
||||||
$(marvinJsModal).modal('hide');
|
$(marvinJsModal).modal('hide');
|
||||||
config.button.dataset.inProgress = false;
|
config.button.dataset.inProgress = false;
|
||||||
|
|
||||||
|
if (MarvinJsEditor.saveCallback) MarvinJsEditor.saveCallback();
|
||||||
}).error((response) => {
|
}).error((response) => {
|
||||||
if (response.status === 403) {
|
if (response.status === 403) {
|
||||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||||
|
@ -250,7 +252,7 @@ var MarvinJsEditorApi = (function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
initNewButton: function(selector) {
|
initNewButton: function(selector, saveCallback) {
|
||||||
$(selector).off('click').on('click', function() {
|
$(selector).off('click').on('click', function() {
|
||||||
var objectId = this.dataset.objectId;
|
var objectId = this.dataset.objectId;
|
||||||
var objectType = this.dataset.objectType;
|
var objectType = this.dataset.objectType;
|
||||||
|
@ -264,6 +266,8 @@ var MarvinJsEditorApi = (function() {
|
||||||
container: container
|
container: container
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MarvinJsEditor.saveCallback = saveCallback;
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function(config) {
|
save: function(config) {
|
||||||
|
|
|
@ -71,7 +71,13 @@
|
||||||
@attachment:viewMode="updateAttachmentViewMode"/>
|
@attachment:viewMode="updateAttachmentViewMode"/>
|
||||||
</div>
|
</div>
|
||||||
<deleteStepModal v-if="confirmingDelete" @confirm="deleteStep" @cancel="closeDeleteModal"/>
|
<deleteStepModal v-if="confirmingDelete" @confirm="deleteStep" @cancel="closeDeleteModal"/>
|
||||||
<fileModal v-if="showFileModal" @cancel="showFileModal = false" :step="step" @files="uploadFiles" @attachmentUploaded="addAttachment" />
|
<fileModal v-if="showFileModal"
|
||||||
|
:step="step"
|
||||||
|
@cancel="showFileModal = false"
|
||||||
|
@files="uploadFiles"
|
||||||
|
@attachmentUploaded="addAttachment"
|
||||||
|
@attachmentsChanged="loadAttachments"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -112,15 +118,20 @@
|
||||||
Attachments
|
Attachments
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
$.get(this.step.attributes.urls.elements_url, (result) => {
|
this.loadAttachments();
|
||||||
this.elements = result.data
|
this.loadElements();
|
||||||
});
|
|
||||||
|
|
||||||
$.get(this.step.attributes.urls.attachments_url, (result) => {
|
|
||||||
this.attachments = result.data
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
loadAttachments() {
|
||||||
|
$.get(this.step.attributes.urls.attachments_url, (result) => {
|
||||||
|
this.attachments = result.data
|
||||||
|
});
|
||||||
|
},
|
||||||
|
loadElements() {
|
||||||
|
$.get(this.step.attributes.urls.elements_url, (result) => {
|
||||||
|
this.elements = result.data
|
||||||
|
});
|
||||||
|
},
|
||||||
showDeleteModal() {
|
showDeleteModal() {
|
||||||
this.confirmingDelete = true;
|
this.confirmingDelete = true;
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
:data-sketch-name="attachment.attributes.metadata.name"
|
:data-sketch-name="attachment.attributes.metadata.name"
|
||||||
:data-sketch-description="attachment.attributes.metadata.description"
|
:data-sketch-description="attachment.attributes.metadata.description"
|
||||||
>
|
>
|
||||||
<img :src="attachment.attributes.url.marvin_js_icon"/>
|
<img :src="attachment.attributes.urls.marvin_js_icon"/>
|
||||||
{{ i18n.t('assets.file_preview.edit_in_marvinjs') }}
|
{{ i18n.t('assets.file_preview.edit_in_marvinjs') }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="modal" @keydown.esc="cancel"
|
<div ref="modal" @keydown.esc="cancel"
|
||||||
class="modal add-file-modal"
|
class="modal add-file-modal"
|
||||||
:class="dragingFile ? 'draging-file' : ''"
|
:class="{ 'draging-file' : dragingFile }"
|
||||||
role="dialog" aria-hidden="true" tabindex="-1">
|
role="dialog" aria-hidden="true" tabindex="-1">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -41,7 +41,9 @@
|
||||||
<a
|
<a
|
||||||
class="new-marvinjs-upload-button btn btn-light"
|
class="new-marvinjs-upload-button btn btn-light"
|
||||||
:data-object-id="step.id"
|
:data-object-id="step.id"
|
||||||
|
:data-marvin-url="step.attributes.marvinjs_context.marvin_js_asset_url"
|
||||||
data-object-type="Step"
|
data-object-type="Step"
|
||||||
|
@click="openMarvinJsModal"
|
||||||
>
|
>
|
||||||
<span class="new-marvinjs-upload-icon">
|
<span class="new-marvinjs-upload-icon">
|
||||||
<img :src="step.attributes.marvinjs_context.icon"/>
|
<img :src="step.attributes.marvinjs_context.icon"/>
|
||||||
|
@ -79,6 +81,10 @@
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
$(this.$refs.modal).modal('show');
|
$(this.$refs.modal).modal('show');
|
||||||
|
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button', () => {
|
||||||
|
this.$emit('attachmentsChanged');
|
||||||
|
this.$nextTick(this.cancel);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
cancel() {
|
cancel() {
|
||||||
|
@ -95,6 +101,10 @@
|
||||||
$(this.$refs.modal).modal('hide');
|
$(this.$refs.modal).modal('hide');
|
||||||
this.$emit('files', this.$refs.fileSelector.files);
|
this.$emit('files', this.$refs.fileSelector.files);
|
||||||
},
|
},
|
||||||
|
openMarvinJsModal() {
|
||||||
|
// hide regular file modal
|
||||||
|
$(this.$refs.modal).modal('hide');
|
||||||
|
},
|
||||||
openWopiFileModal() {
|
openWopiFileModal() {
|
||||||
// hide regular file modal
|
// hide regular file modal
|
||||||
$(this.$refs.modal).modal('hide');
|
$(this.$refs.modal).modal('hide');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class StepSerializer < ActiveModel::Serializer
|
class StepSerializer < ActiveModel::Serializer
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
@ -12,6 +14,7 @@ class StepSerializer < ActiveModel::Serializer
|
||||||
def marvinjs_context
|
def marvinjs_context
|
||||||
if marvinjs_enabled
|
if marvinjs_enabled
|
||||||
{
|
{
|
||||||
|
marvin_js_asset_url: marvin_js_assets_path,
|
||||||
icon: image_path('icon_small/marvinjs.svg')
|
icon: image_path('icon_small/marvinjs.svg')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue