Add Teleport for modals [SCI-9862]

This commit is contained in:
Ivan Kljun 2024-01-05 10:50:39 +01:00
parent 53c9be6f21
commit 44556f5070
3 changed files with 35 additions and 33 deletions

View file

@ -30,34 +30,36 @@
@open_ove_editor="openOVEditor(attachment.attributes.urls.open_vector_editor_edit)"
@open_marvinjs_editor="openMarvinJsEditor"
@open_scinote_editor="openScinoteEditor"
@open_locally="openLocallyButton"
@open_locally="openLocally"
@delete="deleteModal = true"
@viewMode="changeViewMode"
@move="showMoveModal"
></MenuDropdown>
<deleteAttachmentModal
v-if="deleteModal"
:fileName="attachment.attributes.file_name"
@confirm="deleteAttachment"
@cancel="deleteModal = false"
/>
<moveAssetModal
v-if="movingAttachment"
:parent_type="attachment.attributes.parent_type"
:targets_url="attachment.attributes.urls.move_targets"
@confirm="moveAttachment($event)" @cancel="closeMoveModal"
/>
<NoPredefinedAppModal
v-if="showNoPredefinedAppModal"
:fileName="attachment.attributes.file_name"
@confirm="showNoPredefinedAppModal = false"
/>
<editLaunchingApplicationModal
v-if="editAppModal"
<Teleport to="body">
<deleteAttachmentModal
v-if="deleteModal"
:fileName="attachment.attributes.file_name"
:application="this.localAppName"
@cancel="editAppModal = false"
/>
@confirm="deleteAttachment"
@cancel="deleteModal = false"
/>
<moveAssetModal
v-if="movingAttachment"
:parent_type="attachment.attributes.parent_type"
:targets_url="attachment.attributes.urls.move_targets"
@confirm="moveAttachment($event)" @cancel="closeMoveModal"
/>
<NoPredefinedAppModal
v-if="showNoPredefinedAppModal"
:fileName="attachment.attributes.file_name"
@confirm="showNoPredefinedAppModal = false"
/>
<editLaunchingApplicationModal
v-if="editAppModal"
:fileName="attachment.attributes.file_name"
:application="this.localAppName"
@cancel="editAppModal = false"
/>
</Teleport>
</div>
</template>
@ -193,10 +195,6 @@ export default {
);
$(this.$refs.marvinjsEditButton).trigger('click');
},
openLocallyButton() {
this.editAppModal = true;
this.$emit(this.openLocally());
},
openScinoteEditor() {
$(this.$refs.imageEditButton).trigger('click');
}

View file

@ -39,20 +39,21 @@ export default {
this.localAppName = response.data.application;
} catch (error) {
console.error("Error in request: ", error);
console.error('Error in request: ', error);
}
},
async openLocally() {
if (this.localAppName === null) {
this.showNoPredefinedAppModal = true;
return
this.showNoPredefinedAppModal = true;
return;
}
this.editAppModal = true;
try {
const response = await axios.get(this.attachment.attributes.urls.open_locally);
const data = response.data;
const { data } = await axios.get(this.attachment.attributes.urls.open_locally);
await axios.post(this.attachment.attributes.urls.open_locally_api + '/download', data);
} catch (error) {
console.error("Error in request:", error);
console.error('Error in request:', error);
}
}
}

View file

@ -3566,6 +3566,9 @@ en:
body_text_html: "The specified application for accessing the <b>%{file_name}</b> is not preconfigured. To successfully open this file, please set up the appropriate application in your local environment beforehand.</p>"
no_predefined_app: "I understand"
set_up_app: "Set up an application to open this file"
edit_launching_application_modal:
title: "Launching application"
description: "%{file_name} will now open in %{application}. Saved changes in %{application} will automatically be synced in SciNote."
atwho:
no_results: