2024-08-01 21:07:43 +08:00
|
|
|
<template>
|
|
|
|
<div v-if="repositoryRow">
|
|
|
|
<div class="flex items-center gap-4">
|
2024-08-06 15:21:18 +08:00
|
|
|
<h4 data-e2e="e2e-TX-itemCard-locations-title">{{ i18n.t('repositories.locations.title', { count: repositoryRow.storage_locations.locations.length }) }}</h4>
|
2024-08-05 17:23:35 +08:00
|
|
|
<button v-if="repositoryRow.permissions.can_manage && repositoryRow.storage_locations.enabled"
|
2024-08-06 15:21:18 +08:00
|
|
|
@click="openAssignModal = true" class="btn btn-light ml-auto" data-e2e="e2e-BT-itemCard-assignLocation">
|
2024-08-01 21:07:43 +08:00
|
|
|
{{ i18n.t('repositories.locations.assign') }}
|
|
|
|
</button>
|
|
|
|
</div>
|
2024-08-02 20:40:02 +08:00
|
|
|
<template v-for="(location, index) in repositoryRow.storage_locations.locations" :key="location.id">
|
2024-08-01 21:07:43 +08:00
|
|
|
<div>
|
|
|
|
<div class="sci-divider my-4" v-if="index > 0"></div>
|
|
|
|
<div class="flex items-center gap-2 mb-3">
|
|
|
|
{{ i18n.t('repositories.locations.container') }}:
|
2024-09-03 21:50:10 +08:00
|
|
|
<a v-if="location.readable" :href="containerUrl(location.id)">{{ location.name }}</a>
|
|
|
|
<span v-else>{{ location.name }}</span>
|
2024-08-05 17:23:35 +08:00
|
|
|
<span v-if="location.metadata.display_type !== 'grid'">
|
|
|
|
({{ location.positions.length }})
|
|
|
|
</span>
|
2024-08-01 21:07:43 +08:00
|
|
|
</div>
|
2024-08-05 17:23:35 +08:00
|
|
|
<div v-if="location.metadata.display_type === 'grid'" class="flex items-center gap-2 flex-wrap">
|
2024-08-01 21:07:43 +08:00
|
|
|
<div v-for="(position) in location.positions" :key="position.id">
|
|
|
|
<div v-if="position.metadata.position" class="flex items-center font-sm gap-1 uppercase bg-sn-grey-300 rounded pl-1.5 pr-2">
|
|
|
|
{{ formatPosition(position.metadata.position) }}
|
2024-08-02 20:40:02 +08:00
|
|
|
<i v-if="repositoryRow.permissions.can_manage" class="sn-icon sn-icon-unlink-italic-s cursor-pointer"></i>
|
2024-08-01 21:07:43 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2024-08-05 17:23:35 +08:00
|
|
|
<Teleport to="body">
|
|
|
|
<AssignModal
|
|
|
|
v-if="openAssignModal"
|
|
|
|
assignMode="assign"
|
|
|
|
:selectedRow="repositoryRow.id"
|
|
|
|
@close="openAssignModal = false; $emit('reloadRow')"
|
|
|
|
></AssignModal>
|
|
|
|
</Teleport>
|
2024-08-01 21:07:43 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-08-05 17:23:35 +08:00
|
|
|
import AssignModal from '../storage_locations/modals/assign.vue';
|
2024-08-01 21:07:43 +08:00
|
|
|
import {
|
|
|
|
storage_location_path
|
|
|
|
} from '../../routes.js';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'RepositoryItemLocations',
|
|
|
|
props: {
|
|
|
|
repositoryRow: Object,
|
|
|
|
repository: Object
|
|
|
|
},
|
2024-08-05 17:23:35 +08:00
|
|
|
components: {
|
|
|
|
AssignModal
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
openAssignModal: false
|
|
|
|
};
|
|
|
|
},
|
2024-08-01 21:07:43 +08:00
|
|
|
methods: {
|
|
|
|
containerUrl(id) {
|
|
|
|
return storage_location_path(id);
|
|
|
|
},
|
|
|
|
formatPosition(position) {
|
|
|
|
if (position) {
|
|
|
|
return `${this.numberToLetter(position[0])}${position[1]}`;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
numberToLetter(number) {
|
2024-08-05 17:23:35 +08:00
|
|
|
return String.fromCharCode(96 + number);
|
2024-08-01 21:07:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|