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

FIX ModelAdmin toast elements #424

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: 3 additions & 2 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ en:
db_Version: Version
has_many_Versions: Versions
SilverStripe\Versioned\VersionedGridFieldItemRequest:
Archived: 'Archived {name} {title}'
Archived: 'Archived {name} "{title}"'
BUTTONAPPLYCHANGES: 'Apply changes'
BUTTONARCHIVEDESC: 'Unpublish and send to archive'
BUTTONPUBLISHED: Published
Expand All @@ -78,7 +78,8 @@ en:
MODIFIED: Modified
MoreOptions: 'More options'
Published: 'Published {name} {link}'
Unpublished: 'Unpublished {name} {title}'
Unpublished: 'Unpublished {name} "{title}"'
PUBLISHEDTOASTMESSAGE: 'Published {type} "{title}"'
SilverStripe\Versioned\VersionedGridFieldState\VersionedGridFieldState:
ADDEDTODRAFTHELP: 'Item has not been published yet'
ADDEDTODRAFTSHORT: Draft
Expand Down
21 changes: 18 additions & 3 deletions src/VersionedGridFieldItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function doArchive($data, $form)

$message = _t(
__CLASS__ . '.Archived',
'Archived {name} {title}',
'Archived {name} "{title}"',
[
'name' => $record->i18n_singular_name(),
'title' => Convert::raw2xml($title)
Expand All @@ -144,7 +144,7 @@ public function doArchive($data, $form)
//when an item is deleted, redirect to the parent controller
$controller = $this->getToplevelController();
$controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh

$controller->getResponse()->addHeader('X-Status', $message);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
return $controller->redirect($this->getBackLink(), 302); //redirect back to admin section
}

Expand Down Expand Up @@ -183,6 +183,18 @@ public function doPublish($data, $form)
);
$this->setFormMessage($form, $message);

$message = _t(
__CLASS__ . '.PUBLISHEDTOASTMESSAGE',
'Published {type} "{title}"',
[
'type' => $record->i18n_singular_name(),
'title' => Convert::raw2xml($record->Title)
]
);

$controller = $this->getToplevelController();
$controller->getResponse()->addHeader('X-Status', $message);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

return $this->redirectAfterSave($isNewRecord);
}

Expand All @@ -207,14 +219,17 @@ public function doUnpublish($data, $form)

$message = _t(
__CLASS__ . '.Unpublished',
'Unpublished {name} {title}',
'Unpublished {name} "{title}"',
[
'name' => $record->i18n_singular_name(),
'title' => Convert::raw2xml($title)
]
);
$this->setFormMessage($form, $message);

$controller = $this->getToplevelController();
$controller->getResponse()->addHeader('X-Status', $message);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

// Redirect back to edit
return $this->redirectAfterSave(false);
}
Expand Down