feat(admin): edit category content in the admin form behind the HTML gate

- add a content textarea (size huge) after description, with en and pl phrases
- add content to Category.Fillable
- export classes.CheckHTML and run it from FormBeforeCreate and FormBeforeUpdate:
  unsafe category content answers 422 on content, blank content is stored as NULL
This commit is contained in:
2026-10-09 16:26:12 +02:00
parent 740dcd086d
commit f22d08902e
10 changed files with 249 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ func (Category) TranslatableIndexes() []string { return []string{"slug"} }
// Fillable is JOURNAL-002: nest_* stay out of mass assignment.
func (Category) Fillable() []string {
return []string{"name", "slug", "code", "description", "parent_id"}
return []string{"name", "slug", "code", "description", "content", "parent_id"}
}
func (Category) Rules() map[string]string {

View File

@@ -22,3 +22,9 @@ fields:
type: mltextarea
size: large
span: full
content:
label: golem15.journal::lang.category.content
comment: golem15.journal::lang.category.content_comment
type: textarea
size: huge
span: full

View File

@@ -39,7 +39,7 @@ func TestFillable(t *testing.T) {
})
t.Run("category_excludes_nest", func(t *testing.T) {
if got := (models.Category{}).Fillable(); !reflect.DeepEqual(got, []string{"name", "slug", "code", "description", "parent_id"}) {
if got := (models.Category{}).Fillable(); !reflect.DeepEqual(got, []string{"name", "slug", "code", "description", "content", "parent_id"}) {
t.Fatalf("Category.Fillable = %#v", got)
}
left := 3
@@ -48,6 +48,7 @@ func TestFillable(t *testing.T) {
"name": "Essays",
"slug": "essays",
"code": "ess",
"content": "<p>Essay hub</p>",
"nest_left": 9,
"nest_right": 10,
"nest_depth": 2,
@@ -58,6 +59,9 @@ func TestFillable(t *testing.T) {
if cat.Name != "Essays" || cat.Slug != "essays" {
t.Fatalf("category fill = %+v", cat)
}
if cat.Content == nil || *cat.Content != "<p>Essay hub</p>" {
t.Fatalf("category content fill = %#v", cat.Content)
}
if cat.ID != 0 {
t.Fatalf("id was mass-assigned: %d", cat.ID)
}