Skip to content

Add a quantity field to the item create modal form. #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 changes: 2 additions & 0 deletions backend/internal/data/repo/repo_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type (
ImportRef string `json:"-"`
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"`
Name string `json:"name" validate:"required,min=1,max=255"`
Quantity int `json:"quantity"`
Description string `json:"description" validate:"max=1000"`
AssetID AssetID `json:"-"`

Expand Down Expand Up @@ -575,6 +576,7 @@ func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCr
q := e.db.Item.Create().
SetImportRef(data.ImportRef).
SetName(data.Name).
SetQuantity(data.Quantity).
SetDescription(data.Description).
SetGroupID(gid).
SetLocationID(data.LocationID).
Expand Down
8 changes: 8 additions & 0 deletions frontend/components/Item/CreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
:max-length="255"
:min-length="1"
/>
<FormTextField
v-model="form.quantity"
:label="$t('components.item.create_modal.item_quantity')"
type="number"
/>
<FormTextArea
v-model="form.description"
:label="$t('components.item.create_modal.item_description')"
Expand Down Expand Up @@ -120,6 +125,7 @@
const form = reactive({
location: locations.value && locations.value.length > 0 ? locations.value[0] : ({} as LocationOut),
name: "",
quantity: 1,
description: "",
color: "", // Future!
labels: [] as LabelOut[],
Expand Down Expand Up @@ -187,6 +193,7 @@
const out: ItemCreate = {
parentId: null,
name: form.name,
quantity: form.quantity,
description: form.description,
locationId: form.location.id as string,
labelIds: form.labels.map(l => l.id) as string[],
Expand Down Expand Up @@ -218,6 +225,7 @@

// Reset
form.name = "";
form.quantity = 1;
form.description = "";
form.color = "";
form.photos = [];
Expand Down
1 change: 1 addition & 0 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"create_modal": {
"item_description": "Item Description",
"item_name": "Item Name",
"item_quantity": "Item Quantity",
"photo_button": "Photo 📷",
"title": "Create Item"
},
Expand Down
Loading