Merge pull request #7881 from aignatov-bio/ai-sci-11082-add-descripiton-modal-to-storage-location

Add description modal to storage locations [SCI-11082]
This commit is contained in:
aignatov-bio 2024-09-25 11:29:47 +02:00 committed by GitHub
commit 677b199bfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 6 deletions

View file

@ -0,0 +1,35 @@
<template>
<div ref="modal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<i class="sn-icon sn-icon-close"></i>
</button>
<h4 class="modal-title truncate !block" id="edit-project-modal-label" :title="experiment.name">
{{ experiment.name }}
</h4>
</div>
<div class="modal-body">
<div class="[&_.atwho-user-container]:!whitespace-normal whitespace-pre-wrap" v-html="experiment.sa_description"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ i18n.t('general.close') }}</button>
</div>
</div>
</div>
</div>
</template>
<script>
import modalMixin from '../../shared/modal_mixin';
export default {
name: 'DescriptionModal',
props: {
experiment: Object
},
mixins: [modalMixin]
};
</script>

View file

@ -1,5 +1,15 @@
<template> <template>
<div v-html="params.data.sa_description"></div> <div v-if="params.data.sa_description" class="group relative flex items-center group-hover:marker text-xs h-full w-full leading-[unset]">
<div class="flex gap-2 w-full items-center text-sm leading-[unset]">
<span class="cursor-pointer line-clamp-1 leading-[unset]"
@click.stop="showDescriptionModal"
v-html="params.data.sa_description">
</span>
<span @click.stop="showDescriptionModal" class="text-sn-blue cursor-pointer shrink-0 inline-block text-sm">
{{ i18n.t('experiments.card.more') }}
</span>
</div>
</div>
</template> </template>
<script> <script>
@ -7,9 +17,18 @@ export default {
name: 'DescriptionRenderer', name: 'DescriptionRenderer',
props: { props: {
params: { params: {
type: Object,
required: true required: true
} }
},
computed: {
shouldTruncateText() {
return this.params.data.description?.length > 60;
}
},
methods: {
showDescriptionModal() {
this.params.dtComponent.$emit('showDescription', null, [this.params.data]);
}
} }
}; };
</script> </script>

View file

@ -13,6 +13,7 @@
@duplicate="duplicate" @duplicate="duplicate"
@tableReloaded="reloadingTable = false" @tableReloaded="reloadingTable = false"
@move="move" @move="move"
@showDescription="showDescription"
@delete="deleteStorageLocation" @delete="deleteStorageLocation"
@share="share" @share="share"
/> />
@ -25,6 +26,10 @@
:directUploadUrl="directUploadUrl" :directUploadUrl="directUploadUrl"
:editStorageLocation="editStorageLocation" :editStorageLocation="editStorageLocation"
/> />
<DescriptionModal
v-if="descriptionModalObject"
:experiment="descriptionModalObject"
@close="descriptionModalObject = null"/>
<MoveModal v-if="objectToMove" :moveToUrl="moveToUrl" <MoveModal v-if="objectToMove" :moveToUrl="moveToUrl"
:selectedObject="objectToMove" :selectedObject="objectToMove"
@close="objectToMove = null" @move="updateTable()" /> @close="objectToMove = null" @move="updateTable()" />
@ -52,6 +57,7 @@ import DataTable from '../shared/datatable/table.vue';
import EditModal from './modals/new_edit.vue'; import EditModal from './modals/new_edit.vue';
import MoveModal from './modals/move.vue'; import MoveModal from './modals/move.vue';
import ConfirmationModal from '../shared/confirmation_modal.vue'; import ConfirmationModal from '../shared/confirmation_modal.vue';
import DescriptionModal from './modals/description.vue';
import ShareObjectModal from '../shared/share_modal.vue'; import ShareObjectModal from '../shared/share_modal.vue';
import DescriptionRenderer from './renderers/description.vue'; import DescriptionRenderer from './renderers/description.vue';
import NameRenderer from './renderers/storage_name_renderer.vue'; import NameRenderer from './renderers/storage_name_renderer.vue';
@ -65,7 +71,8 @@ export default {
ConfirmationModal, ConfirmationModal,
ShareObjectModal, ShareObjectModal,
DescriptionRenderer, DescriptionRenderer,
NameRenderer NameRenderer,
DescriptionModal
}, },
props: { props: {
dataSource: { dataSource: {
@ -96,7 +103,8 @@ export default {
moveToUrl: null, moveToUrl: null,
shareStorageLocation: null, shareStorageLocation: null,
storageLocationDeleteTitle: '', storageLocationDeleteTitle: '',
storageLocationDeleteDescription: '' storageLocationDeleteDescription: '',
descriptionModalObject: null
}; };
}, },
computed: { computed: {
@ -143,8 +151,10 @@ export default {
field: 'sa_description', field: 'sa_description',
headerName: this.i18n.t('storage_locations.index.table.description'), headerName: this.i18n.t('storage_locations.index.table.description'),
sortable: false, sortable: false,
notSelectable: true, cellStyle: { 'white-space': 'normal' },
cellRenderer: 'DescriptionRenderer' cellRenderer: DescriptionRenderer,
autoHeight: true,
minWidth: 110
}]; }];
return columns; return columns;
@ -254,6 +264,9 @@ export default {
}); });
} }
}, },
showDescription(_e, storageLocation) {
[this.descriptionModalObject] = storageLocation;
},
share(_event, rows) { share(_event, rows) {
const [storageLocation] = rows; const [storageLocation] = rows;
this.shareStorageLocation = storageLocation; this.shareStorageLocation = storageLocation;