2023-09-19 20:38:17 +08:00
|
|
|
<template>
|
2023-09-22 22:08:43 +08:00
|
|
|
<div ref="wrapper"
|
2023-10-13 22:45:23 +08:00
|
|
|
class='items-sidebar-wrapper bg-white 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
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div id="repository-item-sidebar" class="w-full h-full pl-6 bg-white flex flex-col">
|
2023-09-22 22:08:43 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div id="sticky-header-wrapper" class="sticky top-0 right-0 bg-white flex z-50 flex-col h-[78px] pt-6">
|
|
|
|
<div class="header flex w-full h-[30px] pr-6">
|
2023-10-19 17:23:36 +08:00
|
|
|
<h4 class="item-name my-auto truncate text-xl" :title="repositoryRowName">
|
|
|
|
{{ repositoryRowName }}
|
2023-09-22 22:08:43 +08:00
|
|
|
</h4>
|
|
|
|
<i id="close-icon" @click="toggleShowHideSidebar(currentItemUrl)"
|
|
|
|
class="sn-icon sn-icon-close ml-auto cursor-pointer my-auto mx-0"></i>
|
|
|
|
</div>
|
2023-10-19 17:36:12 +08:00
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex items-center self-stretch h-px mt-6 mr-6"></div>
|
2023-09-25 16:49:09 +08:00
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
|
|
|
|
2023-10-19 17:36:12 +08:00
|
|
|
<div ref="bodyWrapper" id="body-wrapper" class="overflow-y-auto overflow-x-hidden h-[calc(100%-78px)] pt-6 ">
|
2023-10-13 22:45:23 +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-10-19 17:36:12 +08:00
|
|
|
<div v-else class="flex flex-1 flex-grow-1 justify-between" ref="scrollSpyContent">
|
|
|
|
|
|
|
|
<div id="left-col" class="flex flex-col gap-4">
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<!-- INFORMATION -->
|
2023-10-19 17:36:12 +08:00
|
|
|
<section id="information-section">
|
2023-10-13 22:45:23 +08:00
|
|
|
<div ref="information-label" id="information-label"
|
2023-10-18 16:06:21 +08:00
|
|
|
class="font-inter text-lg font-semibold leading-7 mb-4 transition-colors duration-300">{{
|
2023-10-13 22:45:23 +08:00
|
|
|
i18n.t('repositories.item_card.section.information') }}
|
|
|
|
</div>
|
2023-10-16 16:51:08 +08:00
|
|
|
<div v-if="defaultColumns">
|
2023-10-13 22:45:23 +08:00
|
|
|
<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>
|
2023-10-17 23:09:11 +08:00
|
|
|
<span class="repository-name text-sn-dark-grey line-clamp-3" :title="repository?.name">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ repository?.name }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div class="sci-divider"></div>
|
|
|
|
|
|
|
|
<!-- CODE -->
|
|
|
|
<div class="flex flex-col ">
|
2023-10-16 16:51:08 +08:00
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.id')
|
2023-10-13 22:45:23 +08:00
|
|
|
}}</span>
|
2023-10-17 23:09:11 +08:00
|
|
|
<span class="inline-block text-sn-dark-grey line-clamp-3" :title="defaultColumns?.code">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ defaultColumns?.code }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div class="sci-divider"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +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-10-13 22:45:23 +08:00
|
|
|
<div class="sci-divider"></div>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +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>
|
2023-10-17 23:09:11 +08:00
|
|
|
<span class="inline-block text-sn-dark-grey line-clamp-3" :title="defaultColumns?.added_by">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ defaultColumns?.added_by }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-10-16 16:51:08 +08:00
|
|
|
|
|
|
|
<!-- ARCHIVED ON -->
|
|
|
|
<div v-if="defaultColumns.archived_on" class="flex flex-col ">
|
|
|
|
<div class="sci-divider pb-4"></div>
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.archived_on')
|
|
|
|
}}</span>
|
|
|
|
<span class="inline-block text-sn-dark-grey" :title="defaultColumns.archived_on">
|
|
|
|
{{ defaultColumns.archived_on }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- ARCHIVED BY -->
|
|
|
|
<div v-if="defaultColumns.archived_by" class="flex flex-col ">
|
|
|
|
<div class="sci-divider pb-4"></div>
|
|
|
|
<span class="inline-block font-semibold pb-[6px]">{{
|
|
|
|
i18n.t('repositories.item_card.default_columns.archived_by')
|
|
|
|
}}</span>
|
|
|
|
<span class="inline-block text-sn-dark-grey" :title="defaultColumns.archived_by.full_name">
|
|
|
|
{{ defaultColumns.archived_by.full_name }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
2023-10-19 17:36:12 +08:00
|
|
|
</section>
|
2023-09-22 22:25:09 +08:00
|
|
|
|
2023-10-13 22:45:23 +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-10-13 22:45:23 +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-10-13 22:45:23 +08:00
|
|
|
<!-- CUSTOM COLUMNS -->
|
2023-10-19 17:36:12 +08:00
|
|
|
<section id="custom-columns-section" class="flex flex-col min-h-[64px] h-auto">
|
2023-10-13 22:45:23 +08:00
|
|
|
<div ref="custom-columns-label" id="custom-columns-label"
|
2023-10-18 16:06:21 +08:00
|
|
|
class="font-inter text-lg font-semibold leading-7 pb-4 transition-colors duration-300">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ 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 relative">
|
|
|
|
<span class="absolute right-2 top-6" v-if="column?.value?.reminder === true">
|
|
|
|
<Reminder :value="column?.value" :valueType="column?.value_type" />
|
|
|
|
</span>
|
2023-10-13 15:51:50 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<component :is="column.data_type" :key="index" :data_type="column.data_type" :colId="column.id"
|
|
|
|
:colName="column.name" :colVal="column.value" :repositoryRowId="repositoryRowId"
|
2023-10-17 22:32:39 +08:00
|
|
|
:repositoryId="repository.id" :permissions="permissions" />
|
2023-10-13 15:51:50 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div class="sci-divider" :class="{ 'hidden': index === customColumns?.length - 1 }"></div>
|
2023-10-13 15:51:50 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
</div>
|
|
|
|
</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>
|
2023-10-19 17:36:12 +08:00
|
|
|
</section>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px"></div>
|
|
|
|
|
|
|
|
<!-- ASSIGNED -->
|
2023-10-19 17:36:12 +08:00
|
|
|
<section id="assigned-section" class="flex flex-col" ref="assignedSectionRef">
|
|
|
|
<div
|
|
|
|
class="flex flex-row text-base font-semibold w-[350px] pb-4 leading-7 items-center justify-between transition-colors duration-300"
|
2023-10-16 16:51:08 +08:00
|
|
|
ref="assigned-label">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ i18n.t('repositories.item_card.section.assigned', {
|
|
|
|
count: assignedModules ?
|
|
|
|
assignedModules.total_assigned_size : 0
|
|
|
|
}) }}
|
2023-10-19 15:38:28 +08:00
|
|
|
<a v-if="!defaultColumns?.archived && (inRepository || actions?.assign_repository_row)"
|
2023-10-16 16:51:08 +08:00
|
|
|
class="btn-text-link font-normal" :class="{
|
|
|
|
'assign-inventory-button': actions?.assign_repository_row,
|
|
|
|
'disabled': actions?.assign_repository_row && actions.assign_repository_row.disabled
|
|
|
|
}"
|
2023-10-13 22:45:23 +08:00
|
|
|
:data-assign-url="actions?.assign_repository_row ? actions.assign_repository_row.assign_url : ''"
|
2023-10-16 16:51:08 +08:00
|
|
|
:data-repository-row-id="repositoryRowId" @click="showRepositoryAssignModal">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ i18n.t('repositories.item_card.assigned.assign') }}
|
|
|
|
</a>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
2023-10-18 16:06:21 +08:00
|
|
|
<div v-if="assignedModules && assignedModules.total_assigned_size > 0" class="flex flex-col gap-4">
|
|
|
|
<div v-if="privateModuleSize() > 0" class="flex flex-col gap-4">
|
2023-10-19 19:35:37 +08:00
|
|
|
<div class="text-sn-dark-grey">{{ i18n.t('repositories.item_card.assigned.private',
|
|
|
|
{ count: privateModuleSize() }) }}
|
|
|
|
</div>
|
2023-10-18 16:06:21 +08:00
|
|
|
<div class="sci-divider" :class="{ 'hidden': assignedModules?.viewable_modules?.length == 0 }"></div>
|
2023-10-13 22:45:23 +08:00
|
|
|
</div>
|
|
|
|
<div v-for="(assigned, index) in assignedModules.viewable_modules" :key="`assigned_module_${index}`"
|
2023-10-18 16:06:21 +08:00
|
|
|
class="flex flex-col w-[350px] h-auto gap-4">
|
2023-11-07 22:22:17 +08:00
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
<div v-for="(item, index_assigned) in assigned" :key="`assigned_element_${index_assigned}`"
|
|
|
|
class="text-sm">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ i18n.t(`repositories.item_card.assigned.labels.${item.type}`) }}
|
2023-10-19 21:58:28 +08:00
|
|
|
<a :href="item.url" class="text-sn-science-blue hover:text-sn-science-blue hover:no-underline">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ item.archived ? i18n.t('labels.archived') : '' }} {{ item.value }}
|
|
|
|
</a>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
2023-10-19 17:03:09 +08:00
|
|
|
<div class="sci-divider"
|
|
|
|
:class="{ 'hidden': index === assignedModules?.viewable_modules?.length - 1 }"></div>
|
2023-09-25 14:29:54 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-10-18 16:06:21 +08:00
|
|
|
<div v-else class="text-sn-dark-grey">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ i18n.t('repositories.item_card.assigned.empty') }}
|
|
|
|
</div>
|
|
|
|
</section>
|
2023-09-19 20:38:17 +08:00
|
|
|
|
2023-10-13 22:45:23 +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-10-13 22:45:23 +08:00
|
|
|
<!-- QR -->
|
2023-10-19 17:36:12 +08:00
|
|
|
<section id="qr-section" ref="QR-label">
|
|
|
|
<div class="font-inter text-base font-semibold leading-7 mb-4 mt-0 transition-colors duration-300">
|
|
|
|
{{ i18n.t('repositories.item_card.section.qr') }}
|
|
|
|
</div>
|
2023-10-13 22:45:23 +08:00
|
|
|
<div class="bar-code-container">
|
|
|
|
<canvas id="bar-code-canvas" class="hidden"></canvas>
|
2023-10-19 17:03:09 +08:00
|
|
|
<img :src="barCodeSrc" class="w-[90px]" />
|
2023-10-13 22:45:23 +08:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
2023-09-22 22:08:43 +08:00
|
|
|
</div>
|
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<!-- NAVIGATION -->
|
|
|
|
<div ref="navigationRef" id="navigation"
|
2023-10-19 17:03:09 +08:00
|
|
|
class="flex item-end gap-x-4 min-w-[130px] min-h-[130px] h-fit sticky top-0 right-[24px] ">
|
2023-10-13 22:45:23 +08:00
|
|
|
<scroll-spy :itemsToCreate="[
|
2023-10-19 17:36:12 +08:00
|
|
|
{ id: 'highlight-item-1', textId: 'text-item-1', labelAlias: 'information_label', label: 'information-label', sectionId: 'information-section' },
|
|
|
|
{ id: 'highlight-item-2', textId: 'text-item-2', labelAlias: 'custom_columns_label', label: 'custom-columns-label', sectionId: 'custom-columns-section' },
|
|
|
|
{ id: 'highlight-item-3', textId: 'text-item-3', labelAlias: 'assigned_label', label: 'assigned-label', sectionId: 'assigned-section' },
|
|
|
|
{ id: 'highlight-item-4', textId: 'text-item-4', labelAlias: 'QR_label', label: 'QR-label', sectionId: 'qr-section' }
|
|
|
|
]" :stickyHeaderHeightPx="102" :cardTopPaddingPx="null" :targetAreaMargin="30" v-show="isShowing">
|
2023-10-13 22:45:23 +08:00
|
|
|
</scroll-spy>
|
|
|
|
</div>
|
2023-09-19 20:38:17 +08:00
|
|
|
</div>
|
2023-09-22 22:25:09 +08:00
|
|
|
|
2023-10-13 22:45:23 +08:00
|
|
|
<!-- BOTTOM -->
|
2023-10-19 17:36:12 +08:00
|
|
|
<div id="bottom" v-show="!dataLoading" class="h-[100px] flex flex-col justify-end mt-4 mr-6"
|
|
|
|
:class="{ 'pb-6': customColumns?.length }">
|
2023-10-13 22:45:23 +08:00
|
|
|
<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">
|
2023-10-16 16:51:08 +08:00
|
|
|
<button type="button" class="btn btn-primary print-label-button"
|
|
|
|
:data-rows="JSON.stringify([repositoryRowId])">
|
2023-10-13 22:45:23 +08:00
|
|
|
{{ i18n.t('repositories.item_card.print_label') }}
|
|
|
|
</button>
|
|
|
|
</div>
|
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-10-11 15:35:10 +08:00
|
|
|
import Reminder from './reminder.vue'
|
2023-09-19 20:38:17 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'RepositoryItemSidebar',
|
|
|
|
components: {
|
2023-10-11 15:35:10 +08:00
|
|
|
Reminder,
|
2023-09-19 20:38:17 +08:00
|
|
|
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-10-12 21:10:54 +08:00
|
|
|
repositoryRowId: null,
|
2023-10-12 20:43:17 +08:00
|
|
|
repository: null,
|
2023-09-19 20:38:17 +08:00
|
|
|
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-27 15:55:53 +08:00
|
|
|
barCodeSrc: null,
|
2023-10-12 21:46:13 +08:00
|
|
|
permissions: null,
|
|
|
|
repositoryRowUrl: null,
|
|
|
|
actions: null,
|
|
|
|
myModuleId: null,
|
|
|
|
inRepository: false
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
window.repositoryItemSidebarComponent = this;
|
|
|
|
},
|
2023-10-19 17:23:36 +08:00
|
|
|
computed: {
|
|
|
|
repositoryRowName() {
|
|
|
|
return this.defaultColumns?.archived ? `${I18n.t('labels.archived')} ${this.defaultColumns?.name}` : this.defaultColumns?.name;
|
|
|
|
}
|
|
|
|
},
|
2023-10-12 21:26:41 +08:00
|
|
|
mounted() {
|
|
|
|
// Add a click event listener to the document
|
|
|
|
document.addEventListener('click', this.handleOutsideClick);
|
2023-10-12 21:46:13 +08:00
|
|
|
this.inRepository = $('.assign-items-to-task-modal-container').length > 0;
|
2023-10-12 21:26:41 +08:00
|
|
|
},
|
2023-11-09 02:32:43 +08:00
|
|
|
beforeUnmount() {
|
2023-09-19 20:38:17 +08:00
|
|
|
delete window.repositoryItemSidebarComponent;
|
2023-10-12 21:26:41 +08:00
|
|
|
document.removeEventListener('click', this.handleDocumentClick);
|
2023-09-19 20:38:17 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2023-10-12 21:26:41 +08:00
|
|
|
handleOutsideClick(event) {
|
|
|
|
if (!this.isShowing) return
|
|
|
|
|
|
|
|
const sidebar = this.$refs.wrapper;
|
2023-10-19 15:48:20 +08:00
|
|
|
// Check if the clicked element is not within the sidebar and it's not another item link or belogs to modals
|
|
|
|
const selectors = ['a', '.modal', '.label-printing-progress-modal'];
|
|
|
|
|
|
|
|
if (!sidebar.contains(event.target) && !selectors.some(selector => event.target.closest(selector))) {
|
|
|
|
this.toggleShowHideSidebar(null);
|
2023-10-12 21:26:41 +08:00
|
|
|
}
|
|
|
|
},
|
2023-10-12 21:46:13 +08:00
|
|
|
toggleShowHideSidebar(repositoryRowUrl, myModuleId = null) {
|
2023-09-22 22:08:43 +08:00
|
|
|
// initial click
|
|
|
|
if (this.currentItemUrl === null) {
|
2023-10-12 21:46:13 +08:00
|
|
|
this.myModuleId = myModuleId;
|
|
|
|
this.isShowing = true;
|
|
|
|
this.loadRepositoryRow(repositoryRowUrl);
|
|
|
|
this.currentItemUrl = repositoryRowUrl;
|
2023-09-22 22:08:43 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
// click on the same item - should just open/close it
|
|
|
|
else if (this.currentItemUrl === repositoryRowUrl) {
|
2023-10-12 21:46:13 +08:00
|
|
|
this.isShowing = false;
|
|
|
|
this.currentItemUrl = null;
|
|
|
|
this.myModuleId = null;
|
2023-09-22 22:08:43 +08:00
|
|
|
return
|
|
|
|
}
|
2023-10-09 23:10:41 +08:00
|
|
|
// explicit close (from emit)
|
|
|
|
else if (repositoryRowUrl === null) {
|
2023-10-12 21:46:13 +08:00
|
|
|
this.isShowing = false;
|
|
|
|
this.currentItemUrl = null;
|
|
|
|
this.myModuleId = null;
|
2023-10-09 23:10:41 +08:00
|
|
|
return
|
|
|
|
}
|
2023-09-22 22:08:43 +08:00
|
|
|
// click on a different item - should just fetch new data
|
|
|
|
else {
|
2023-10-12 21:46:13 +08:00
|
|
|
this.myModuleId = myModuleId;
|
|
|
|
this.loadRepositoryRow(repositoryRowUrl);
|
|
|
|
this.currentItemUrl = repositoryRowUrl;
|
2023-09-22 22:08:43 +08:00
|
|
|
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,
|
2023-10-12 21:46:13 +08:00
|
|
|
data: { my_module_id: this.myModuleId },
|
2023-09-19 20:38:17 +08:00
|
|
|
dataType: 'json',
|
|
|
|
success: (result) => {
|
2023-10-17 23:09:11 +08:00
|
|
|
this.repositoryRowId = result.id;
|
2023-10-13 17:54:39 +08:00
|
|
|
this.repository = result.repository;
|
|
|
|
this.defaultColumns = result.default_columns;
|
|
|
|
this.customColumns = result.custom_columns;
|
|
|
|
this.assignedModules = result.assigned_modules;
|
2023-10-17 23:09:11 +08:00
|
|
|
this.permissions = result.permissions;
|
2023-10-13 17:54:39 +08:00
|
|
|
this.actions = result.actions;
|
2023-10-17 23:09:11 +08:00
|
|
|
this.dataLoading = false;
|
2023-10-03 17:11:07 +08:00
|
|
|
this.$nextTick(() => {
|
2023-10-13 17:54:39 +08:00
|
|
|
this.generateBarCode(this.defaultColumns.code);
|
2023-10-03 17:11:07 +08:00
|
|
|
});
|
2023-09-19 20:38:17 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-10-12 21:46:13 +08:00
|
|
|
reload() {
|
2023-10-16 16:51:08 +08:00
|
|
|
if (this.isShowing) {
|
2023-10-12 21:46:13 +08:00
|
|
|
this.loadRepositoryRow(this.currentItemUrl);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showRepositoryAssignModal() {
|
|
|
|
if (this.inRepository) {
|
|
|
|
window.AssignItemsToTaskModalComponentContainer.showModal([this.repositoryRowId]);
|
|
|
|
}
|
|
|
|
},
|
2023-10-03 17:11:07 +08:00
|
|
|
generateBarCode(text) {
|
2023-10-16 16:51:08 +08:00
|
|
|
if (!text) return;
|
2023-10-03 17:11:07 +08:00
|
|
|
const barCodeCanvas = bwipjs.toCanvas('bar-code-canvas', {
|
|
|
|
bcid: 'qrcode',
|
|
|
|
text,
|
|
|
|
scale: 3
|
|
|
|
});
|
2023-10-12 21:10:54 +08:00
|
|
|
this.barCodeSrc = barCodeCanvas.toDataURL('image/png');
|
2023-10-03 17:11:07 +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>
|