code simplification
This commit is contained in:
parent
be80307bde
commit
cf2e217030
7 changed files with 47 additions and 73 deletions
|
|
@ -22,21 +22,6 @@ func OrderTitle(order models.Order) string {
|
|||
return "Nowe zamówienie"
|
||||
}
|
||||
|
||||
func specialCakeDetail(sc models.SpecialCake) string {
|
||||
return sc.Detail()
|
||||
}
|
||||
|
||||
func cakeItemsDesc(cakes []models.Cake) string {
|
||||
desc := ""
|
||||
for i, c := range cakes {
|
||||
if i > 0 {
|
||||
desc += ", "
|
||||
}
|
||||
desc += c.Name + " (x" + strconv.Itoa(c.Amount) + ")"
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
func cakeHasTag(tags []models.Tag, id int) bool {
|
||||
for _, t := range tags {
|
||||
if t.ID == id {
|
||||
|
|
@ -63,7 +48,13 @@ func tagNames(tags []models.Tag) string {
|
|||
}
|
||||
|
||||
func orderItemsDesc(order models.Order) string {
|
||||
desc := cakeItemsDesc(order.Cakes)
|
||||
desc := ""
|
||||
for i, c := range order.Cakes {
|
||||
if i > 0 {
|
||||
desc += ", "
|
||||
}
|
||||
desc += c.Name + " (x" + strconv.Itoa(c.Amount) + ")"
|
||||
}
|
||||
for _, s := range order.SpecialCakes {
|
||||
if desc != "" {
|
||||
desc += ", "
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ templ OrderForm(order models.Order, catalogue []models.Cake, allTags []models.Ta
|
|||
<li data-special-id={ strconv.Itoa(s.ID) }>
|
||||
<div class="basket-item-body">
|
||||
<div class="name">{ s.Name }</div>
|
||||
<div class="detail">{ specialCakeDetail(s) }</div>
|
||||
<div class="detail">{ s.Detail() }</div>
|
||||
if len(s.Tags) > 0 {
|
||||
<div class="basket-item-tags">
|
||||
for _, t := range s.Tags {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue