add fittopage checkbox + custom print options
All checks were successful
Go / build (push) Successful in 16m26s
All checks were successful
Go / build (push) Successful in 16m26s
This commit is contained in:
@@ -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,6 +152,12 @@ 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,
|
||||
@@ -162,6 +170,8 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
|
||||
Variants: variants,
|
||||
PrintMode: printMode,
|
||||
WasPrinted: false,
|
||||
FitToPage: doFit,
|
||||
CustomPrintOptions: customPrintOptions,
|
||||
}
|
||||
|
||||
fmt.Println("Creating Shopitem: ", shopItem)
|
||||
@@ -402,6 +412,8 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
|
||||
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
|
||||
|
||||
@@ -19,6 +19,7 @@ const (
|
||||
ShortEdge PrintOption = "-o Binding=TopBinding"
|
||||
CreateBooklet PrintOption = "-o Combination=Booklet -o PageSize=A5"
|
||||
TriFold PrintOption = "-o Fold=TriFold -o Binding=TopBinding"
|
||||
FitToPage PrintOption = "-o fit-to-page"
|
||||
)
|
||||
|
||||
type OldPrintJob struct {
|
||||
@@ -101,7 +102,12 @@ func (p *PrintJob) GeneratePrintOptions() []PrintOption {
|
||||
result = append(result, CoverPage)
|
||||
}
|
||||
|
||||
if p.ShopItem.FitToPage {
|
||||
result = append(result, FitToPage)
|
||||
}
|
||||
|
||||
result = append(result, GetPrintMode(p.ShopItem.PrintMode))
|
||||
result = append(result, PrintOption(p.ShopItem.CustomPrintOptions))
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -53,5 +53,7 @@ type ShopItem struct {
|
||||
Image string
|
||||
Pdf string
|
||||
PrintMode string `json:"printMode" gorm:"default:CreateBooklet"`
|
||||
CustomPrintOptions string `gorm:"default:''"`
|
||||
FitToPage bool `gorm:"default:false"`
|
||||
WasPrinted bool `gorm:"default:false"`
|
||||
}
|
||||
|
||||
@@ -77,6 +77,20 @@
|
||||
<option value="TriFold">Tri-Fold (Flyer)</option>
|
||||
</select>
|
||||
|
||||
<label class="flex text-sm/6 items-center">
|
||||
<input type="checkbox" {{ if .data.shopItem.FitToPage }} checked {{ else }} {{ end }} class="form-checkbox h-4 w-4 text-gray-900"
|
||||
value="true" name="fit-to-page">
|
||||
<span class="ml-2 text-sm/6 text-gray-900">Fit to Page</span>
|
||||
</label>
|
||||
|
||||
|
||||
<div>
|
||||
<label for="custom-print-options" class="block text-sm/6 font-medium text-gray-900">Custom Print Options:</label>
|
||||
<textarea id="custom-print-options" name="custom-print-options" type="textarea" class="block w-full px-4 py-2
|
||||
mt-2 text-gray-900 bg-white border border-gray-300 rounded-md focus:border-blue-500 focus:outline-none
|
||||
focus:ring">{{ .data.shopItem.CustomPrintOptions}}</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm/6 text-gray-900">Select Categories</label>
|
||||
|
||||
Reference in New Issue
Block a user