Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

ProductBarcode: return more fields from DB (brand, model...)

Crumb Owl6dbb243ba597
diff --git a/backend/app/api/handlers/v1/v1_ctrl_qrcode.go b/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
index 59f817e2..24cbe81a 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_qrcode.go
@@ -92,7 +92,7 @@ type BarcodeProduct struct {
// TODO: add asin?
ImageURL string `json:"imageURL"`
- item repo.ItemCreate
+ Item repo.ItemCreate `json:"item"`
}
/*
@@ -245,8 +245,8 @@ func (ctrl *V1Controller) HandleProductSearchEAN() errchain.HandlerFunc {
p.SearchEngineName = "upcitemdb.com"
p.Barcode = iEan
- p.item.Description = it.Description
- p.item.Name = it.Title
+ p.Item.Description = it.Description
+ p.Item.Name = it.Title
p.Manufacturer = it.Brand
p.ModelNumber = it.Model
if len(it.Images) != 0 {
@@ -300,8 +300,8 @@ func (ctrl *V1Controller) HandleProductSearchEAN() errchain.HandlerFunc {
var p BarcodeProduct
p.Barcode = iEan
p.SearchEngineName = "barcodespider.com"
- p.item.Name = result.ItemAttributes.Title
- p.item.Description = result.ItemAttributes.Description
+ p.Item.Name = result.ItemAttributes.Title
+ p.Item.Description = result.ItemAttributes.Description
p.Manufacturer = result.ItemAttributes.Brand
p.ModelNumber = result.ItemAttributes.Model
p.ImageURL = result.ItemAttributes.Image
@@ -329,7 +329,7 @@ func (ctrl *V1Controller) HandleProductSearchEAN() errchain.HandlerFunc {
w.Header().Set("Content-Type", "application/json")
if len(products) != 0 {
- return json.NewEncoder(w).Encode(products[0].item)
+ return json.NewEncoder(w).Encode(products[0])
}
return nil
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index 3f2900ee..bb267d57 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -221,7 +221,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
- "type": "string"
+ "$ref": "#/definitions/repo.ItemCreate"
}
}
}
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index e8cb6adf..a8493f57 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -219,7 +219,7 @@
"200": {
"description": "OK",
"schema": {
- "type": "string"
+ "$ref": "#/definitions/repo.ItemCreate"
}
}
}
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index 5bb042dc..babde081 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -1564,7 +1564,7 @@ paths:
"200":
description: OK
schema:
- type: string
+ $ref: '#/definitions/repo.ItemCreate'
security:
- Bearer: []
summary: Search EAN from Barcode
diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json
index e8cb6adf..a8493f57 100644
--- a/docs/en/api/openapi-2.0.json
+++ b/docs/en/api/openapi-2.0.json
@@ -219,7 +219,7 @@
"200": {
"description": "OK",
"schema": {
- "type": "string"
+ "$ref": "#/definitions/repo.ItemCreate"
}
}
}
diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml
index 5bb042dc..babde081 100644
--- a/docs/en/api/openapi-2.0.yaml
+++ b/docs/en/api/openapi-2.0.yaml
@@ -1564,7 +1564,7 @@ paths:
"200":
description: OK
schema:
- type: string
+ $ref: '#/definitions/repo.ItemCreate'
security:
- Bearer: []
summary: Search EAN from Barcode
diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue
index b6a5ab5d..edb71b68 100644
--- a/frontend/components/Item/CreateModal.vue
+++ b/frontend/components/Item/CreateModal.vue
@@ -313,8 +313,8 @@
if(active.params)
{
- form.name = active.params.name;
- form.description = active.params.description;
+ form.name = active.params.item.name;
+ form.description = active.params.item.description;
}
if (labelId.value) {