feat: Refine trail category model (#1059)
* feat: advanced trail categories * rename remote_category * fix merge issues * subcategories for plugins mapping * fix refresh * remove vertical trail filter category scrolling * cleanup * add confirm modal for disabling a category * Fix federation issues * fix review findings * redesign category settings page * remove prio badge * fix subcategory badge layout * optimize subcategory settings layout * further settings page layout optimization * fix subcategory icon position * fix * update docs --------- Co-authored-by: Christian Beutel <>
This commit is contained in:
@@ -33,10 +33,24 @@ func documentFromTrailRecord(r *core.Record, author *core.Record, includeShares
|
||||
tags[i] = v.GetString("name")
|
||||
}
|
||||
|
||||
categoryID := r.GetString("category")
|
||||
var categoryIDValue any
|
||||
if categoryID != "" {
|
||||
categoryIDValue = categoryID
|
||||
}
|
||||
|
||||
subcategoryID := r.GetString("subcategory")
|
||||
var subcategoryIDValue any
|
||||
if subcategoryID != "" {
|
||||
subcategoryIDValue = subcategoryID
|
||||
}
|
||||
|
||||
category := ""
|
||||
categoryIcon := ""
|
||||
trailCategory := r.ExpandedOne("category")
|
||||
if trailCategory != nil {
|
||||
category = trailCategory.GetString("name")
|
||||
categoryIcon = trailCategory.GetString("icon")
|
||||
}
|
||||
|
||||
bounds := getStoredBounds(r)
|
||||
@@ -52,34 +66,40 @@ func documentFromTrailRecord(r *core.Record, author *core.Record, includeShares
|
||||
}
|
||||
|
||||
document := map[string]any{
|
||||
"id": r.Id,
|
||||
"author": author.Id,
|
||||
"author_name": author.GetString("preferred_username"),
|
||||
"author_avatar": author.GetString("icon"),
|
||||
"name": r.GetString("name"),
|
||||
"description": r.GetString("description"),
|
||||
"location": r.GetString("location"),
|
||||
"distance": r.GetFloat("distance"),
|
||||
"elevation_gain": r.GetFloat("elevation_gain"),
|
||||
"elevation_loss": r.GetFloat("elevation_loss"),
|
||||
"duration": r.GetFloat("duration"),
|
||||
"difficulty": difficultyToNumber(r.GetString("difficulty")),
|
||||
"category": category,
|
||||
"completed": r.GetBool("completed"),
|
||||
"date": r.GetDateTime("date").Time().Unix(),
|
||||
"created": r.GetDateTime("created").Time().Unix(),
|
||||
"public": r.GetBool("public"),
|
||||
"thumbnail": thumbnail,
|
||||
"gpx": r.GetString("gpx"),
|
||||
"tags": tags,
|
||||
"polyline": r.GetString("polyline"),
|
||||
"domain": domain,
|
||||
"iri": r.GetString("iri"),
|
||||
"min_lat": bounds[0],
|
||||
"max_lat": bounds[1],
|
||||
"min_lon": bounds[2],
|
||||
"max_lon": bounds[3],
|
||||
"bounding_box_diagonal": diagonal,
|
||||
"id": r.Id,
|
||||
"author": author.Id,
|
||||
"author_name": author.GetString("preferred_username"),
|
||||
"author_avatar": author.GetString("icon"),
|
||||
"name": r.GetString("name"),
|
||||
"description": r.GetString("description"),
|
||||
"location": r.GetString("location"),
|
||||
"distance": r.GetFloat("distance"),
|
||||
"elevation_gain": r.GetFloat("elevation_gain"),
|
||||
"elevation_loss": r.GetFloat("elevation_loss"),
|
||||
"duration": r.GetFloat("duration"),
|
||||
"difficulty": difficultyToNumber(r.GetString("difficulty")),
|
||||
"category": category,
|
||||
"category_id": categoryIDValue,
|
||||
"category_icon": categoryIcon,
|
||||
"subcategory_id": subcategoryIDValue,
|
||||
"is_federated": !author.GetBool("is_local"),
|
||||
"federated_category_name": r.GetString("federated_category_name"),
|
||||
"federated_subcategory_name": r.GetString("federated_subcategory_name"),
|
||||
"completed": r.GetBool("completed"),
|
||||
"date": r.GetDateTime("date").Time().Unix(),
|
||||
"created": r.GetDateTime("created").Time().Unix(),
|
||||
"public": r.GetBool("public"),
|
||||
"thumbnail": thumbnail,
|
||||
"gpx": r.GetString("gpx"),
|
||||
"tags": tags,
|
||||
"polyline": r.GetString("polyline"),
|
||||
"domain": domain,
|
||||
"iri": r.GetString("iri"),
|
||||
"min_lat": bounds[0],
|
||||
"max_lat": bounds[1],
|
||||
"min_lon": bounds[2],
|
||||
"max_lon": bounds[3],
|
||||
"bounding_box_diagonal": diagonal,
|
||||
"_geo": map[string]float64{
|
||||
"lat": r.GetFloat("lat"),
|
||||
"lng": r.GetFloat("lon"),
|
||||
|
||||
Reference in New Issue
Block a user