feat(16.2-01): translatable plugin field types, untouched skip, writes, list values and uploads
- translatable types lift, store and hydrate through the ML path
(isMLField); Decode and Load run per locale and notices carry the locale
- on update a value equal to the served value (Load of the stored host
value or exact translation) is neither decoded nor written
- FieldWrite, FieldWritesFromContext and WithFieldWrites expose what a save
writes to the Form hooks
- list columns may use a plugin alias and show the type's ListValue
- POST .../{id}/fields/{field}/upload hands the file to the type's Upload
(guard, X-Requested-With, permissions, field context, record scope, body
cap); OpenAPI, route inventories, README and docs updated
This commit is contained in:
@@ -52,6 +52,13 @@ func mlFieldType(typ string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isMLField reports whether a form field's value is a locale map stored
|
||||
// through the translation writer: a built-in ML type (mlFieldType) or a
|
||||
// translatable plugin field type (pact.FormFieldType.Translatable).
|
||||
func isMLField(field FormField) bool {
|
||||
return mlFieldType(field.Type) || (field.fieldType != nil && field.fieldType.def.Translatable)
|
||||
}
|
||||
|
||||
// liftMLValues takes declared mltext/mltextarea/mlmarkdown maps out of a save body
|
||||
// before ProjectWritableFields drops nested values. Only fields present in
|
||||
// the body whose context allows op are lifted. A value must be a JSON object
|
||||
@@ -64,7 +71,7 @@ func liftMLValues(ctx context.Context, cc *CompiledController, body map[string]a
|
||||
}
|
||||
var names []string
|
||||
for _, field := range cc.Form.Fields {
|
||||
if !mlFieldType(field.Type) || !contextAllows(cc, field.Name, op) {
|
||||
if !isMLField(field) || !contextAllows(cc, field.Name, op) {
|
||||
continue
|
||||
}
|
||||
if _, present := body[field.Name]; present {
|
||||
@@ -186,7 +193,7 @@ func hydrateMLRecord(ctx context.Context, tx *gorm.DB, cc *CompiledController, w
|
||||
}
|
||||
var names []string
|
||||
for _, field := range cc.Form.Fields {
|
||||
if !mlFieldType(field.Type) || !contextAllows(cc, field.Name, op) {
|
||||
if !isMLField(field) || !contextAllows(cc, field.Name, op) {
|
||||
continue
|
||||
}
|
||||
names = append(names, field.Name)
|
||||
|
||||
Reference in New Issue
Block a user