2023-09-19 20:38:17 +08:00
|
|
|
<template>
|
2023-09-22 22:08:43 +08:00
|
|
|
<div ref="wrapper"
|
|
|
|
class='bg-white overflow-auto gap-2.5 self-stretch rounded-tl-4 rounded-bl-4 transition-transform ease-in-out transform shadow-lg'
|
2023-10-02 23:00:47 +08:00
|
|
|
:class="{ 'translate-x-0 w-[565px] h-full': isShowing, 'transition-transform ease-in-out duration-400 transform translate-x-0 translate-x-full w-0': !isShowing }">
|
2023-09-22 22:08:43 +08:00
|
|
|
|
|
|
|
<div id="repository-item-sidebar" class="w-full h-full py-6 px-6 bg-white flex flex-col">
|
|
|
|
|
|
|
|
<div id="sticky-header-wrapper">
|
|
|
|
<div class="header flex w-full">
|
|
|
|
<h4 class="item-name my-auto truncate" :title="defaultColumns?.name">
|
|
|
|
{{ !defaultColumns?.archived ? i18n.t('labels.archived') : '' }}
|
|
|
|
{{ defaultColumns?.name }}
|
|
|
|
</h4>
|
|
|
|
<i id="close-icon" @click="toggleShowHideSidebar(currentItemUrl)"
|
|
|
|
class="sn-icon sn-icon-close ml-auto cursor-pointer my-auto mx-0"></i>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="divider" class="flex w-500 bg-sn-light-grey my-6 self-stretch h-px items-center pt-px">
|
|
|
|
</div>
|
2023-09-25 16:49:09 +08:00
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div v-if="dataLoading" class="h-full flex flex-grow-1">
|
|
|
|
<div class="sci-loader"></div>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div v-else id="body-wrapper" class="flex flex-1 flex-grow-1 justify-between">
|
|
|
|
<div id="left-col" class="flex flex-col gap-4">
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- INFORMATION -->
|
|
|
|
<div id="information">
|
|
|
|
<div ref="information-label" id="information-label"
|
|
|
|
class="font-inter text-base font-semibold leading-7 mb-4 transition-colors duration-300">{{
|
|
|
|
i18n.t('repositories.item_card.title.information') }}
|
|
|
|
</div>
|
|
|
|
<div class="item-details">
|
|
|
|
<div class="flex flex-col gap-4">
|
|
|
|
<!-- REPOSITORY NAME -->
|
|
|
|
<div class="flex flex-col ">
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.repository_name') }}</span>
|
|
|
|
<span class="repository-name flex text-sn-dark-grey" :title="repositoryName">
|
|
|
|
{{ repositoryName }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="dashed-divider" class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- CODE -->
|
|
|
|
<div class="flex flex-col ">
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{ i18n.t('repositories.item_card.default_columns.id')
|
|
|
|
}}</span>
|
|
|
|
<span class="inline-block text-sn-dark-grey" :title="defaultColumns?.code">
|
|
|
|
{{ defaultColumns?.code }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="dashed-divider" class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- ADDED ON -->
|
|
|
|
<div class="flex flex-col ">
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.added_on')
|
|
|
|
}}</span>
|
|
|
|
<span class="inline-block text-sn-dark-grey" :title="defaultColumns?.added_on">
|
|
|
|
{{ defaultColumns?.added_on }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="dashed-divider" class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- ADDED BY -->
|
|
|
|
<div class="flex flex-col ">
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.added_by')
|
|
|
|
}}</span>
|
|
|
|
<span class="inline-block text-sn-dark-grey" :title="defaultColumns?.added_by">
|
|
|
|
{{ defaultColumns?.added_by }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
2023-09-22 22:25:09 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex items-center self-stretch h-px "></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- CUSTOM COLUMNS, ASSIGNED, QR CODE -->
|
|
|
|
<div id="custom-col-assigned-qr-wrapper" class="flex flex-col gap-4">
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- CUSTOM COLUMNS -->
|
|
|
|
<div id="custom-columns-wrapper" class="flex flex-col min-h-[64px] h-auto">
|
|
|
|
<div ref="custom-columns-label" id="custom-columns-label"
|
|
|
|
class="font-inter text-base font-semibold leading-7 pb-4 transition-colors duration-300">
|
|
|
|
{{ i18n.t('repositories.item_card.custom_columns_label') }}
|
|
|
|
</div>
|
|
|
|
<div v-if="customColumns?.length > 0" class="flex flex-col gap-4 w-[350px] h-auto">
|
|
|
|
<div v-for="(column, index) in customColumns" class="flex flex-col gap-4 w-[350px] h-auto">
|
|
|
|
<component :is="column.data_type" :key="index" :data_type="column.data_type" :colId="column.id"
|
2023-09-27 15:55:53 +08:00
|
|
|
:colName="column.name" :colVal="column.value" :repositoryRowId="repositoryRowId" :permissions="permissions" />
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="dashed-divider" :class="{ 'hidden': index === customColumns.length - 1 }"
|
|
|
|
class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey">
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
|
|
|
<div v-else class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
|
|
|
|
{{ i18n.t('repositories.item_card.no_custom_columns_label') }}
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- ASSIGNED -->
|
|
|
|
<section id="assigned_wrapper" class="flex flex-col ">
|
|
|
|
<div class="text-base font-semibold w-[350px] my-3 leading-7" ref="assigned-label">
|
|
|
|
{{ i18n.t('repositories.item_card.section.assigned', {
|
|
|
|
count: assignedModules ?
|
|
|
|
assignedModules.total_assigned_size : 0
|
|
|
|
}) }}
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
<div v-if="assignedModules && assignedModules.total_assigned_size > 0">
|
|
|
|
<div v-if="privateModuleSize() > 0" class="pb-6">
|
|
|
|
{{ i18n.t('repositories.item_card.assigned.private', { count: privateModuleSize() }) }}
|
|
|
|
<hr v-if="assignedModules.viewable_modules.length > 0"
|
|
|
|
class="h-1 w-[350px] m-0 mt-6 border-dashed border-1 border-sn-light-grey" />
|
|
|
|
</div>
|
|
|
|
<div v-for="(assigned, index) in assignedModules.viewable_modules" :key="`assigned_module_${index}`"
|
|
|
|
class="flex flex-col w-[350px] mb-6 h-auto">
|
|
|
|
<div class="flex flex-col gap-3">
|
|
|
|
<div v-for="(item, index_assigned) in assigned" :key="`assigned_element_${index_assigned}`">
|
|
|
|
{{ i18n.t(`repositories.item_card.assigned.labels.${item.type}`) }}
|
|
|
|
<a :href="item.url">
|
|
|
|
{{ item.archived ? i18n.t('labels.archived') : '' }} {{ item.value }}
|
|
|
|
</a>
|
|
|
|
</div>
|
2023-09-25 14:29:54 +08:00
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
<hr v-if="index < assignedModules.viewable_modules.length - 1"
|
|
|
|
class="h-1 w-[350px] mt-6 mb-0 border-dashed border-1 border-sn-light-grey" />
|
2023-09-25 14:29:54 +08:00
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
<div v-else class="mb-3">
|
|
|
|
{{ i18n.t('repositories.item_card.assigned.empty') }}
|
|
|
|
</div>
|
|
|
|
</section>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px "></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- QR -->
|
|
|
|
<div id="QR-wrapper" class="block">
|
|
|
|
<div ref="QR-label" id="QR-label"
|
|
|
|
class="font-inter text-base font-semibold leading-7 mb-4 transition-colors duration-300">QR</div>
|
|
|
|
<canvas id="bar-code-canvas" class="hidden" data-id="IT2"></canvas>
|
|
|
|
<img :src="barCodeSrc" />
|
2023-09-22 22:17:42 +08:00
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- NAVIGATION -->
|
|
|
|
<div id="navigation" class="flex item-end gap-x-4 min-w-[130px] h-[130px] sticky top-0 right-0">
|
|
|
|
<scroll-spy :itemsToCreate="[
|
|
|
|
{ id: 'highlight-item-1', textId: 'text-item-1', labelAlias: 'information_label', label: 'information-label' },
|
|
|
|
{ id: 'highlight-item-2', textId: 'text-item-2', labelAlias: 'custom_columns_label', label: 'custom-columns-label' },
|
|
|
|
{ id: 'highlight-item-3', textId: 'text-item-3', labelAlias: 'assigned_label', label: 'assigned-label' },
|
|
|
|
{ id: 'highlight-item-4', textId: 'text-item-4', labelAlias: 'QR_label', label: 'QR-label' }
|
|
|
|
]">
|
|
|
|
</scroll-spy>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-22 22:25:09 +08:00
|
|
|
|
2023-09-22 22:08:43 +08:00
|
|
|
<!-- BOTTOM -->
|
|
|
|
<div id="bottom" class="h-[100px] flex flex-col justify-end" :class="{ 'pb-6': customColumns?.length }">
|
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px mb-6"></div>
|
|
|
|
<div id="bottom-button-wrapper" class="flex h-10 justify-end">
|
|
|
|
<button class="btn btn-primary">Print Label</button>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import RepositoryStockValue from './repository_values/RepositoryStockValue.vue';
|
|
|
|
import RepositoryTextValue from './repository_values/RepositoryTextValue.vue';
|
|
|
|
import RepositoryNumberValue from './repository_values/RepositoryNumberValue.vue';
|
|
|
|
import RepositoryAssetValue from './repository_values/RepositoryAssetValue.vue';
|
|
|
|
import RepositoryListValue from './repository_values/RepositoryListValue.vue';
|
|
|
|
import RepositoryChecklistValue from './repository_values/RepositoryChecklistValue.vue';
|
|
|
|
import RepositoryStatusValue from './repository_values/RepositoryStatusValue.vue';
|
|
|
|
import RepositoryDateTimeValue from './repository_values/RepositoryDateTimeValue.vue';
|
|
|
|
import RepositoryDateTimeRangeValue from './repository_values/RepositoryDateTimeRangeValue.vue';
|
|
|
|
import RepositoryDateValue from './repository_values/RepositoryDateValue.vue';
|
|
|
|
import RepositoryDateRangeValue from './repository_values/RepositoryDateRangeValue.vue';
|
|
|
|
import RepositoryTimeRangeValue from './repository_values/RepositoryTimeRangeValue.vue'
|
2023-09-22 22:25:09 +08:00
|
|
|
import RepositoryTimeValue from './repository_values/RepositoryTimeValue.vue'
|
2023-09-22 22:08:43 +08:00
|
|
|
import ScrollSpy from './repository_values/ScrollSpy.vue';
|
2023-09-19 20:38:17 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'RepositoryItemSidebar',
|
|
|
|
components: {
|
|
|
|
RepositoryStockValue,
|
|
|
|
RepositoryTextValue,
|
|
|
|
RepositoryNumberValue,
|
|
|
|
RepositoryAssetValue,
|
|
|
|
RepositoryListValue,
|
|
|
|
RepositoryChecklistValue,
|
|
|
|
RepositoryStatusValue,
|
|
|
|
RepositoryDateTimeValue,
|
|
|
|
RepositoryDateTimeRangeValue,
|
|
|
|
RepositoryDateValue,
|
|
|
|
RepositoryDateRangeValue,
|
|
|
|
RepositoryTimeRangeValue,
|
2023-09-22 22:08:43 +08:00
|
|
|
RepositoryTimeValue,
|
|
|
|
'scroll-spy': ScrollSpy
|
2023-09-19 20:38:17 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-09-22 22:08:43 +08:00
|
|
|
currentItemUrl: null,
|
|
|
|
dataLoading: false,
|
2023-09-19 20:38:17 +08:00
|
|
|
repositoryName: null,
|
|
|
|
defaultColumns: null,
|
|
|
|
customColumns: null,
|
2023-09-25 14:29:54 +08:00
|
|
|
assignedModules: null,
|
2023-09-19 20:38:17 +08:00
|
|
|
isShowing: false,
|
2023-09-22 22:08:43 +08:00
|
|
|
assigned: 'Assigned to 3 private tasks that will not be displayed',
|
2023-09-27 15:55:53 +08:00
|
|
|
barCodeSrc: null,
|
|
|
|
permissions: null
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
window.repositoryItemSidebarComponent = this;
|
|
|
|
},
|
|
|
|
watch: {
|
2023-09-22 22:08:43 +08:00
|
|
|
defaultColumns(newCol, oldCol) {
|
|
|
|
const canvasEl = document.getElementById('bar-code-canvas')
|
|
|
|
if (newCol.code && bwipjs && canvasEl) {
|
|
|
|
// generate the QR code
|
|
|
|
let barCodeCanvas = bwipjs.toCanvas('bar-code-canvas', {
|
|
|
|
bcid: 'qrcode',
|
|
|
|
text: newCol.code,
|
|
|
|
scale: 3
|
|
|
|
});
|
|
|
|
this.barCodeSrc = barCodeCanvas.toDataURL('image/png')
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
2023-09-22 22:08:43 +08:00
|
|
|
},
|
2023-09-25 16:49:09 +08:00
|
|
|
},
|
2023-09-19 20:38:17 +08:00
|
|
|
beforeDestroy() {
|
|
|
|
delete window.repositoryItemSidebarComponent;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleShowHideSidebar(repositoryRowUrl) {
|
2023-09-22 22:08:43 +08:00
|
|
|
// initial click
|
|
|
|
if (this.currentItemUrl === null) {
|
|
|
|
this.isShowing = true
|
|
|
|
this.loadRepositoryRow(repositoryRowUrl)
|
|
|
|
this.currentItemUrl = repositoryRowUrl
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// click on the same item - should just open/close it
|
|
|
|
else if (this.currentItemUrl === repositoryRowUrl) {
|
|
|
|
this.isShowing = false
|
|
|
|
this.currentItemUrl = null
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// click on a different item - should just fetch new data
|
|
|
|
else {
|
|
|
|
this.loadRepositoryRow(repositoryRowUrl)
|
|
|
|
this.currentItemUrl = repositoryRowUrl
|
|
|
|
return
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
loadRepositoryRow(repositoryRowUrl) {
|
2023-09-22 22:08:43 +08:00
|
|
|
this.dataLoading = true
|
2023-09-19 20:38:17 +08:00
|
|
|
$.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: repositoryRowUrl,
|
|
|
|
dataType: 'json',
|
|
|
|
success: (result) => {
|
|
|
|
this.repositoryName = result.repository_name;
|
|
|
|
this.defaultColumns = result.default_columns;
|
|
|
|
this.customColumns = result.custom_columns;
|
2023-09-22 22:08:43 +08:00
|
|
|
this.dataLoading = false
|
2023-09-25 14:29:54 +08:00
|
|
|
this.assignedModules = result.assigned_modules;
|
2023-09-27 15:55:53 +08:00
|
|
|
this.permissions = result.permissions
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-09-25 14:29:54 +08:00
|
|
|
privateModuleSize() {
|
|
|
|
return this.assignedModules.total_assigned_size - this.assignedModules.viewable_modules.length;
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|