scinote-web/app/javascript/vue/repository_item_sidebar/locations.vue

56 lines
1.8 KiB
Vue
Raw Normal View History

2024-08-01 21:07:43 +08:00
<template>
<div v-if="repositoryRow">
<div class="flex items-center gap-4">
<h4>{{ i18n.t('repositories.locations.title', { count: repositoryRow.storage_locations.locations.length }) }}</h4>
<button v-if="repositoryRow.permissions.can_manage && repositoryRow.storage_locations.enabled" class="btn btn-light">
2024-08-01 21:07:43 +08:00
{{ i18n.t('repositories.locations.assign') }}
</button>
</div>
<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') }}:
<a :href="containerUrl(location.id)">{{ location.name }}</a>
</div>
<div class="flex items-center gap-2 flex-wrap">
<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) }}
<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>
</div>
</template>
<script>
import {
storage_location_path
} from '../../routes.js';
export default {
name: 'RepositoryItemLocations',
props: {
repositoryRow: Object,
repository: Object
},
methods: {
containerUrl(id) {
return storage_location_path(id);
},
formatPosition(position) {
if (position) {
return `${this.numberToLetter(position[0])}${position[1]}`;
}
return '';
},
numberToLetter(number) {
return String.fromCharCode(97 + number);
}
}
};
</script>