Skip to content

Commit

Permalink
Generating initial detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus committed Mar 31, 2024
1 parent 50d695d commit 3623598
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/nrp_devtools/commands/ui/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def create_model_ui(config: OARepoConfig, *, ui_name: str):
capitalized_name = caseconverter.camelcase(ui_config.name)
capitalized_name = capitalized_name[0].upper() + capitalized_name[1:]

model_name = ui_config.model
prefix = model_name.capitalize()

run_cookiecutter(
config.ui_dir,
template=Path(__file__).parent.parent.parent / "templates" / "ui_model",
Expand All @@ -65,16 +68,16 @@ def create_model_ui(config: OARepoConfig, *, ui_name: str):
"resource_config": capitalized_name + "ResourceConfig",
"ui_serializer_class": ui_config.ui_serializer_class,
"api_service": ui_config.api_service,
"root_component": prefix + "DetailRoot",
},
)

model_name = ui_config.model
model_config: ModelConfig = config.get_model(model_name)

ui_file = config.repository_dir / model_config.model_package / 'models' / 'ui.json'
ui_components_dir = config.ui_dir / ui_config.name / 'templates' / 'semantic-ui' / 'components'
ui_components_dir.mkdir(parents=True, exist_ok=True)
create_detail_page(ui_file, ui_components_dir, model_name.capitalize())
create_detail_page(ui_file, ui_components_dir, prefix)


def register_model_ui(config: OARepoConfig, *, ui_name: str):
Expand Down
3 changes: 2 additions & 1 deletion src/nrp_devtools/templates/ui_model/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"resource": "",
"resource_config": "",
"ui_serializer_class": "",
"api_service": ""
"api_service": "",
"root_component": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- endblock %}

{% block record_main_content %}
Add your main content here
<{% endraw %}{{root_component}}{% raw %} d={d}>
{% endblock %}

{% block record_sidebar %}
Expand Down

0 comments on commit 3623598

Please sign in to comment.