scinote-web/app/javascript/vue/experiments/card.vue

102 lines
3.7 KiB
Vue
Raw Normal View History

2023-12-11 22:41:03 +08:00
<template>
<div class="px-3 pt-3 pb-4 rounded border-solid border border-sn-gray flex flex-col"
:class="{ 'bg-sn-light-grey': dtComponent.currentViewMode === 'archived', [cardMinWidth]: true}">
2024-03-01 20:37:31 +08:00
<div class="flex items-center gap-4 mb-2">
2023-12-11 22:41:03 +08:00
<div class="sci-checkbox-container">
<input
type="checkbox"
class="sci-checkbox"
2024-04-01 19:53:45 +08:00
:checked="cardSelected"
2023-12-11 22:41:03 +08:00
@change="itemSelected"
/>
<label :for="params.id" class="sci-checkbox-label"></label>
</div>
<div>{{ params.code }}</div>
<RowMenuRenderer :params="{data: params, dtComponent: dtComponent}" class="ml-auto"/>
</div>
<a :href="params.urls.show"
2024-03-01 20:37:31 +08:00
:title="params.name"
2023-12-11 22:41:03 +08:00
:class="{'pointer-events-none text-sn-grey': !params.urls.show}"
class="font-bold mb-4 shrink-0 text-sn-blue hover:no-underline line-clamp-2 hover:text-sn-blue h-10">
2023-12-11 22:41:03 +08:00
{{ params.name }}
</a>
2024-03-01 20:37:31 +08:00
<div class="flex gap-4 mb-2.5">
2024-03-16 11:51:32 +08:00
<div class="grid grow gap-x-2 gap-y-3 grid-cols-[90px_auto] mt-auto text-xs">
2024-03-01 20:37:31 +08:00
<span class="text-sn-dark-grey">{{ i18n.t('experiments.card.start_date') }}</span>
2023-12-11 22:41:03 +08:00
<span class="font-bold">{{ params.created_at }}</span>
<template v-if="dtComponent.currentViewMode == 'archived'">
2024-03-01 20:37:31 +08:00
<span class="text-sn-dark-grey">{{ i18n.t('experiments.card.archived_date') }}</span>
2023-12-11 22:41:03 +08:00
<span class="font-bold">{{ params.archived_on }}</span>
</template>
2024-03-01 20:37:31 +08:00
<template v-else>
<span class="text-sn-dark-grey">{{ i18n.t('experiments.card.modified_date') }}</span>
<span class="font-bold">{{ params.updated_at }}</span>
</template>
2023-12-11 22:41:03 +08:00
2024-03-01 20:37:31 +08:00
<span class="text-sn-dark-grey">{{ i18n.t('experiments.card.completed_task') }}</span>
<div class="w-full">
<span class="font-bold">{{ i18n.t(
'experiments.card.completed_value', {
completed: params.completed_tasks,
all: params.total_tasks
}
) }}</span>
<div class="w-full h-1 bg-sn-sleepy-grey">
<div class="h-full"
:class="{
'bg-sn-black': params.archived_on,
'bg-sn-blue': !params.archived_on
2024-03-01 20:37:31 +08:00
}"
:style="{
width: `${progress}%`
2024-03-01 20:37:31 +08:00
}"></div>
</div>
</div>
2023-12-11 22:41:03 +08:00
</div>
2024-03-01 20:37:31 +08:00
<div class="h-20 w-20 p-0.5 bg-sn-sleepy-grey rounded-sm shrink-0 ml-auto relative">
2024-01-23 22:20:12 +08:00
<div v-if="imageLoading" class="flex absolute top-0 items-center justify-center w-full flex-grow h-full z-10">
<img src="/images/medium/loading.svg" alt="Loading" />
</div>
2024-03-04 18:07:15 +08:00
<img v-else-if="!hasError" :src="workflow_img" @error="hasError = true" class="max-h-full max-w-full">
2023-12-11 22:41:03 +08:00
</div>
</div>
<Description :params="{data: params, value: params.description, dtComponent: dtComponent}" />
</div>
</template>
<script>
/* global GLOBAL_CONSTANTS */
2023-12-11 22:41:03 +08:00
import RowMenuRenderer from '../shared/datatable/row_menu_renderer.vue';
import CardSelectorMixin from '../shared/datatable/mixins/card_selector.js';
2024-01-23 22:20:12 +08:00
import workflowImgMixin from './workflow_img_mixin.js';
2023-12-11 22:41:03 +08:00
import Description from './renderers/description.vue';
export default {
name: 'ProjectCard',
props: {
params: Object,
dtComponent: Object,
},
components: {
RowMenuRenderer,
Description,
},
2024-01-23 22:20:12 +08:00
mixins: [CardSelectorMixin, workflowImgMixin],
computed: {
progress() {
const { completed_tasks: completedTasks, total_tasks: totalTasks } = this.params;
if (totalTasks === 0) return 0;
return (completedTasks / totalTasks) * 100;
},
cardMinWidth() {
2024-03-16 11:51:32 +08:00
return `min-w-[${GLOBAL_CONSTANTS.TABLE_CARD_MIN_WIDTH}px]`;
}
}
2023-12-11 22:41:03 +08:00
};
</script>