Updated Multiselect um mehrere Waren angeben zu können.

This commit is contained in:
2025-07-27 11:31:19 +02:00
parent 92bff5640f
commit 58b7552714
2 changed files with 15 additions and 7 deletions

BIN
data.db

Binary file not shown.

22
main.go
View File

@@ -60,7 +60,11 @@ var (
"Terrapin", "Vulture", "Hull-A", "Hull-C", "Zeus ES", "Zeus CL", "Terrapin", "Vulture", "Hull-A", "Hull-C", "Zeus ES", "Zeus CL",
// …weitere Capital- und Concept-Schiffe sind ebenfalls bekannt! // …weitere Capital- und Concept-Schiffe sind ebenfalls bekannt!
} }
waren = []string{"", "Laranite", "Titanium", "Medical Supplies", "Gold", "Agricium", "Hydrogen", "Nitrogen", "Astatine", "Iodine", "Aluminium", "Copper", "Lithium", "Silicon", "Tungsten", "Aphorite", "Beryl", "Bexalite", "Corundum", "Diamond", "Dolivine", "Hadanite", "Hephaestanite", "Laranite", "Quartz", "Taranite"} waren = []string{
"", "Laranite", "Titanium", "Medical Supplies", "Gold", "Agricium", "Hydrogen", "Nitrogen", "Astatine",
"Iodine", "Aluminium", "Copper", "Lithium", "Silicon", "Tungsten", "Aphorite", "Beryl", "Bexalite",
"Corundum", "Diamond", "Dolivine", "Hadanite", "Hephaestanite", "Laranite", "Quartz", "Taranite",
}
) )
type POI struct { type POI struct {
@@ -218,8 +222,10 @@ func main() {
} }
orte = append(orte, "") orte = append(orte, "")
for _, poi := range pois { for _, poi := range pois {
formatted := fmt.Sprintf("%s - %s - %s (%s)", poi.System, poi.Planet, poi.PoiName, poi.Type) if poi.System == "Stanton" || poi.System == "Pyro" {
orte = append(orte, formatted) formatted := fmt.Sprintf("%s - %s - %s (%s)", poi.System, poi.Planet, poi.PoiName, poi.Type)
orte = append(orte, formatted)
}
} }
// //
if err != nil { if err != nil {
@@ -333,10 +339,11 @@ func main() {
startort := r.FormValue("startort") startort := r.FormValue("startort")
zielort := r.FormValue("zielort") zielort := r.FormValue("zielort")
schiff := r.FormValue("schiff") schiff := r.FormValue("schiff")
ware := r.FormValue("ware") ware := r.Form["ware"]
wareStr := strings.Join(ware, ", ")
zeitaufwand, _ := strconv.ParseFloat(r.FormValue("zeitaufwand"), 64) zeitaufwand, _ := strconv.ParseFloat(r.FormValue("zeitaufwand"), 64)
_, err := db.Exec(`INSERT INTO eintraege (anfangsbestand, endbestand, prozentwert, abgabe, created_at, startort, zielort, schiff, ware, zeitaufwand) VALUES (?, ?, ?, ?, datetime('now'), ?, ?, ?, ?, ?)`, anfang, ende, prozent, abgabe, startort, zielort, schiff, ware, zeitaufwand) _, err := db.Exec(`INSERT INTO eintraege (anfangsbestand, endbestand, prozentwert, abgabe, created_at, startort, zielort, schiff, ware, zeitaufwand) VALUES (?, ?, ?, ?, datetime('now'), ?, ?, ?, ?, ?)`, anfang, ende, prozent, abgabe, startort, zielort, schiff, wareStr, zeitaufwand)
if err != nil { if err != nil {
http.Error(w, "Fehler beim Einfügen", http.StatusInternalServerError) http.Error(w, "Fehler beim Einfügen", http.StatusInternalServerError)
return return
@@ -664,7 +671,7 @@ const htmlTemplate = `
</div> </div>
<div class="col"> <div class="col">
<label class="form-label">Ware</label> <label class="form-label">Ware</label>
<select id="ware" name="ware" class="form-select"> <select id="ware" name="ware" class="form-select" multiple>
{{range .Waren}} {{range .Waren}}
<option value="{{.}}">{{.}}</option> <option value="{{.}}">{{.}}</option>
{{end}} {{end}}
@@ -912,7 +919,8 @@ const htmlTemplate = `
<script> <script>
new TomSelect("#ware", { new TomSelect("#ware", {
create: true, // erlaubt Freitext create: true, // erlaubt Freitext
sortField: "text" sortField: "text",
plugins: ['remove_button'] // ← erlaubt Entfernen per „x“-Button
}); });
</script> </script>