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:
@@ -81,6 +81,13 @@ func CompileList(pluginID string, ctl pact.AdminController, fsys fs.FS) (*ListSc
|
||||
}
|
||||
|
||||
func compileList(pluginID string, ctl pact.AdminController, fsys fs.FS) (*ListSchema, error) {
|
||||
return compileListWithTypes(pluginID, ctl, fsys, nil)
|
||||
}
|
||||
|
||||
// compileListWithTypes is compileList with the plugin field types of the
|
||||
// boot: a column may name a plugin alias as its type, and the list then
|
||||
// shows the type's ListValue for it.
|
||||
func compileListWithTypes(pluginID string, ctl pact.AdminController, fsys fs.FS, types *fieldTypeRegistry) (*ListSchema, error) {
|
||||
if ctl == nil {
|
||||
return nil, fmt.Errorf("cabana: admin schema %s: controller is nil", pluginID)
|
||||
}
|
||||
@@ -107,7 +114,7 @@ func compileList(pluginID string, ctl pact.AdminController, fsys fs.FS) (*ListSc
|
||||
if err != nil {
|
||||
return nil, bootErr(pluginID, ctl.ID(), cfgPath, err)
|
||||
}
|
||||
columns, err := compileColumns(pluginID, ctl, fsys, colPath)
|
||||
columns, err := compileColumns(pluginID, ctl, fsys, colPath, types)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -197,7 +204,7 @@ func compileList(pluginID string, ctl pact.AdminController, fsys fs.FS) (*ListSc
|
||||
return schema, nil
|
||||
}
|
||||
|
||||
func compileColumns(pluginID string, ctl pact.AdminController, fsys fs.FS, colPath string) ([]ListColumn, error) {
|
||||
func compileColumns(pluginID string, ctl pact.AdminController, fsys fs.FS, colPath string, types *fieldTypeRegistry) ([]ListColumn, error) {
|
||||
colRaw, err := readAsset(fsys, colPath)
|
||||
if err != nil {
|
||||
return nil, bootErr(pluginID, ctl.ID(), colPath, err)
|
||||
@@ -232,9 +239,15 @@ func compileColumns(pluginID string, ctl pact.AdminController, fsys fs.FS, colPa
|
||||
typ = inferred
|
||||
}
|
||||
}
|
||||
var pluginType *compiledFieldType
|
||||
if typ != "" {
|
||||
if _, known := listColumnTypes[typ]; !known {
|
||||
return nil, bootErr(pluginID, ctl.ID(), colPath, fmt.Errorf("unsupported column type %s", typ))
|
||||
if types != nil && !types.refuse {
|
||||
pluginType = types.byName[typ]
|
||||
}
|
||||
if pluginType == nil {
|
||||
return nil, bootErr(pluginID, ctl.ID(), colPath, fmt.Errorf("unsupported column type %s", typ))
|
||||
}
|
||||
}
|
||||
}
|
||||
if spec.Relation != "" || spec.Select != "" {
|
||||
@@ -267,6 +280,7 @@ func compileColumns(pluginID string, ctl pact.AdminController, fsys fs.FS, colPa
|
||||
Relation: spec.Relation,
|
||||
Select: spec.Select,
|
||||
Invisible: spec.Invisible,
|
||||
fieldType: pluginType,
|
||||
})
|
||||
}
|
||||
return compiled, nil
|
||||
|
||||
Reference in New Issue
Block a user