allow updating tags of items
This commit is contained in:
@@ -69,6 +69,11 @@ func (r *GORMShopItemRepository) GetById(id string) (models.ShopItem, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *GORMShopItemRepository) Update(shopItem models.ShopItem) (models.ShopItem, error) {
|
func (r *GORMShopItemRepository) Update(shopItem models.ShopItem) (models.ShopItem, error) {
|
||||||
|
err := r.DB.Model(&shopItem).Association("Tags").Replace(shopItem.Tags)
|
||||||
|
if err != nil {
|
||||||
|
return models.ShopItem{}, err
|
||||||
|
}
|
||||||
|
|
||||||
result := r.DB.Save(&shopItem)
|
result := r.DB.Save(&shopItem)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
return models.ShopItem{}, result.Error
|
return models.ShopItem{}, result.Error
|
||||||
|
|||||||
@@ -34,6 +34,17 @@
|
|||||||
<span class="text-gray-600 dark:text-gray-300">{{ .data.shopItem.Price }}€</span>
|
<span class="text-gray-600 dark:text-gray-300">{{ .data.shopItem.Price }}€</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex mb-4">
|
||||||
|
<div class="mr-4">
|
||||||
|
<span class="font-bold text-gray-700 dark:text-gray-300">Tags:</span>
|
||||||
|
<span class="text-gray-600 dark:text-gray-300">
|
||||||
|
{{ range .data.shopItem.Tags }}
|
||||||
|
{{ .Name }}
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!--
|
<!--
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<span class="font-bold text-gray-700 dark:text-gray-300">Select Size:</span>
|
<span class="font-bold text-gray-700 dark:text-gray-300">Select Size:</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user