orchidsoftware / orchidsoftware/platform

Add multiple info rows (more than one totals row) to the table

Open
#2,358 1 comment 0 reactions 1 assignee View on GitHub

@tabuna is already working on this.

Since Sep 6, 2022.

Improvements
Dominant language
PHP
Stars
4.8k
Forks
662
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Is your feature request related to a problem? Please describe.
We now have a working row with totals for the Table layout. As explained in #1205:

The obvious disadvantage of this approach is the impossibility of specifying several lines at once. This can be a problem in the indication of any invoices when it is necessary to show tax and price in separate lines.

Describe the solution you'd like
I propose an additional method infoRows. Each element of the returned array is a row represented by an array (could be replaced by a TR class that acts as a container) of TD cells. Similar as in #1205 I propose to ignore the "target" property for them.

protected function infoRows(): array
{
    return [
        [
            TD::make()
                ->align(TD::ALIGN_RIGHT)
                ->colspan(3)
                ->render(function () {
                    return __('Tax') . ':';
                }),
            TD::make('tax')
                ->colspan(2),
        ],
        [
            TD::make()
                ->align(TD::ALIGN_RIGHT)
                ->colspan(3)
                ->render(function () {
                    return __('Discount') . ':';
                }),
            TD::make('discount')
                ->colspan(2),
        ],
        [
            TD::make()
                ->canSee(false)
                ->align(TD::ALIGN_RIGHT)
                ->colspan(3)
                ->render(function () {
                    return __('Total') . ':';
                }),
            TD::make('total')
                ->colspan(2),
        ],
    ];
}

Additional context
This also should not break compatibility. A possible solution is the following:

In table.blade.php

@if($infoRows->isNotEmpty())
    @foreach($infoRows as $infoRow)
        <tr>
            @foreach($infoRow as $column)
                {!! $column->buildTd($repository, $loop) !!}
            @endforeach
        </tr>
    @endforeach
@endif

In the Table class, method build:

$infoRows = collect($this->infoRows())->map(static function ($row) {
    return collect($row)->filter(static function (TD $column) {
        return $column->isSee();
    });
});

...

return view($this->template, [
...
    'infoRows' => $infoRows,
...
];

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.