feat: import export rewrite (#290)

* WIP: initial work

* refactoring

* fix failing JS tests

* update import docs

* fix import headers

* fix column headers

* update refs on import

* remove demo status

* finnnneeeee

* formatting
This commit is contained in:
Hayden 2023-02-25 17:54:40 -09:00 committed by GitHub
parent a005fa5b9b
commit a6bcb36c5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1616 additions and 796 deletions

View file

@ -45,10 +45,10 @@
Imports the standard CSV format for Homebox. This will <b>not</b> overwrite any existing items in your
inventory. It will only add new items.
</DetailAction>
<!-- <DetailAction>
<DetailAction @action="getExportTSV()">
<template #title>Export Inventory</template>
Exports the standard CSV format for Homebox. This will export all items in your inventory.
</DetailAction> -->
</DetailAction>
</div>
</BaseCard>
<BaseCard>
@ -68,6 +68,11 @@
current asset_id field in the database and applying the next value to each item that has an unset asset_id
field. This is done in order of the created_at field.
</DetailAction>
<DetailAction @action="ensureImportRefs">
<template #title>Ensures Import Refs</template>
Ensures that all items in your inventory have a valid import_ref field. This is done by randomly generating
a 8 character string for each item that has an unset import_ref field.
</DetailAction>
<DetailAction @click="resetItemDateTimes">
<template #title> Zero Item Date Times</template>
Resets the time value for all date time fields in your inventory to the beginning of the date. This is to
@ -103,7 +108,13 @@
const notify = useNotifier();
function getBillOfMaterials() {
api.reports.billOfMaterialsURL();
const url = api.reports.billOfMaterialsURL();
window.open(url, "_blank");
}
function getExportTSV() {
const url = api.items.exportURL();
window.open(url, "_blank");
}
async function ensureAssetIDs() {
@ -125,6 +136,25 @@
notify.success(`${result.data.completed} assets have been updated.`);
}
async function ensureImportRefs() {
const { isCanceled } = await confirm.open(
"Are you sure you want to ensure all assets have an import_ref? This can take a while and cannot be undone."
);
if (isCanceled) {
return;
}
const result = await api.actions.ensureImportRefs();
if (result.error) {
notify.error("Failed to ensure import refs.");
return;
}
notify.success(`${result.data.completed} assets have been updated.`);
}
async function resetItemDateTimes() {
const { isCanceled } = await confirm.open(
"Are you sure you want to reset all date and time values? This can take a while and cannot be undone."