Skip to content

Commit

Permalink
refactor: show empty or not
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Apr 7, 2024
1 parent 7be831a commit 35365df
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 65 deletions.
6 changes: 3 additions & 3 deletions darkstat/front/bases.templ
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package front

import (
"strconv"
"github.com/darklab8/fl-darkstat/darkstat/front/urls"
"github.com/darklab8/fl-darkstat/darkstat/common/types"
"github.com/darklab8/fl-configs/configs/configs_export"
"fmt"
"strings"
"github.com/darklab8/fl-darkstat/darkstat/front/urls"
)

func InfocardURL(infocard_key configs_export.InfocardKey) string {
Expand All @@ -19,8 +19,8 @@ func BaseMarketGoodUrl(base configs_export.Base) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ BasesT(bases []configs_export.Base) {
@TabMenu(urls.Bases)
templ BasesT(bases []configs_export.Base, mode ShowEmpty) {
@TabMenu(urls.Bases, mode)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions darkstat/front/commodities.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func GoodAtBaseInfoTUrl(commodity configs_export.Commodity) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ CommoditiesT(commodities []configs_export.Commodity) {
@TabMenu(urls.Commodities)
templ CommoditiesT(commodities []configs_export.Commodity, mode ShowEmpty) {
@TabMenu(urls.Commodities, mode)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions darkstat/front/engines.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func EngineDetailedUrl(engine configs_export.Engine) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ Engines(engines []configs_export.Engine) {
@TabMenu(urls.Engines)
templ Engines(engines []configs_export.Engine, mode ShowEmpty) {
@TabMenu(urls.Engines, mode)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
6 changes: 3 additions & 3 deletions darkstat/front/factions.templ
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const (

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ FactionsT(factions []configs_export.Faction, mode FactionTabMode) {
templ FactionsT(factions []configs_export.Faction, mode FactionTabMode, mode2 ShowEmpty) {
if mode == FactionShowBases {
@TabMenu(urls.Factions)
@TabMenu(urls.Factions, mode2)
} else if mode == FactionShowRephacks {
@TabMenu(urls.Rephacks)
@TabMenu(urls.Rephacks, mode2)
}
@TabContent() {
<div class="splitter">
Expand Down
8 changes: 4 additions & 4 deletions darkstat/front/guns.templ
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const (

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ GunsT(guns []configs_export.Gun, mode GunTabMode) {
templ GunsT(guns []configs_export.Gun, mode GunTabMode, mode2 ShowEmpty) {
if mode == GunsShowBases {
@TabMenu(urls.Guns)
@TabMenu(urls.Guns, mode2)
} else if mode == GunsShowDamageBonuses {
@TabMenu(urls.GunModifiers)
@TabMenu(urls.GunModifiers, mode2)
} else if mode == GunsMissiles {
@TabMenu(urls.Missiles)
@TabMenu(urls.Missiles, mode2)
}
@TabContent() {
<div class="splitter">
Expand Down
4 changes: 2 additions & 2 deletions darkstat/front/mines.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func MineDetailedUrl(mine configs_export.Mine) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ MinesT(mines []configs_export.Mine) {
@TabMenu(urls.Mines)
templ MinesT(mines []configs_export.Mine, mode2 ShowEmpty) {
@TabMenu(urls.Mines, mode2)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
55 changes: 40 additions & 15 deletions darkstat/front/shared.templ
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ templ Heading() {
</div>
}

templ TabMenu(url utils_types.FilePath) {
type ShowEmpty bool

templ TabMenu(url utils_types.FilePath, mode ShowEmpty) {
<style>
.tab-list {
height: 100%;
Expand All @@ -154,20 +156,39 @@ templ TabMenu(url utils_types.FilePath) {
}
</style>
<div class="tab-list" role="tablist">
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Bases.ToString() } class={ templ.KV("selected", urls.Bases == url) } role="tab" aria-selected="false" aria-controls="tab-content">Bases</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Factions.ToString() } class={ templ.KV("selected", urls.Factions == url) } role="tab" aria-selected="false" aria-controls="tab-content">Factions</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Rephacks.ToString() } class={ templ.KV("selected", urls.Rephacks == url) } role="tab" aria-selected="false" aria-controls="tab-content">Rephacks</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Commodities.ToString() } class={ templ.KV("selected", urls.Commodities == url) } role="tab" aria-selected="false" aria-controls="tab-content">Commodities</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Guns.ToString() } class={ templ.KV("selected", urls.Guns == url) } role="tab" aria-selected="false" aria-controls="tab-content">Guns</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.GunModifiers.ToString() } class={ templ.KV("selected", urls.GunModifiers == url) } role="tab" aria-selected="false" aria-controls="tab-content">Gun Modifiers</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Missiles.ToString() } class={ templ.KV("selected", urls.Missiles == url) } role="tab" aria-selected="false" aria-controls="tab-content">Missiles</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Mines.ToString() } class={ templ.KV("selected", urls.Mines == url) } role="tab" aria-selected="false" aria-controls="tab-content">Mines</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Shields.ToString() } class={ templ.KV("selected", urls.Shields == url) } role="tab" aria-selected="false" aria-controls="tab-content">Shields</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Thrusters.ToString() } class={ templ.KV("selected", urls.Thrusters == url) } role="tab" aria-selected="false" aria-controls="tab-content">Thrusters</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Ships.ToString() } class={ templ.KV("selected", urls.Ships == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ships</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.ShipDetails.ToString() } class={ templ.KV("selected", urls.ShipDetails == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ship Details</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Tractors.ToString() } class={ templ.KV("selected", urls.Tractors == url) } role="tab" aria-selected="false" aria-controls="tab-content">Tractors</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Engines.ToString() } class={ templ.KV("selected", urls.Engines == url) } role="tab" aria-selected="false" aria-controls="tab-content">Engines</button>
if mode == false {
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Bases.ToString() } class={ templ.KV("selected", urls.Bases == url) } role="tab" aria-selected="false" aria-controls="tab-content">Bases</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Factions.ToString() } class={ templ.KV("selected", urls.Factions == url) } role="tab" aria-selected="false" aria-controls="tab-content">Factions</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Rephacks.ToString() } class={ templ.KV("selected", urls.Rephacks == url) } role="tab" aria-selected="false" aria-controls="tab-content">Rephacks</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Commodities.ToString() } class={ templ.KV("selected", urls.Commodities == url) } role="tab" aria-selected="false" aria-controls="tab-content">Commodities</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Guns.ToString() } class={ templ.KV("selected", urls.Guns == url) } role="tab" aria-selected="false" aria-controls="tab-content">Guns</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.GunModifiers.ToString() } class={ templ.KV("selected", urls.GunModifiers == url) } role="tab" aria-selected="false" aria-controls="tab-content">Gun Modifiers</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Missiles.ToString() } class={ templ.KV("selected", urls.Missiles == url) } role="tab" aria-selected="false" aria-controls="tab-content">Missiles</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Mines.ToString() } class={ templ.KV("selected", urls.Mines == url) } role="tab" aria-selected="false" aria-controls="tab-content">Mines</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Shields.ToString() } class={ templ.KV("selected", urls.Shields == url) } role="tab" aria-selected="false" aria-controls="tab-content">Shields</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Thrusters.ToString() } class={ templ.KV("selected", urls.Thrusters == url) } role="tab" aria-selected="false" aria-controls="tab-content">Thrusters</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Ships.ToString() } class={ templ.KV("selected", urls.Ships == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ships</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.ShipDetails.ToString() } class={ templ.KV("selected", urls.ShipDetails == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ship Details</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Tractors.ToString() } class={ templ.KV("selected", urls.Tractors == url) } role="tab" aria-selected="false" aria-controls="tab-content">Tractors</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Engines.ToString() } class={ templ.KV("selected", urls.Engines == url) } role="tab" aria-selected="false" aria-controls="tab-content">Engines</button>
<button style="width:150px;" hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Bases).ToString() } role="tab" aria-selected="false" aria-controls="tab-content">Show Empty</button>
} else {
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Bases).ToString() } class={ templ.KV("selected", urls.Bases == url) } role="tab" aria-selected="false" aria-controls="tab-content">Bases</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Factions).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Factions) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Factions</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Rephacks).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Rephacks) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Rephacks</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Commodities).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Commodities) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Commodities</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Guns).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Guns) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Guns</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.GunModifiers).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.GunModifiers) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Gun Modifiers</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Missiles).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Missiles) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Missiles</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Mines).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Mines) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Mines</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Shields).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Shields) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Shields</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Thrusters).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Thrusters) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Thrusters</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Ships).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Ships) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ships</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.ShipDetails).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.ShipDetails) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Ship Details</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Tractors).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Tractors) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Tractors</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + AllItemsUrl(urls.Engines).ToString() } class={ templ.KV("selected", AllItemsUrl(urls.Engines) == url) } role="tab" aria-selected="false" aria-controls="tab-content">Engines</button>
<button style="width:150px;" hx-get={ types.GetCtx(ctx).SiteRoot + urls.Bases.ToString() } role="tab" aria-selected="false" aria-controls="tab-content">Don't Show Empty</button>
}
</div>
}
<hr/>
Expand Down Expand Up @@ -269,3 +290,7 @@ func Buyable(Bases []configs_export.GoodAtBase) bool {

return false
}

