2023-12-28 03:09:36 +08:00
|
|
|
<template>
|
|
|
|
<div ref="modal" class="modal" tabindex="-1" role="dialog">
|
|
|
|
<div class="modal-dialog" role="document">
|
2024-03-06 18:49:51 +08:00
|
|
|
<div class="modal-content ">
|
2023-12-28 03:09:36 +08:00
|
|
|
<div class="modal-header">
|
2024-03-12 21:13:13 +08:00
|
|
|
<button type="button" class="close self-start" data-dismiss="modal" aria-label="Close">
|
2023-12-28 03:09:36 +08:00
|
|
|
<i class="sn-icon sn-icon-close"></i>
|
|
|
|
</button>
|
2024-03-12 21:13:13 +08:00
|
|
|
<h4 class="modal-title line-clamp-3" style="display: -webkit-box;">
|
2023-12-28 03:09:36 +08:00
|
|
|
{{ i18n.t('protocols.index.linked_children.title', { protocol: protocol.name }) }}
|
|
|
|
</h4>
|
|
|
|
</div>
|
2024-03-12 21:13:13 +08:00
|
|
|
<div class="modal-body gap-6">
|
|
|
|
<div class="flex items-center gap-4 mb-6">
|
|
|
|
{{ i18n.t("protocols.index.linked_children.show_version") }}
|
|
|
|
<div class="w-48 mr-auto">
|
|
|
|
<SelectDropdown
|
|
|
|
:options="versionsList"
|
|
|
|
:value="selectedVersion"
|
|
|
|
@change="changeSelectedVersion"
|
|
|
|
></SelectDropdown>
|
2023-12-28 03:09:36 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-12 21:13:13 +08:00
|
|
|
<hr />
|
|
|
|
<perfect-scrollbar
|
|
|
|
class="max-h-96 relative flex flex-col gap-6 pr-8"
|
|
|
|
@ps-scroll-y="onScroll" ref="linkedMyModules">
|
|
|
|
<div v-for="(myModule, idx) in linkedMyModules" class="flex items-center gap-1 flex-wrap w-full">
|
|
|
|
<div v-if="myModule.project_folder_name" class="flex items-center ">
|
|
|
|
<a :href="myModule.project_folder_url"
|
|
|
|
:title="myModule.project_folder_name"
|
|
|
|
class="hover:no-underline flex items-center shrink-0 gap-1 ">
|
|
|
|
<i class="sn-icon sn-icon-mini-folder-left"></i>
|
|
|
|
<span class="truncate max-w-[200px]">{{ myModule.project_folder_name }}</span>
|
|
|
|
</a>
|
|
|
|
<i class="sn-icon sn-icon-right"></i>
|
|
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<a :href="myModule.project_url"
|
|
|
|
:title="myModule.project_name"
|
|
|
|
class="hover:no-underline flex items-center shrink-0 gap-1">
|
|
|
|
<i class="sn-icon sn-icon-projects"></i>
|
|
|
|
<span class="truncate max-w-[200px]">{{ myModule.project_name }}</span>
|
|
|
|
</a>
|
|
|
|
<i class="sn-icon sn-icon-right"></i>
|
|
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<a :href="myModule.experiment_url"
|
|
|
|
:title="myModule.experiment_name"
|
|
|
|
class="hover:no-underline flex items-center shrink-0 gap-1">
|
|
|
|
<i class="sn-icon sn-icon-experiment"></i>
|
|
|
|
<span class="truncate max-w-[200px]">{{ myModule.experiment_name }}</span>
|
|
|
|
</a>
|
|
|
|
<i class="sn-icon sn-icon-right"></i>
|
|
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<a :href="myModule.my_module_url"
|
|
|
|
:title="myModule.my_module_name"
|
|
|
|
class="hover:no-underline flex items-center shrink-0 gap-1 ">
|
|
|
|
<i class="sn-icon sn-icon-task"></i>
|
|
|
|
<span class="truncate max-w-[200px]">{{ myModule.my_module_name }}</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="idx !== linkedMyModules.length - 1" class="sci-divider mt-6"></div>
|
|
|
|
</div>
|
|
|
|
</perfect-scrollbar>
|
2023-12-28 03:09:36 +08:00
|
|
|
</div>
|
2024-03-12 21:13:13 +08:00
|
|
|
<div class="modal-footer">
|
2023-12-28 03:09:36 +08:00
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import SelectDropdown from '../../shared/select_dropdown.vue';
|
|
|
|
import axios from '../../../packs/custom_axios.js';
|
|
|
|
import modalMixin from '../../shared/modal_mixin';
|
2024-02-29 19:34:17 +08:00
|
|
|
import Pagination from '../../shared/datatable/pagination.vue';
|
2023-12-28 03:09:36 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'NewProtocolModal',
|
|
|
|
props: {
|
|
|
|
protocol: Object
|
|
|
|
},
|
|
|
|
mixins: [modalMixin],
|
|
|
|
components: {
|
2024-02-29 19:34:17 +08:00
|
|
|
SelectDropdown,
|
|
|
|
Pagination
|
2023-12-28 03:09:36 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
linkedMyModules: [],
|
|
|
|
versionsList: [],
|
2024-02-29 19:34:17 +08:00
|
|
|
selectedVersion: 'All',
|
2024-03-12 21:13:13 +08:00
|
|
|
nextPage: null
|
2023-12-28 03:09:36 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadLinkedMyModules();
|
|
|
|
this.loadVersions();
|
|
|
|
},
|
|
|
|
methods: {
|
2024-03-12 21:13:13 +08:00
|
|
|
loadLinkedMyModules(myModules = []) {
|
|
|
|
const urlParams = { page: this.nextPage || 1 };
|
2023-12-28 03:09:36 +08:00
|
|
|
if (this.selectedVersion !== 'All') {
|
|
|
|
urlParams.version = this.selectedVersion;
|
|
|
|
}
|
|
|
|
axios.get(this.protocol.urls.linked_my_modules, { params: urlParams })
|
|
|
|
.then((response) => {
|
2024-03-12 21:13:13 +08:00
|
|
|
this.linkedMyModules = myModules.concat(response.data.data);
|
|
|
|
this.nextPage = response.data.next_page;
|
2023-12-28 03:09:36 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
loadVersions() {
|
|
|
|
axios.get(this.protocol.urls.versions_list)
|
|
|
|
.then((response) => {
|
|
|
|
this.versionsList = [['All', 'All']].concat(response.data.versions.map((version) => [version, version]));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
changeSelectedVersion(version) {
|
|
|
|
this.selectedVersion = version;
|
2024-03-12 21:13:13 +08:00
|
|
|
this.nextPage = null;
|
2024-02-29 19:34:17 +08:00
|
|
|
this.loadLinkedMyModules();
|
|
|
|
},
|
2024-03-12 21:13:13 +08:00
|
|
|
onScroll() {
|
|
|
|
const scrollObj = this.$refs.linkedMyModules.ps;
|
|
|
|
|
|
|
|
if (scrollObj) {
|
|
|
|
const reachedEnd = scrollObj.reach.y === 'end';
|
|
|
|
if (reachedEnd && this.contentHeight !== scrollObj.contentHeight) {
|
|
|
|
this.contentHeight = scrollObj.contentHeight;
|
|
|
|
if (this.nextPage) this.loadLinkedMyModules(this.linkedMyModules);
|
|
|
|
}
|
|
|
|
}
|
2023-12-28 03:09:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|