Skip to content

Report Builder: code-defined Bricks (fields + config schema) #521

Description

@nielsdrost7

Status 2026-07-13: implemented on feature/130-report-builder (#608) — as-built notes in the #130 status section.


Parent: #130 (Report Builder — bands + bricks). Phase 1. Part of epic #506, Track A.

Scope

Bricks are defined purely in code — there is no report_blocks table and no DB registry. Each brick is a class in app/Mason/Bricks/ extending Awcodes\Mason\Brick:

  • getId(), getLabel(), getIcon()
  • allowedBands(): array of ReportBand (header, group_header, details, group_footer, footer)
  • configureBrickAction() — slide-over Filament form defining the brick's config schema and defaults (e.g. show_vat_id, font_size)
  • toHtml(array $config, array $data) / toPreviewHtml(array $config) — rendered through blade views at resources/views/mason/bricks/<brick>/{index,preview}.blade.php, with all output escaped via {{ }}

Harvest the 17 existing bricks + views from feature/145-report-builder (Header: company, client, invoice-meta, quote-meta, project · Detail: items, invoice-product, quote-product, invoice-project, quote-project, expense, tasks, customer-aging · Footer: totals, summary, notes, terms). Add two utility bricks for #95: PageBreakBrick and SpacerBrick.

Discovery/registry: ReportBricksCollection (harvested), extended with a per-band filter.

Acceptance criteria

  • All bricks are discoverable via ReportBricksCollection with zero DB involvement.
  • Every brick declares allowedBands(); the collection can filter bricks by band.
  • Config values not present in a brick's schema are ignored at render time (unknown keys dropped).
  • Every brick view escapes output ({{ }} only — no {!! !!} for user-influenced data).
  • PageBreakBrick and SpacerBrick exist and are allowed in every band.

Test scenarios (PHPUnit, #[Test], no Pest)

  • Each brick renders expected HTML from a given config + data array (adapt the harvested MasonBricksTest).
  • ReportBricksCollection::forBand(ReportBand::DETAILS) excludes header/footer-only bricks.
  • Rendering with an unknown config key produces the same output as without it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinedRefined with SMART plan / test suggestions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions