Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Update API to reflect changes in silverstripe/framework #479

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions _config/versionedgridfield.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ SilverStripe\Forms\GridField\GridFieldDetailForm:
# Add status row to gridfields by default
SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor:
extensions:
- SilverStripe\Versioned\VersionedGridFieldStateExtension
- SilverStripe\Versioned\VersionedGridFieldArchiveExtension
SilverStripe\Forms\GridField\GridFieldConfig_Base:
extensions:
- SilverStripe\Versioned\VersionedGridFieldStateExtension
SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor:
extensions:
- SilverStripe\Versioned\VersionedGridFieldStateExtension
- SilverStripe\Versioned\VersionedGridFieldArchiveExtension
# Enable gridfield extensions for dataobjects by default
SilverStripe\ORM\DataObject:
Expand Down
38 changes: 38 additions & 0 deletions src/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -2981,4 +2981,42 @@ public function Publisher()
$member = DataObject::get_by_id(Member::class, $this->owner->PublisherID);
return $member;
}

protected function updateStatusFlags(array &$flags): void
{
if ($this->isOnLiveOnly()) {
$flags['removedfromdraft'] = [
'text' => _t(__CLASS__ . '.FLAG_ONLIVEONLY_SHORT', 'On live only'),
'title' => _t(
__CLASS__ . '.FLAG_ONLIVEONLYSHORT_HELP',
'Item is published, but has been deleted from draft'
),
];
return;
}

if ($this->isArchived()) {
$flags['archived'] = [
'text' => _t(__CLASS__ . '.FLAG_ARCHIVED_SHORT', 'Archived'),
'title' => _t(__CLASS__ . '.FLAG_ARCHIVED_HELP', 'Item is removed from draft and live'),
];
return;
}

if ($this->isOnDraftOnly()) {
$flags['addedtodraft'] = [
'text' => _t(__CLASS__ . '.FLAG_ADDEDTODRAFT_SHORT', 'Draft'),
'title' => _t(__CLASS__ . '.FLAG_ADDEDTODRAFT_HELP', 'Item has not been published yet')
];
return;
}

if ($this->isModifiedOnDraft()) {
$flags['modified'] = [
'text' => _t(__CLASS__ . '.FLAG_MODIFIEDONDRAFT_SHORT', 'Modified'),
'title' => _t(__CLASS__ . '.FLAG_MODIFIEDONDRAFT_HELP', 'Item has unpublished changes'),
];
return;
}
}
}
58 changes: 0 additions & 58 deletions src/VersionedGridFieldItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\TabSet;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Model\ArrayData;
use SilverStripe\View\SSViewer;

/**
Expand All @@ -26,29 +23,6 @@
*/
class VersionedGridFieldItemRequest extends GridFieldDetailForm_ItemRequest
{
public function Breadcrumbs($unlinked = false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done via the template for all LeftAndMain breadcrumbs now instead.

{
$items = parent::Breadcrumbs($unlinked);
$status = $this->getRecordStatus();
$badge = null;
if ($status) {
// 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) {
$lastItem = $items->last();
$lastItem->setField('Extra', $badge);
}

return $items;
}

/**
* @return FieldList
*/
Expand Down Expand Up @@ -244,38 +218,6 @@ protected function setFormMessage($form, $message)
}
}

/**
* Return list of class / title to add on the end of record status in breadcrumbs
*
* @return array|null
*/
protected function getRecordStatus()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in Versioned::updateStatusFlags() instead

{
/** @var DataObject|Versioned $record */
$record = $this->record;

// No status if un-versioned
if (!$this->record->hasExtension(Versioned::class)) {
return null;
}

if ($record->isOnDraftOnly()) {
return [
'class' => 'addedtodraft',
'title' => _t(__CLASS__ . '.DRAFT', 'Draft')
];
}

if ($record->isModifiedOnDraft()) {
return [
'class' => 'modified',
'title' => _t(__CLASS__ . '.MODIFIED', 'Modified')
];
}

return null;
}

/**
* Getting buttons that are for versioned objects
*
Expand Down
239 changes: 0 additions & 239 deletions src/VersionedGridFieldState/VersionedGridFieldState.php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in GridFieldDataColumns directly instead

This file was deleted.

Loading
Loading