Skip to content

Commit

Permalink
ENH Updated UI for versioned objects and all its versioned relations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Dec 21, 2023
1 parent d5faa01 commit 11391a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\Hierarchy\Hierarchy;
Expand Down Expand Up @@ -1089,6 +1090,29 @@ public function Breadcrumbs($unlinked = false)
]));
}

$badge = null;

if ($record->stagesDifferRecursive()) {
$status = [
'class' => 'modified',
'title' => _t(__CLASS__ . '.MODIFIED', 'Modified'),
];
// Generate badge
$badge = DBField::create_field('HTMLFragment', sprintf(
'<span class="badge version-status version-status--%s">%s</span>',
$status['class'],
$status['title']
));
}

$this->extend('updateBadge', $badge);

if ($badge) {
/** @var ArrayData $lastItem */
$lastItem = $items->last();
$lastItem->setField('Extra', $badge);
}

$this->extend('updateBreadcrumbs', $items);

return $items;
Expand Down
4 changes: 2 additions & 2 deletions code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ public function getCMSActions()
// Get status of page
$isOnDraft = $this->isOnDraft();
$isPublished = $this->isPublished();
$stagesDiffer = $this->stagesDiffer();
$stagesDiffer = $this->stagesDifferRecursive();

// Check permissions
$canPublish = $this->canPublish();
Expand Down Expand Up @@ -2960,7 +2960,7 @@ public function getStatusFlags($cached = true)
'text' => _t(__CLASS__.'.ADDEDTODRAFTSHORT', 'Draft'),
'title' => _t(__CLASS__.'.ADDEDTODRAFTHELP', "Page has not been published yet")
];
} elseif ($this->isModifiedOnDraft()) {
} elseif ($this->isModifiedOnDraft() || $this->stagesDifferRecursive()) {
$flags['modified'] = [
'text' => _t(__CLASS__.'.MODIFIEDONDRAFTSHORT', 'Modified'),
'title' => _t(__CLASS__.'.MODIFIEDONDRAFTHELP', 'Page has unpublished changes'),
Expand Down

0 comments on commit 11391a0

Please sign in to comment.