feat(board): name the cards after the model - #174
Open
grafst wants to merge 2 commits into
Open
Conversation
… hint The empty-column view lowercases the plural card label before it is interpolated, which reads naturally in English but breaks German, where nouns are always capitalised: the board showed "Keine datensätze in dieser Spalte". Use Laravel's capitalising placeholder in the German line so the label comes back capitalised. No other locale is affected.
The empty-column hint and the card counters always said "records", whatever the board actually holds. Boards know their model, and in a panel the model usually has a resource with proper (and translated) labels, so use those: an audiobook board now reads "No audiobooks in this column" instead of "No records in this column". Resolution order: an explicit cardLabel()/pluralCardLabel(), then the resource of the board page, then the resource registered for the model in the current panel, then the model name itself. Boards without a query keep the previous translated wording.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A board always calls its cards records:
But the board knows its model, and inside a panel that model usually has a resource with proper — and translated — labels. An audiobook board can just as well say:
What
BoardgainscardLabel()andpluralCardLabel(), and resolves the defaults in this order:cardLabel()/pluralCardLabel()(string or closure),BoardResourcePage),Filament::getModelResource()),Str::title(Str::snake(class_basename($model), ' '))).A board without a query — or outside a panel, where nothing can be resolved — keeps the existing
flowforge::flowforge.card_labelwording, so standalone usage is unchanged.Notes
HasCardLabelsconcern;Board::getViewData()just calls the getters, so the labels reach both the Blade views and the JS config as before.filament/filamentstays optional: the panel lookup is skipped when the facade is missing or no panel is current.tests/Feature/CardLabelTest.phpcovers all four resolution steps plus the rendered empty column. Full suite green (167 passed), PHPStan reports no new errors, Pint clean.Based on #173 — the German lang fix it contains is the first commit here and disappears from this diff once that one lands.