Skip to content

Commit

Permalink
Hide status indicators for entry types w/o status fields
Browse files Browse the repository at this point in the history
Resolves #15636
  • Loading branch information
brandonkelly committed Sep 2, 2024
1 parent 861123e commit bf9c66a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Category slugs are now inline-editable from the Categories index page. ([#15560](https://github.com/craftcms/cms/pull/15560))
- Entry post dates, expiry dates, slugs, and authors are now inline-editable from the Entries index page. ([#15560](https://github.com/craftcms/cms/pull/15560))
- Improved Addresses field validation to be more consistent with Matrix fields.
- Entry chips and cards no longer include status indicators, if their entry type’s “Show thet Status field” setting is disabled. ([#15636](https://github.com/craftcms/cms/discussions/15636))

### Accessibility
- Improved the accessibility of Tags fields.
Expand All @@ -30,6 +31,7 @@
### Extensibility
- Added `craft\base\ApplicationTrait::getEnvId()`. ([#15313](https://github.com/craftcms/cms/issues/15313))
- Added `craft\base\ElementInterface::getRootOwner()`. ([#15534](https://github.com/craftcms/cms/discussions/15534))
- Added `craft\base\ElementInterface::showStatusIndicator()`.
- Added `craft\elements\conditions\NotRelatedToConditionRule`.
- Added `craft\elements\conditions\SiteGroupConditionRule`.
- Added `craft\gql\arguments\RelationCriteria`.
Expand Down
8 changes: 8 additions & 0 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,14 @@ public function getChipLabelHtml(): string
return Html::encode($this->getUiLabel());
}

/**
* @inheritdoc
*/
public function showStatusIndicator(): bool
{
return static::hasStatuses();
}

/**
* @inheritdoc
*/
Expand Down
8 changes: 8 additions & 0 deletions src/base/ElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,14 @@ public function setUiLabelPath(array $path): void;
*/
public function getChipLabelHtml(): string;

/**
* Returns whether chips and cards for this element should include a status indicator.
*
* @return bool
* @since 5.4.0
*/
public function showStatusIndicator(): bool;

/**
* Returns the body HTML for element cards.
*
Expand Down
8 changes: 8 additions & 0 deletions src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,14 @@ public function getChipLabelHtml(): string
]);
}

/**
* @inheritdoc
*/
public function showStatusIndicator(): bool
{
return $this->getType()->showStatusField;
}

/**
* @inheritdoc
*/
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public static function elementChipHtml(ElementInterface $element, array $config
$config['attributes'],
);

$config['showStatus'] = $config['showStatus'] && ($element->getIsDraft() || $element::hasStatuses());
$config['showStatus'] = $config['showStatus'] && ($element->getIsDraft() || $element->showStatusIndicator());

if ($config['showLabel']) {
$config['labelHtml'] = self::elementLabelHtml(
Expand Down Expand Up @@ -611,7 +611,7 @@ public static function elementCardHtml(ElementInterface $element, array $config
$bodyContent = $element->getCardBodyHtml() ?? '';

$labels = array_filter([
$element::hasStatuses() ? static::componentStatusLabelHtml($element) : null,
$element->showStatusIndicator() ? static::componentStatusLabelHtml($element) : null,
$element->isProvisionalDraft ? self::changeStatusLabelHtml() : null,
]);

Expand Down

0 comments on commit bf9c66a

Please sign in to comment.