From 6ef7c53001499c870b16a9a7e86409246ec9e5ca Mon Sep 17 00:00:00 2001 From: kalipso Date: Mon, 21 Apr 2025 11:33:18 +0200 Subject: [PATCH 1/3] feat #19 Flyer - Tri fold? add trifold option to items --- models/printer.go | 5 +++++ static/output.css | 26 -------------------------- views/additem.html | 1 + views/edititem.html | 1 + 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/models/printer.go b/models/printer.go index 914ac40..868c269 100644 --- a/models/printer.go +++ b/models/printer.go @@ -15,6 +15,7 @@ const ( LongEdge PrintOption = "" ShortEdge PrintOption = "-o Binding=TopBinding" CreateBooklet PrintOption = "-o Combination=Booklet -o PageSize=A5" + TriFold PrintOption = "-o Fold=TriFold" ) type PrintJob struct { @@ -32,6 +33,10 @@ func GetPrintMode(mode string) PrintOption { return ShortEdge } + if mode == "TriFold" { + return TriFold + } + return CreateBooklet } diff --git a/static/output.css b/static/output.css index 4333cf7..51dca4a 100644 --- a/static/output.css +++ b/static/output.css @@ -810,26 +810,10 @@ video { grid-template-columns: repeat(12, minmax(0, 1fr)); } -.grid-cols-2 { - grid-template-columns: repeat(2, minmax(0, 1fr)); -} - -.grid-cols-3 { - grid-template-columns: repeat(3, minmax(0, 1fr)); -} - .grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } -.grid-cols-4 { - grid-template-columns: repeat(4, minmax(0, 1fr)); -} - -.grid-rows-6 { - grid-template-rows: repeat(6, minmax(0, 1fr)); -} - .flex-col { flex-direction: column; } @@ -1245,16 +1229,6 @@ video { background-color: rgb(24 24 27 / var(--tw-bg-opacity, 1)); } -.bg-green-500 { - --tw-bg-opacity: 1; - background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1)); -} - -.bg-gray-700 { - --tw-bg-opacity: 1; - background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1)); -} - .fill-red-50 { fill: #fef2f2; } diff --git a/views/additem.html b/views/additem.html index edb09b7..767f4c8 100644 --- a/views/additem.html +++ b/views/additem.html @@ -131,6 +131,7 @@ + diff --git a/views/edititem.html b/views/edititem.html index e115386..d12cdd7 100644 --- a/views/edititem.html +++ b/views/edititem.html @@ -74,6 +74,7 @@ + From 6f5c0354cc3debfa8c0bf3e17ab17461abb45a54 Mon Sep 17 00:00:00 2001 From: kalipso Date: Mon, 21 Apr 2025 12:09:39 +0200 Subject: [PATCH 2/3] fix #23 viewing non existing item breaks view --- controllers/shopItemController.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/controllers/shopItemController.go b/controllers/shopItemController.go index 55295ec..a0da554 100644 --- a/controllers/shopItemController.go +++ b/controllers/shopItemController.go @@ -260,14 +260,16 @@ func (rc *shopItemController) ShopItemView(c *gin.Context) { shopItem, err := repositories.ShopItems.GetById(c.Param("id")) if err != nil { - c.HTML(http.StatusBadRequest, "shopitem.html", gin.H{"data": gin.H{"error": err}}) + c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": "Item does not exist"}}) + return } //TODO: get tags by item tags, err := repositories.Tags.GetAll() if err != nil { - c.HTML(http.StatusBadRequest, "shopitem.html", gin.H{"data": gin.H{"error": err}}) + c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}}) + return } data := CreateSessionData(c, gin.H{ @@ -275,10 +277,6 @@ func (rc *shopItemController) ShopItemView(c *gin.Context) { "tags": tags, }) - if err != nil { - c.HTML(http.StatusBadRequest, "shopitem.html", data) - } - c.HTML(http.StatusOK, "shopitem.html", data) } From 8f89c149610ab0e74c27d817b3cc21a79c22e20b Mon Sep 17 00:00:00 2001 From: kalipso Date: Mon, 21 Apr 2025 12:11:44 +0200 Subject: [PATCH 3/3] issue #20 add sort, not yet in view --- controllers/userController.go | 16 ++++++++++++++-- repositories/shopItemRepository.go | 28 ++++++++++++++++++++++++++++ views/shopitems.html | 4 ++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/controllers/userController.go b/controllers/userController.go index b037982..da32163 100644 --- a/controllers/userController.go +++ b/controllers/userController.go @@ -333,8 +333,20 @@ func (rc *UserController) InviteHandler(c *gin.Context) { } func (rc *UserController) MainView(c *gin.Context) { - shopItems, _ := repositories.ShopItems.GetAll() - fmt.Println(len(shopItems)) + itemOrder := c.Query("order") + + var shopItems []models.ShopItem + if itemOrder == "newestFirst" { + shopItems, _ = repositories.ShopItems.GetAllNewestFirst() + } else if itemOrder == "oldestFirst" { + shopItems, _ = repositories.ShopItems.GetAllNewestLast() + } else if itemOrder == "az" { + shopItems, _ = repositories.ShopItems.GetAllLexicalFirst() + } else if itemOrder == "za" { + shopItems, _ = repositories.ShopItems.GetAllLexicalLast() + } else { + shopItems, _ = repositories.ShopItems.GetAllNewestFirst() + } data := CreateSessionData(c, gin.H{ "title": "shopItem Page", diff --git a/repositories/shopItemRepository.go b/repositories/shopItemRepository.go index 73e2377..58a11f1 100644 --- a/repositories/shopItemRepository.go +++ b/repositories/shopItemRepository.go @@ -11,6 +11,11 @@ import ( type ShopItemRepository interface { Create(models.ShopItem) (models.ShopItem, error) GetAll() ([]models.ShopItem, error) + GetAllSorted(string) ([]models.ShopItem, error) + GetAllNewestFirst() ([]models.ShopItem, error) + GetAllNewestLast() ([]models.ShopItem, error) + GetAllLexicalFirst() ([]models.ShopItem, error) + GetAllLexicalLast() ([]models.ShopItem, error) GetAllPublic() ([]models.ShopItem, error) GetById(string) (models.ShopItem, error) GetNextOfId(string) (models.ShopItem, error) @@ -47,6 +52,29 @@ func (r *GORMShopItemRepository) GetAll() ([]models.ShopItem, error) { return shopItems, result.Error } +func (r *GORMShopItemRepository) GetAllSorted(sortString string) ([]models.ShopItem, error) { + var shopItems []models.ShopItem + result := r.DB.Preload("Tags").Preload("Variants").Order(sortString).Find(&shopItems) + + return shopItems, result.Error +} + +func (r *GORMShopItemRepository) GetAllNewestFirst() ([]models.ShopItem, error) { + return r.GetAllSorted("created_at desc") +} + +func (r *GORMShopItemRepository) GetAllNewestLast() ([]models.ShopItem, error) { + return r.GetAllSorted("created_at asc") +} + +func (r *GORMShopItemRepository) GetAllLexicalFirst() ([]models.ShopItem, error) { + return r.GetAllSorted("name asc") +} + +func (r *GORMShopItemRepository) GetAllLexicalLast() ([]models.ShopItem, error) { + return r.GetAllSorted("name desc") +} + func (r *GORMShopItemRepository) GetAllPublic() ([]models.ShopItem, error) { var shopItems []models.ShopItem result := r.DB.Preload("Tags").Preload("Variants").Where("is_public = 1").Find(&shopItems) diff --git a/views/shopitems.html b/views/shopitems.html index 7ee74c8..f769524 100644 --- a/views/shopitems.html +++ b/views/shopitems.html @@ -1,8 +1,8 @@
-

Available Zines

+

Available Zines

- +
{{ range .data.shopItems }}