salix-front/src/components/ui/CardDescriptor.vue

103 lines
2.9 KiB
Vue
Raw Normal View History

2022-11-08 06:41:36 +00:00
<script setup>
2022-11-08 12:36:22 +00:00
import { useSlots } from 'vue';
2022-11-08 06:41:36 +00:00
import { useI18n } from 'vue-i18n';
defineProps({
2022-11-08 12:36:22 +00:00
module: {
type: String,
required: true,
},
2022-11-08 06:41:36 +00:00
data: {
type: Object,
required: true,
},
2022-11-08 12:36:22 +00:00
description: {
type: String,
required: true,
},
2022-11-08 06:41:36 +00:00
});
const slots = useSlots();
const { t } = useI18n();
</script>
<template>
<div class="descriptor">
<div class="header bg-primary q-pa-sm">
2022-11-08 12:36:22 +00:00
<router-link :to="{ name: `${module}List` }">
2022-11-08 06:41:36 +00:00
<q-btn round flat dense size="md" icon="view_list" color="white">
2022-11-08 12:36:22 +00:00
<q-tooltip>{{ t('components.cardDescriptor.mainList') }}</q-tooltip>
2022-11-08 06:41:36 +00:00
</q-btn>
</router-link>
2022-11-08 12:36:22 +00:00
<router-link :to="{ name: `${module}Summary`, params: { id: data.id } }">
2022-11-08 06:41:36 +00:00
<q-btn round flat dense size="md" icon="launch" color="white">
2022-11-08 12:36:22 +00:00
<q-tooltip>{{ t('components.cardDescriptor.summary') }}</q-tooltip>
2022-11-08 06:41:36 +00:00
</q-btn>
</router-link>
<q-btn v-if="slots.menu" size="md" icon="more_vert" color="white" round flat dense>
2022-11-08 12:36:22 +00:00
<q-tooltip>{{ t('components.cardDescriptor.moreOptions') }}</q-tooltip>
2022-11-08 06:41:36 +00:00
<q-menu>
<q-list>
<slot name="menu" />
</q-list>
</q-menu>
</q-btn>
</div>
2022-11-08 12:36:22 +00:00
<div v-if="$props.data" class="body q-py-sm">
<q-list>
<q-item-label header class="ellipsis text-h5" :lines="1">
{{ $props.description }}
<q-tooltip>{{ $props.description }}</q-tooltip>
</q-item-label>
<q-item dense>
<q-item-label class="text-subtitle2" caption>#{{ data.id }}</q-item-label>
</q-item>
</q-list>
2022-11-08 06:41:36 +00:00
<slot name="body" />
</div>
<!-- Skeleton -->
<div id="descriptor-skeleton" v-if="!$props.data">
<div class="col q-pl-sm q-pa-sm">
<q-skeleton type="text" square height="45px" />
<q-skeleton type="text" square height="18px" />
<q-skeleton type="text" square height="18px" />
<q-skeleton type="text" square height="18px" />
</div>
<q-card-actions>
<q-skeleton size="40px" />
<q-skeleton size="40px" />
<q-skeleton size="40px" />
<q-skeleton size="40px" />
<q-skeleton size="40px" />
</q-card-actions>
</div>
</div>
</template>
2022-11-08 12:36:22 +00:00
<style lang="scss">
.body {
.q-card__actions {
justify-content: center;
}
.text-h5 {
padding-top: 5px;
padding-bottom: 5px;
}
}
</style>
2022-11-08 06:41:36 +00:00
<style lang="scss" scoped>
.descriptor {
2022-11-08 12:36:22 +00:00
width: 256px;
2022-11-08 06:41:36 +00:00
.header {
display: flex;
justify-content: space-between;
align-items: stretch;
}
}
</style>