Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions mdl-examples/doctype-tests/36-building-block-examples.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

-- MARK: List building blocks

-- List every building block in the project.
-- List every building block in the project (empty on a project with none).
show building blocks;

-- Filter building blocks by module.
show building blocks in MyModule;

-- MARK: Describe a building block

-- Describe a single building block (header comment + widget tree).
describe building block MyModule.LoginForm;
--
-- DESCRIBE prints a header comment + the widget tree. It is NOT exercised here
-- because it errors on a project that has no such block ("building block not
-- found"), and a fresh test project ships none. Against a project that contains
-- building blocks, run e.g.:
--
-- describe building block Atlas_Web_Content.HelloWorld;
--
-- You can also query them from the catalog:
--
-- select QualifiedName, Platform, Category from CATALOG.building_blocks;
24 changes: 24 additions & 0 deletions mdl/backend/modelsdk/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ func (b *Backend) ListSnippets() ([]*pages.Snippet, error) {
return out, nil
}

// ListBuildingBlocks reads Pages$BuildingBlock units. Read-only: the codec engine
// lists them (name + scalar metadata) so SHOW / DESCRIBE BUILDING BLOCK work on
// this engine too; the widget tree is read separately via GetRawUnit (shared).
func (b *Backend) ListBuildingBlocks() ([]*pages.BuildingBlock, error) {
units, err := mprread.ListUnitsWithContainer[*genPg.BuildingBlock](b.reader)
if err != nil {
return nil, err
}
out := make([]*pages.BuildingBlock, 0, len(units))
for _, u := range units {
bb := &pages.BuildingBlock{
ContainerID: u.ContainerID,
Name: u.Element.Name(),
Documentation: u.Element.Documentation(),
DisplayName: u.Element.DisplayName(),
Platform: u.Element.Platform(),
TemplateCategory: u.Element.TemplateCategory(),
}
bb.ID = model.ID(u.Element.ID())
out = append(out, bb)
}
return out, nil
}

func pageFromGen(p *genPg.Page, containerID model.ID) *pages.Page {
out := &pages.Page{
ContainerID: containerID,
Expand Down
Loading