mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 23:56:22 +00:00
feat: avisar que se guardaron los cambios
This commit is contained in:
parent
798bb992dc
commit
34aa8822f2
5 changed files with 22 additions and 4 deletions
|
@ -128,7 +128,9 @@ class PostsController < ApplicationController
|
||||||
# condiciones.
|
# condiciones.
|
||||||
if htmx?
|
if htmx?
|
||||||
if post.persisted?
|
if post.persisted?
|
||||||
swap_modals
|
triggers = { 'notification:show' => { 'id' => params.permit(:saved).values.first } }
|
||||||
|
|
||||||
|
swap_modals(triggers)
|
||||||
|
|
||||||
@value = post.title.value
|
@value = post.title.value
|
||||||
@uuid = post.uuid.value
|
@uuid = post.uuid.value
|
||||||
|
@ -169,7 +171,9 @@ class PostsController < ApplicationController
|
||||||
|
|
||||||
if htmx?
|
if htmx?
|
||||||
if post.persisted?
|
if post.persisted?
|
||||||
swap_modals
|
triggers = { 'notification:show' => params.permit(:saved).values.first }
|
||||||
|
|
||||||
|
swap_modals(triggers)
|
||||||
|
|
||||||
@value = post.title.value
|
@value = post.title.value
|
||||||
@uuid = post.uuid.value
|
@uuid = post.uuid.value
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
'hx-validate': true,
|
'hx-validate': true,
|
||||||
data: {
|
data: {
|
||||||
controller: 'form-validation',
|
controller: 'form-validation',
|
||||||
action: 'form-validation#submit'
|
action: 'form-validation#submit',
|
||||||
|
'form-validation-submitting-id-value': params.permit(:submitting).values.first,
|
||||||
|
'form-validation-invalid-id-value': params.permit(:invalid).values.first,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@
|
||||||
%input{ type: 'hidden', name: 'swap', value: params.require(:swap) }
|
%input{ type: 'hidden', name: 'swap', value: params.require(:swap) }
|
||||||
- if params[:inverse].present?
|
- if params[:inverse].present?
|
||||||
%input{ type: 'hidden', name: 'inverse', value: params.require(:inverse) }
|
%input{ type: 'hidden', name: 'inverse', value: params.require(:inverse) }
|
||||||
|
- if params[:saved].present?
|
||||||
|
%input{ type: 'hidden', name: 'saved', value: params.require(:saved) }
|
||||||
|
|
||||||
= hidden_field_tag "#{base}[layout]", post.layout.name
|
= hidden_field_tag "#{base}[layout]", post.layout.name
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
post_form_loaded_id = random_id
|
post_form_loaded_id = random_id
|
||||||
value_list_id = random_id
|
value_list_id = random_id
|
||||||
layout = metadata.filter[:layout]
|
layout = metadata.filter[:layout]
|
||||||
|
invalid_id = random_id
|
||||||
|
submitting_id = random_id
|
||||||
|
saved_id = random_id
|
||||||
|
|
||||||
%div{ data: { controller: 'modal' }}
|
%div{ data: { controller: 'modal' }}
|
||||||
.form-group
|
.form-group
|
||||||
|
@ -43,10 +46,13 @@
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' } do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' } do
|
||||||
- content_for :"#{id}_body" do
|
- content_for :"#{id}_body" do
|
||||||
-# @todo ocultar el modal después de guardar
|
-# @todo ocultar el modal después de guardar
|
||||||
.placeholder-glow{ 'hx-get': site_posts_form_path(site, layout: layout, base: id, name: name, form: form_id, swap: 'innerHTML', target: target_id, attribute: 'new_has_one', hide: modal_id, uuid: metadata.value), 'hx-trigger': 'load' }
|
.placeholder-glow{ 'hx-get': site_posts_form_path(site, layout: layout, base: id, name: name, form: form_id, swap: 'innerHTML', target: target_id, attribute: 'new_has_one', hide: modal_id, uuid: metadata.value, invalid: invalid_id, submitting: submitting_id, saved: saved_id), 'hx-trigger': 'load' }
|
||||||
%span.placeholder.w-100.h-100
|
%span.placeholder.w-100.h-100
|
||||||
|
|
||||||
- content_for :"#{id}_footer" do
|
- content_for :"#{id}_footer" do
|
||||||
|
= render 'posts/validation', site: site, invalid: { id: invalid_id }, submitting: { id: submitting_id }
|
||||||
|
= render 'bootstrap/alert', class: 'm-0 d-none fade', id: saved_id, data: { controller: 'notification', action: 'notification:show@window->notification#show', 'notification-hide-class': 'hide', 'notification-show-class': 'show' } do
|
||||||
|
= t('.saved')
|
||||||
= render 'bootstrap/btn', form: form_id, content: t('.save'), type: 'submit', class: 'm-0 mt-1 mr-1'
|
= render 'bootstrap/btn', form: form_id, content: t('.save'), type: 'submit', class: 'm-0 mt-1 mr-1'
|
||||||
= render 'bootstrap/btn', content: t('.close'), action: 'modal#hide', class: 'm-0 mt-1 mr-1'
|
= render 'bootstrap/btn', content: t('.close'), action: 'modal#hide', class: 'm-0 mt-1 mr-1'
|
||||||
|
|
||||||
|
|
|
@ -965,3 +965,5 @@ en:
|
||||||
save: "Save"
|
save: "Save"
|
||||||
card:
|
card:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
|
alert:
|
||||||
|
saved: "Changes were saved!"
|
||||||
|
|
|
@ -975,3 +975,5 @@ es:
|
||||||
save: "Guardar"
|
save: "Guardar"
|
||||||
card:
|
card:
|
||||||
edit: "Editar"
|
edit: "Editar"
|
||||||
|
alert:
|
||||||
|
saved: "¡Cambios guardados!"
|
||||||
|
|
Loading…
Reference in a new issue