Enhance admin UI and schema management: Introduce generic handling for image/asset URL fields, ensuring explicit widget usage for image previews. Update translations for new UI elements and implement field ordering in schema definitions. Add functionality for managing field extensions and improve asset filtering in the admin UI.
This commit is contained in:
@@ -368,6 +368,51 @@ pub async fn get_collection_schema(
|
||||
Ok(Json(serde_json::to_value(schema).unwrap()))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GET /api/schemas – list all type names (including reusable, for extends dropdown)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn list_schema_names(
|
||||
State(state): State<Arc<AppState>>,
|
||||
) -> Json<Value> {
|
||||
let names: Vec<String> = {
|
||||
let registry = state.registry.read().await;
|
||||
registry.names()
|
||||
};
|
||||
Json(json!({ "names": names }))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GET /api/schemas/:name/raw – schema as stored on disk (own fields + extends, unresolved)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn get_schema_raw(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Path(name): Path<String>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let path_json5 = state.types_dir.join(format!("{}.json5", name));
|
||||
let path_json = state.types_dir.join(format!("{}.json", name));
|
||||
let path = if path_json5.exists() {
|
||||
path_json5
|
||||
} else if path_json.exists() {
|
||||
path_json
|
||||
} else {
|
||||
return Err(ApiError::NotFound(format!("Schema '{}' not found", name)));
|
||||
};
|
||||
let content = tokio::fs::read_to_string(&path)
|
||||
.await
|
||||
.map_err(|e| ApiError::Internal(format!("Failed to read schema file: {}", e)))?;
|
||||
let schema: SchemaDefinition = json5::from_str(&content)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid schema file: {}", e)))?;
|
||||
if schema.name != name {
|
||||
return Err(ApiError::BadRequest(format!(
|
||||
"Schema file name mismatch: expected '{}', got '{}'",
|
||||
name, schema.name
|
||||
)));
|
||||
}
|
||||
Ok(Json(serde_json::to_value(schema).unwrap()))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GET /api/collections/:collection/slug-check?slug=xxx&exclude=yyy&_locale=zzz
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user