diff --git a/server/routes/device_validate_name.go b/server/routes/device_validate_name.go index 6934360..c15c53a 100644 --- a/server/routes/device_validate_name.go +++ b/server/routes/device_validate_name.go @@ -29,6 +29,15 @@ func (routes *Routes) DevicesValidateNameHTMX(rw http.ResponseWriter, req *http. Value: s, HXSwapOOB: true, } + + if s == "" { + slugData.Error = "Identifier resolves to empty value. Please set a valid identifier manually." + _ = nameComponent.Render(ctx, rw) + if err := adddevice.SlugInput(slugData).Render(ctx, rw); err != nil { + log.New(ctx).Err(err).Error("failed to render name input") + } + return + } exist, err := routes.API.DevicesValidateSlug(ctx, s) if err != nil { log.New(ctx).Err(err).Error("failed to validate slug") @@ -42,7 +51,6 @@ func (routes *Routes) DevicesValidateNameHTMX(rw http.ResponseWriter, req *http. if exist { slugData.Error = "Device with this identifier already exist. Please change the value manually." - // rw.WriteHeader(http.StatusConflict) _ = nameComponent.Render(ctx, rw) if err := adddevice.SlugInput(slugData).Render(ctx, rw); err != nil { log.New(ctx).Err(err).Error("failed to render name input") @@ -50,7 +58,7 @@ func (routes *Routes) DevicesValidateNameHTMX(rw http.ResponseWriter, req *http. return } - slugData.Valid = "Identifier is available" + slugData.Valid = "Identifier is available." _ = nameComponent.Render(ctx, rw) if err := adddevice.SlugInput(slugData).Render(ctx, rw); err != nil { diff --git a/views/components/image_card.templ b/views/components/image_card.templ index edc12b2..74ba6f2 100644 --- a/views/components/image_card.templ +++ b/views/components/image_card.templ @@ -10,8 +10,16 @@ func (o ImageCardOption) Has(opt ImageCardOption) bool { return o&opt != 0 } +func (o ImageCardOption) SetCond(opt ImageCardOption, cond bool) ImageCardOption { + if cond { + return o | opt + } + return o +} + const ( - HideTitle ImageCardOption = 1 << iota + HideNothing ImageCardOption = 0 + HideTitle ImageCardOption = 1 << iota HideSubreddit HidePoster HideDevice diff --git a/views/devicesview/adddevice/nsfw_checkbox.templ b/views/devicesview/adddevice/nsfw_checkbox.templ index 93d77f3..1e013e8 100644 --- a/views/devicesview/adddevice/nsfw_checkbox.templ +++ b/views/devicesview/adddevice/nsfw_checkbox.templ @@ -1,24 +1,37 @@ package adddevice +import "fmt" + type NSFWCheckboxData struct { Checked bool } templ NSFWCheckbox(data NSFWCheckboxData) { -