Import inventaire: format date when needed

This commit is contained in:
2026-01-29 16:24:12 +01:00
parent cea2cfb19e
commit 9b90565b95
2 changed files with 14 additions and 3 deletions

View File

@@ -12,6 +12,16 @@
date: String,
isbn: String,
});
function displayDate(date) {
const regex = /^\d{4}-\d{2}-\d{2}$/;
if (regex.test(date)) {
const d = new Date(date);
return d.toLocaleDateString();
} else {
return date;
}
}
const imagePathOrDefault = computed(() => getInventaireImagePathOrDefault(props.image));
</script>
@@ -28,7 +38,8 @@
</div>
<div class="media-content">
<div class="is-size-4">{{title}}</div>
<div v-if="props.date" class="is-size-5">{{$t('importlistelement.releasedate') + "" + date}}</div>
<div v-if="props.date" class="is-size-5">{{$t('importlistelement.releasedate') + "" +
displayDate(date)}}</div>
<div v-if="props.publisher" class="is-size-5">{{$t('importlistelement.publisher') + "" + publisher}}</div>
<div v-if="props.isbn" class="is-size-5">{{"ISBN: " + isbn}}</div>
</div>

View File

@@ -19,7 +19,7 @@
let error = ref(null);
const pageTotal = computed(() => {
let countValue = (data.value !== null) ? data.value['count'] : 0;
const countValue = (data.value !== null) ? data.value['count'] : 0;
return Math.ceil(countValue / limit);
});
@@ -28,7 +28,7 @@
function fetchData(searchTerm, authorId) {
if (searchTerm != null) {
let lang = navigator.language.substring(0,2);
const lang = navigator.language.substring(0,2);
getSearchBooks(data, error, searchTerm, lang, limit, offset.value);
} else if (authorId != null) {
getAuthorBooks(data, error, authorId, limit, offset.value);