feat(14.2.1-03): add markdown and multilingual cabana fields
Lift locale maps before ProjectWritableFields so a Journal-shaped save can persist the default host scalar and non-default locales through TranslationWriter without dropping nested JSON. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,9 @@ type CRUDService struct {
|
||||
// commit; tr localizes the file limit messages. Both may be nil.
|
||||
bucket *blob.Bucket
|
||||
tr *phrasebook.Translator
|
||||
// writer persists non-default locale values for mltext/mlmarkdown fields.
|
||||
// Nil when the translate plugin is not mounted.
|
||||
writer TranslationWriter
|
||||
}
|
||||
|
||||
// RecordInput is a decoded JSON object. Keys are untrusted. SessionKey is
|
||||
@@ -588,6 +591,13 @@ func (s CRUDService) save(ctx context.Context, cc *CompiledController, id any, i
|
||||
if err != nil {
|
||||
return RecordResult{}, err
|
||||
}
|
||||
// ML locale maps are lifted before scalar projection, which drops every
|
||||
// nested value. The default-locale string is written back onto the body
|
||||
// so Fill sees a host scalar.
|
||||
translations, err := liftMLValues(ctx, cc, in.Body, op, s.writer, s.DB)
|
||||
if err != nil {
|
||||
return RecordResult{}, err
|
||||
}
|
||||
var result RecordResult
|
||||
err = s.transaction(ctx, func(ctx context.Context, tx *gorm.DB) error {
|
||||
ctx = withVirtualFields(withTx(ctx, tx), virtual)
|
||||
@@ -670,6 +680,11 @@ func (s CRUDService) save(ctx context.Context, cc *CompiledController, id any, i
|
||||
if err != nil {
|
||||
return lifecycleFailure(cc, err)
|
||||
}
|
||||
// Non-default locales are written only after the host row has an id
|
||||
// and after permission, query scope, and relation locks have passed.
|
||||
if err := applyMLTranslations(ctx, tx, s.writer, target, translations); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := syncBelongsToMany(ctx, tx, cc, target, relations); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1202,7 +1217,8 @@ func modelColumns(model any) map[string]struct{} {
|
||||
|
||||
func scalarFormField(typ string) bool {
|
||||
switch typ {
|
||||
case "text", "textarea", "number", "checkbox", "switch", "dropdown", "datepicker":
|
||||
case "text", "textarea", "number", "checkbox", "switch", "dropdown", "datepicker",
|
||||
"markdown", "mltext", "mlmarkdown":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user