func AllItemsUrl(url utils_types.FilePath) utils_types.FilePath {
return "all_" + url
}
4 changes: 2 additions & 2 deletions darkstat/front/shields.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func ShieldDetailedUrl(shield configs_export.Shield) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ ShieldT(shields []configs_export.Shield) {
@TabMenu(urls.Shields)
templ ShieldT(shields []configs_export.Shield,mode2 ShowEmpty) {
@TabMenu(urls.Shields, mode2)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
6 changes: 3 additions & 3 deletions darkstat/front/ships.templ
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const (

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ ShipsT(ships []configs_export.Ship, mode ShipTabMode) {
templ ShipsT(ships []configs_export.Ship, mode ShipTabMode, mode2 ShowEmpty) {
if mode == ShipShowBases {
@TabMenu(urls.Ships)
@TabMenu(urls.Ships, mode2)
} else if mode == ShipShowDetails {
@TabMenu(urls.ShipDetails)
@TabMenu(urls.ShipDetails, mode2)
}
@TabContent() {
<div class="splitter">
Expand Down
4 changes: 2 additions & 2 deletions darkstat/front/thrusters.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func ThrusterDetailedUrl(thruster configs_export.Thruster) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ ThrusterT(thrusters []configs_export.Thruster) {
@TabMenu(urls.Thrusters)
templ ThrusterT(thrusters []configs_export.Thruster, mode2 ShowEmpty) {
@TabMenu(urls.Thrusters, mode2)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions darkstat/front/tractors.templ
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func TractorDetailedUrl(tractor configs_export.Tractor) string {

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ TractorsT(tractors []configs_export.Tractor) {
@TabMenu(urls.Tractors)
templ TractorsT(tractors []configs_export.Tractor, mode2 ShowEmpty) {
@TabMenu(urls.Tractors, mode2)
@TabContent() {
<div class="splitter">
<div id="table-wrapper">
Expand Down
Loading

0 comments on commit 35365df

Please sign in to comment.