feat(09-04): compile switch, date-range, and scope filters
- Filters keep typed values and only registered scope names - Raw conditions and arbitrary methods fail activation - Request localization copies labels and leaves identifiers unchanged
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"git.golem15.com/golem15/summercms/bouncer"
|
||||
"git.golem15.com/golem15/summercms/pact"
|
||||
"git.golem15.com/golem15/summercms/party"
|
||||
"git.golem15.com/golem15/summercms/phrasebook"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -140,10 +141,30 @@ func (s *service) listSchema(w http.ResponseWriter, r *http.Request) {
|
||||
if schema == nil {
|
||||
schema = &ListSchema{}
|
||||
}
|
||||
WriteData(w, http.StatusOK, schema, map[string]any{})
|
||||
view, err := schema.Localize(r.Context(), s.translator())
|
||||
if err != nil {
|
||||
WriteError(w, http.StatusInternalServerError, "error", msgServerError)
|
||||
return
|
||||
}
|
||||
meta := map[string]any{}
|
||||
if view.Meta != nil {
|
||||
meta["locale"] = view.Meta.Locale
|
||||
}
|
||||
WriteData(w, http.StatusOK, view, meta)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *service) translator() *phrasebook.Translator {
|
||||
if s == nil || s.app == nil {
|
||||
return nil
|
||||
}
|
||||
tr, ok := s.app.Lookup[*phrasebook.Translator]()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return tr
|
||||
}
|
||||
|
||||
func (s *service) list(w http.ResponseWriter, r *http.Request) {
|
||||
s.protect(w, r, func(cc *CompiledController) {
|
||||
db, err := s.db()
|
||||
|
||||
Reference in New Issue
Block a user