outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
274 stars 96 forks source link

[request] Reload page on save #10

Closed pzmarzly closed 4 years ago

pzmarzly commented 4 years ago

I use Nova Settings for color fields, to let admins control their site appearance (including Nova, via CSS variables and timothyasp/color). But since Nova is a SPA, I'd need to somehow execute location.reload() after the form is saved, ideally somewhere around here:

https://github.com/optimistdigital/nova-settings/blob/cba4c547c4df1fe0d323a3547ae39abe45d92306/resources/js/views/Settings.vue#L81-L94

I can't think of any useful hooks on JS side other than the reload one, but maybe someone will want PHP hooks one day (for dropping caches after settings are saved, etc.).

royduin commented 4 years ago

Why is a reload needed?

pzmarzly commented 4 years ago

For my use case, I'm changing nova theme by putting

<style>
:root {
    --primary: {{ nova_get_setting('primary_color') ?? '#aabbcc' }};
    --secondary: {{ nova_get_setting('secondary_color') ?? '#ddeeff' }};
}
</style>

to my resources/views/layouts/partials/theme.blade.php file.

But I suspect there are other aspects of Nova that can be customized but require a full page reload (maybe enabling/disabling an item in the sidebar?).

Tarpsvo commented 4 years ago

Hey! Added a config file with reload_page_on_save option in version 2.4.0. Good luck!