Skip to content
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
3 changes: 3 additions & 0 deletions config/bolt/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,6 @@ reset_password_settings:

# Adds sorting and filtering of users in backend
user_show_sort&filter: true

# Use Ajaxy saving ("Stay on page"), or traditional saving
ajaxy_saving: true
26 changes: 17 additions & 9 deletions src/Controller/Backend/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,23 @@ public function save(?Content $originalContent = null, ?ContentValidatorInterfac

$locale = $originalAuthor->getLocale();

return new JsonResponse([
'url' => $url,
'status' => 'success',
'type' => $this->translator->trans('success', [], null, $locale),
'message' => $this->translator->trans('content.updated_successfully', [], null, $locale),
'notification' => $this->translator->trans('flash_messages.notification', [], null, $locale),
'title' => $content->getExtras()['title'],
], 200
);
// If we're "Saving Ajaxy"
if ($this->request->isXmlHttpRequest()) {
return new JsonResponse([
'url' => $url,
'status' => 'success',
'type' => $this->translator->trans('success', [], null, $locale),
'message' => $this->translator->trans('content.updated_successfully', [], null, $locale),
'notification' => $this->translator->trans('flash_messages.notification', [], null, $locale),
'title' => $content->getExtras()['title'],
], 200
);
}

// Otherwise, treat it as a normal POST-request cycle..
$this->addFlash('success', 'content.updated_successfully');

return new RedirectResponse($url);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion templates/content/_buttons.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

<div class="record-actions {% if hide_on_mobile|default(false) %}d-none d-xl-block{% endif %}">
{% if is_granted('edit', record) %}
{{ macro.button('action.save', 'fa-save', 'success mb-0', {'type': 'button', 'form': 'editcontent', 'data-patience': 'virtue', 'name': 'save'}) }}

{% if app.request.get('_route') == 'bolt_content_edit' and config.get('general/ajaxy_saving') %}
{% set type = 'button' %}
{% else %}
{% set type = 'submit' %}
{% endif %}

{{ macro.button('action.save', 'fa-save', 'success mb-0', {'type': type, 'form': 'editcontent', 'data-patience': 'virtue', 'name': 'save'}) }}
{% endif %}

{% if record.id %}
Expand Down