Master-Detail Adapter

Adapter for integrating cjm-fasthtml-interactions MasterDetail pattern into settings

Settings Detail Renderer

This function renders the detail content for a settings schema using the standard settings form.


source

create_settings_detail_renderer

 create_settings_detail_renderer (config_dir:pathlib.Path,
                                  save_route_fn:<built-
                                  infunctioncallable>,
                                  reset_route_fn:<built-
                                  infunctioncallable>)

*Create a render function for settings detail view.

This creates a closure that captures the config_dir and route functions, returning a render function compatible with DetailItem.*

Type Details
config_dir Path Configuration directory
save_route_fn callable Function that returns save route URL for schema_id
reset_route_fn callable Function that returns reset route URL for schema_id
Returns callable Render function for detail view

Settings Data Loader

This function creates a data loader that provides schema information to the render function.


source

create_settings_data_loader

 create_settings_data_loader (schema:Dict, schema_id:str)

Create a data loader that provides schema information.

Type Details
schema Dict JSON schema
schema_id str Schema identifier
Returns callable Data loader function

Configuration Badge Helper

Check if a schema has been configured (config file exists).


source

is_schema_configured

 is_schema_configured (schema_id:str, config_dir:pathlib.Path)

Check if a schema has been configured.

Type Details
schema_id str Schema identifier
config_dir Path Configuration directory
Returns bool True if config file exists

Settings Master-Detail Creator

This is the main adapter function that creates a MasterDetail instance configured for settings.


source

create_settings_master_detail

 create_settings_master_detail (schemas:Dict, config_dir:pathlib.Path,
                                save_route_fn:<built-infunctioncallable>,
                                reset_route_fn:<built-infunctioncallable>,
                                default_schema:str='general',
                                menu_section_title:str='Settings',
                                plugin_registry:Optional[Any]=None,
                                plugin_save_route_fn:Optional[<built-
                                infunctioncallable>]=None,
                                plugin_reset_route_fn:Optional[<built-
                                infunctioncallable>]=None)

*Create a MasterDetail instance configured for settings.

This adapter function transforms the settings schema structure into DetailItem and DetailItemGroup objects compatible with MasterDetail.*

Type Default Details
schemas Dict All registered schemas (from registry.get_all())
config_dir Path Configuration directory
save_route_fn callable Function that returns save route URL for schema_id
reset_route_fn callable Function that returns reset route URL for schema_id
default_schema str general Default schema to show
menu_section_title str Settings Title for master list
plugin_registry Optional None Optional plugin registry
plugin_save_route_fn Optional None Function that returns save route URL for plugin_id
plugin_reset_route_fn Optional None Function that returns reset route URL for plugin_id
Returns MasterDetail Configured MasterDetail instance

Usage Example

# Example: Create settings master-detail
from pathlib import Path
from cjm_fasthtml_settings.core.schemas import registry
from cjm_fasthtml_settings.core.config import get_app_config_schema

# Register a sample schema
registry.register(get_app_config_schema(app_title="Test App", include_theme=False))

# Create the master-detail interface
settings_md = create_settings_master_detail(
    schemas=registry.get_all(),
    config_dir=Path("configs"),
    save_route_fn=lambda id: f"/settings/save?id={id}",
    reset_route_fn=lambda id: f"/settings/reset?id={id}",
    default_schema="general",
    menu_section_title="Settings"
)

print(f"Settings master-detail created with {len(settings_md.item_index)} items")
print(f"Items: {list(settings_md.item_index.keys())}")
Settings master-detail created with 1 items
Items: ['general']