mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-14 23:08:17 +00:00
Merge branch 'issue-15068' into production.panel.sutty.nl
This commit is contained in:
commit
51eb573aa2
11 changed files with 34 additions and 12 deletions
|
@ -76,10 +76,16 @@ export default class extends Controller {
|
||||||
return this.inputFrom(itemTarget)?.checked || false;
|
return this.inputFrom(itemTarget)?.checked || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelWithEscape(event) {
|
||||||
|
if (event?.key !== "Escape") return;
|
||||||
|
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Al cancelar, se vuelve al estado original de la lista
|
* Al cancelar, se vuelve al estado original de la lista
|
||||||
*/
|
*/
|
||||||
cancel(event) {
|
cancel(event = undefined) {
|
||||||
for (const itemTarget of this.itemTargets) {
|
for (const itemTarget of this.itemTargets) {
|
||||||
const input = this.inputFrom(itemTarget);
|
const input = this.inputFrom(itemTarget);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
if (!event.target?.dataset?.modalShowValue) return;
|
if (!event.target?.dataset?.modalShowValue) return;
|
||||||
|
|
||||||
window.dispatchEvent(new CustomEvent("modal:show", { detail: { id: event.target.dataset.modalShowValue } }));
|
window.dispatchEvent(new CustomEvent("modal:show", { detail: { id: event.target.dataset.modalShowValue, previousFocus: event.target.id } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -50,12 +50,26 @@ export default class extends Controller {
|
||||||
|
|
||||||
window.document.body.classList.add("modal-open");
|
window.document.body.classList.add("modal-open");
|
||||||
|
|
||||||
|
if (event?.detail?.previousFocus) {
|
||||||
|
this.previousFocus = window.document.getElementById(event.detail.previousFocus);
|
||||||
|
} else {
|
||||||
|
this.previousFocus = event?.target;
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.modalTarget.classList.add("show");
|
this.modalTarget.classList.add("show");
|
||||||
this.backdropTarget.classList.add("show");
|
this.backdropTarget.classList.add("show");
|
||||||
|
|
||||||
|
this.modalTarget.focus();
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideWithEscape(event) {
|
||||||
|
if (event?.key !== "Escape") return;
|
||||||
|
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
|
||||||
hide(event = undefined) {
|
hide(event = undefined) {
|
||||||
event?.preventDefault();
|
event?.preventDefault();
|
||||||
const modalId = event?.detail?.id;
|
const modalId = event?.detail?.id;
|
||||||
|
@ -69,6 +83,8 @@ export default class extends Controller {
|
||||||
this.modalTarget.removeAttribute("role");
|
this.modalTarget.removeAttribute("role");
|
||||||
this.modalTarget.removeAttribute("aria-modal");
|
this.modalTarget.removeAttribute("aria-modal");
|
||||||
|
|
||||||
|
this.previousFocus?.focus();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.modalTarget.style.display = "";
|
this.modalTarget.style.display = "";
|
||||||
this.backdropTarget.style.display = "";
|
this.backdropTarget.style.display = "";
|
||||||
|
|
|
@ -12,8 +12,6 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
||||||
def create_or_update
|
def create_or_update
|
||||||
uuid = params.require(base).permit(:uuid).values.first
|
uuid = params.require(base).permit(:uuid).values.first
|
||||||
|
|
||||||
binding.pry
|
|
||||||
|
|
||||||
if uuid.blank?
|
if uuid.blank?
|
||||||
create
|
create
|
||||||
elsif (indexed_post = site.indexed_posts.find_by(post_id: uuid)).present?
|
elsif (indexed_post = site.indexed_posts.find_by(post_id: uuid)).present?
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
:ruby
|
:ruby
|
||||||
local_assigns[:hide_actions] ||= []
|
local_assigns[:hide_actions] ||= []
|
||||||
local_assigns[:hide_actions] << 'click->modal#hide'
|
local_assigns[:hide_actions] << 'click->modal#hide'
|
||||||
|
local_assigns[:keydown_actions] ||= []
|
||||||
|
local_assigns[:keydown_actions] << 'keydown->modal#hideWithEscape'
|
||||||
local_assigns[:modal_content_attributes] ||= {}
|
local_assigns[:modal_content_attributes] ||= {}
|
||||||
|
|
||||||
-# XXX: Necesario para poder generar todas las demás
|
-# XXX: Necesario para poder generar todas las demás
|
||||||
= yield
|
= yield
|
||||||
|
|
||||||
.modal.fade{ tabindex: -1, aria: { hidden: 'true' }, data: { target: 'modal.modal' } }
|
.modal.fade{ tabindex: -1, aria: { hidden: 'true' }, data: { target: 'modal.modal', action: local_assigns[:keydown_actions].join(' ') } }
|
||||||
.modal-backdrop.fade{ data: { target: 'modal.backdrop', action: local_assigns[:hide_actions].join(' ') } }
|
.modal-backdrop.fade{ data: { target: 'modal.backdrop', action: local_assigns[:hide_actions].join(' ') } }
|
||||||
.modal-dialog.modal-dialog-scrollable.modal-dialog-centered.modal-lg
|
.modal-dialog.modal-dialog-scrollable.modal-dialog-centered.modal-lg
|
||||||
.modal-content{ **local_assigns[:modal_content_attributes] }
|
.modal-content{ **local_assigns[:modal_content_attributes] }
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
- metadata.value.sort_by(&:remove_diacritics).each do |value|
|
- metadata.value.sort_by(&:remove_diacritics).each do |value|
|
||||||
= render 'posts/new_array_value', value: value
|
= render 'posts/new_array_value', value: value
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
- if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value))
|
- if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value))
|
||||||
= render 'posts/new_related_post', post: indexed_post
|
= render 'posts/new_related_post', post: indexed_post
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
|
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
|
||||||
= render 'posts/new_related_post', post: indexed_post
|
= render 'posts/new_related_post', post: indexed_post
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
|
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
|
||||||
= render 'posts/new_related_post', post: indexed_post
|
= render 'posts/new_related_post', post: indexed_post
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
= hidden_field_tag name, ''
|
= hidden_field_tag name, ''
|
||||||
.d-flex.align-items-center.justify-content-between
|
.d-flex.align-items-center.justify-content-between
|
||||||
= label_tag id, post_label_t(attribute, post: post), class: 'h3'
|
= label_tag id, post_label_t(attribute, post: post), class: 'h3'
|
||||||
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#showAnother', data: { 'modal-show-value': modal_id }
|
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#showAnother', data: { 'modal-show-value': modal_id }, id: random_id
|
||||||
|
|
||||||
-# Aquí se reemplaza por la tarjeta y el UUID luego de guardar
|
-# Aquí se reemplaza por la tarjeta y el UUID luego de guardar
|
||||||
.row.row-cols-1.no-gutters.placeholder-glow{ id: target_id }
|
.row.row-cols-1.no-gutters.placeholder-glow{ id: target_id }
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
- metadata.values.slice(*metadata.value).each_key do |value|
|
- metadata.values.slice(*metadata.value).each_key do |value|
|
||||||
= render 'posts/new_array_value', value: value
|
= render 'posts/new_array_value', value: value
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
- unless metadata.empty?
|
- unless metadata.empty?
|
||||||
= render 'posts/new_array_value', value: metadata.to_s
|
= render 'posts/new_array_value', value: metadata.to_s
|
||||||
|
|
||||||
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'] do
|
= render 'bootstrap/modal', id: id, modal_content_attributes: { class: 'h-100' }, hide_actions: ['array#cancel'], keydown_actions: %w[keydown->array#cancelWithEscape] do
|
||||||
- content_for :"#{id}_header" do
|
- content_for :"#{id}_header" do
|
||||||
.form-group.flex-grow-1.mb-0
|
.form-group.flex-grow-1.mb-0
|
||||||
= label_tag id, post_label_t(attribute, post: post)
|
= label_tag id, post_label_t(attribute, post: post)
|
||||||
|
|
Loading…
Reference in a new issue