feat(14.2.1-05): hydrate ML create/GET/save through TranslatedExact

Form schema meta lists enabled locales, Show/save expand mltext maps
without D-11 fallback, and the SPA seeds and adopt-merges every locale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 15:37:00 +02:00
parent ed81f2a0c1
commit 0f8d13738d
11 changed files with 309 additions and 34 deletions

View File

@@ -709,10 +709,16 @@ func (s *service) formSchema(w http.ResponseWriter, r *http.Request) {
}
view.Fields = kept
view.Assets = s.controllerAssets(cc)
if codes := s.enabledContentLocales(r.Context()); len(codes) > 0 {
view.Meta.EnabledLocales = append([]string(nil), codes...)
}
meta := map[string]any{}
if view.Meta.Locale != "" {
meta["locale"] = view.Meta.Locale
}
if len(view.Meta.EnabledLocales) > 0 {
meta["enabledLocales"] = view.Meta.EnabledLocales
}
WriteData(w, http.StatusOK, view, meta)
})
}
@@ -939,6 +945,29 @@ func (s *service) crud() (CRUDService, error) {
return svc, nil
}
// enabledContentLocales is TranslationWriter.EnabledLocales after the same
// Lookup crud() uses. Empty when the adapter is unpublished or the query
// fails; list schemas never call this.
func (s *service) enabledContentLocales(ctx context.Context) []string {
if s == nil || s.app == nil {
return nil
}
writer, ok := s.app.Lookup[TranslationWriter]()
if !ok || writer == nil {
return nil
}
db, err := s.db()
if err != nil {
return nil
}
codes, err := writer.EnabledLocales(ctx, db)
if err != nil {
slog.Error("cabana: enabled locales", "error", err)
return nil
}
return codes
}
func (s *service) list(w http.ResponseWriter, r *http.Request) {
s.protect(w, r, func(cc *CompiledController) {
db, err := s.db()