add fittopage checkbox + custom print options
All checks were successful
Go / build (push) Successful in 16m26s

This commit is contained in:
2025-12-12 19:51:05 +01:00
parent 7fa932e378
commit faf07704d2
4 changed files with 70 additions and 34 deletions

View File

@@ -78,6 +78,8 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
image, err := ctx.FormFile("image")
dstImage := defaultImagePath
printMode := ctx.PostForm("print-mode")
fitToPage := ctx.PostForm("fit-to-page")
customPrintOptions := ctx.PostForm("custom-print-options")
if err == nil {
dstImage = filepath.Join("static/uploads", image.Filename)
@@ -150,18 +152,26 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
})
}
doFit := false
fmt.Println("FitToPage: ", fitToPage)
if fitToPage == "true" {
doFit = true
}
shopItem := models.ShopItem{
Name: name,
Abstract: abstract,
Description: description,
Category: category,
IsPublic: true,
BasePrice: rc.GetBasePrice(variants),
Image: dstImage,
Pdf: dstPdf,
Variants: variants,
PrintMode: printMode,
WasPrinted: false,
Name: name,
Abstract: abstract,
Description: description,
Category: category,
IsPublic: true,
BasePrice: rc.GetBasePrice(variants),
Image: dstImage,
Pdf: dstPdf,
Variants: variants,
PrintMode: printMode,
WasPrinted: false,
FitToPage: doFit,
CustomPrintOptions: customPrintOptions,
}
fmt.Println("Creating Shopitem: ", shopItem)
@@ -391,17 +401,19 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
}
shopItem := models.ShopItem{
Name: file.Filename,
Abstract: file.Filename,
Description: file.Filename,
Category: category,
IsPublic: true,
BasePrice: rc.GetBasePrice(variants),
Image: dstImage,
Pdf: dstPdf,
Variants: variants,
PrintMode: "CreateBooklet",
WasPrinted: false,
Name: file.Filename,
Abstract: file.Filename,
Description: file.Filename,
Category: category,
IsPublic: true,
BasePrice: rc.GetBasePrice(variants),
Image: dstImage,
Pdf: dstPdf,
Variants: variants,
PrintMode: "CreateBooklet",
WasPrinted: false,
FitToPage: false,
CustomPrintOptions: "",
}
_, err = repositories.ShopItems.Create(shopItem)
@@ -540,6 +552,8 @@ func (rc *shopItemController) EditItemHandler(c *gin.Context) {
newShopItem.BasePrice = shopItem.BasePrice
newShopItem.IsPublic = shopItem.IsPublic
newShopItem.WasPrinted = false
newShopItem.FitToPage = shopItem.FitToPage
newShopItem.CustomPrintOptions = shopItem.CustomPrintOptions
if len(shopItem.Tags) != 0 {
newShopItem.Tags = shopItem.Tags