UI
Baked introduces a metadata generation template which can be used to transform the business domain to UI metadata to be used in dynamic UI applications.
app.Layers.AddUi();
UiLayer provides IComponentDescriptor, IComponentSchema, IData types for
building UI page metadata. A page metadata will have a component descriptor
(represented by a ComponentDescriptorAttribute instance) at the top in the
hierarchy containing Type, Schema, Name and Data properties.
The generated UI metadata files will be saved to
Uifolder at$(OutDir)of your project, you can add below properties to your.csprojfile to copy generated files to given directory<PropertyGroup> <CopyComponentDescriptors>true</CopyComponentDescriptors> <UiAppDir>$(ProjectDir)..\admin</UiAppDir> </PropertyGroup>
Configuration Targets
This layer provides AppDescriptor, ComponentExports, LayerDescriptors
and PageDescriptors configuration target for registering pages using
ComponentDescriptor instances.
AppDescriptor
This target is provided in GenerateCode phase. To configure it in a feature;
configurator.ConfigureAppDescriptor(app =>
{
...
});
ComponentExports
This target is provided in GenerateCode phase. To configure it in a feature;
configurator.ConfigureComponentExports(exports =>
{
...
});
LayoutDescriptors
This target is provided in GenerateCode phase. To configure it in a feature;
configurator.ConfigureLayoutDescriptors(layouts =>
{
...
});
PageDescriptors
This target is provided in GenerateCode phase. To configure it in a feature;
configurator.ConfigurePageDescriptors(pages =>
{
...
});
To access the localization function from a feature use below extension method.
configurator.UsingLocalization(l => { // use this function to add that key to UI project; // l("A localized message") ... });Each call to this function will result
UiLayerto bring that value of given key for every language to the UI project under.baked/folder, e.g.,.baked/locale.en.jsonfile.
To access which keys are going to be brought to UI project from a feature, you can use
UsingLocaleTemplatefunction.configurator.UsingLocaleTemplate(localeTemplate => { ... });
Descriptor Builder System
To generate a page descriptor from a domain model, we provide a descriptor builder system that is added through domain model conventions. There are two builder attributes for this purpose;
ComponentDescriptorBuilderAttribute<TComponentSchema>DescriptorBuilderAttribute<TSchema>
The page generator starts with a Page component path to render a domain model
into a ComponentDescriptor<TComponentSchema> instance. To add a component to a
domain model, usually to a type, use the AddTypeComponent extension of
IDomainModelConventionCollection;
configurator.ConfigureDomainModelBuilder(builder =>
{
builder.Conventions.AddTypeComponent(
component: (c, cc) => ...,
whenType: c => c.Type...,
whenComponent: cc => cc.Path.EndsWith("Page")
);
});
component:is a builder function that takesTypeModelMetadataContext candComponentContext ccas parameters, and is expected to return aComponentDescriptor<TComponentSchema>instance, such asComponentDescriptor<ReportPage>whenType:is a predicate function that takesTypeModelMetadataContext cas a parameter and is used as a filter to choose which types this convention applies towhenComponent:is a predicate funtion that takesComponentContext ccas a parameter and is used as a filter to determine at which component path this convention should be applied
AddPropertyComponent, AddMethodComponent and AddParameterComponent
extensions works the same way, except instead of whenType: they accept
whenProperty:, whenMethod: and whenParameter: respectively.
Once you add a component for a domain model at a specific component path, it
will return that component instance when asked at that component path. You may
use GetComponent extension to ask for a component during a component build.
For example, below call asks for a component at ../title path for the type;
type.GetComponent(cc.Drill("Title"))
ComponentContexthas aDrill(...)method that enables you to navigate deeper into component paths.
GetRequiredComponentis also provided to ensure that a component exists at the speficied path for the domain model. Otherwise, it will cause a generation error during post-build phase ofdotnet build.
For non-component schemas, similar extensions are provided for domain models;
AddTypeSchemaAddPropertySchemaAddMethodSchemaAddParameterSchema
Use these extensions to associate domain models with non-component schemas such
as ReportPage.Tab or Parameter. Once you add a schema for a domain model,
you can access it using GetSchema<TSchema> or GetSchemas<TSchema> extension
methods.
GetRequiredSchema<TSchema>is also provided to ensure that a schema exists at that path for that domain model. Otherwise, it will cause a generation error during post-build phase ofdotnet build.
Configuring Existing Schemas
To add a convention that configures an existing schema, there are
Add...ComponentConfiguration<TComponentSchema> and
Add...SchemaConfiguration<TSchema> helpers.