5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 22:26:22 +00:00

Merge branch 'issue-15068' into production.panel.sutty.nl

This commit is contained in:
f 2024-10-21 16:46:05 -03:00
commit a238e92272
No known key found for this signature in database
13 changed files with 36 additions and 12 deletions

View file

@ -6,7 +6,11 @@ export default class extends Controller {
connect() {
// TODO: Stimulus >1
this.newArrayValueURL = new URL(window.location.origin);
this.newArrayValueURL.pathname = this.element.dataset.arrayNewArrayValue;
const [ pathname, search ] = this.element.dataset.arrayNewArrayValue.split("?");
this.newArrayValueURL.pathname = pathname;
this.newArrayValueURL.search = `?${search}`;
this.originalValue = JSON.parse(this.element.dataset.arrayOriginalValue);
}

View file

@ -1,4 +1,8 @@
# frozen_string_literal: true
# Nueva interfaz
class MetadataNewPredefinedValue < MetadataPredefinedValue; end
class MetadataNewPredefinedValue < MetadataPredefinedValue
def values
@values ||= (required ? {} : { I18n.t('posts.attributes.new_predefined_value.empty') => '' }).merge(super)
end
end

View file

@ -26,6 +26,7 @@
- form_params[:modal_id] = form_params[:show] = modal_id = random_id
-# Asociar un modal con una tarjeta
- form_params[:result_id] = card_id
- form_params[:inverse] = local_assigns[:inverse]
-# @todo Poder indicar en qué elemento queremos asociar lo descargado
= render 'bootstrap/btn', content: t('.edit'), data: { controller: 'htmx', action: 'modal#showAnother htmx#getUrlOnce', 'modal-show-value': modal_id, 'htmx-get-url-param': site_posts_modal_path(post.site, **form_params) }, id: random_id

View file

@ -19,7 +19,7 @@
como obligatorio al validar el formulario.
.d-flex.align-items-center.justify-content-between
%div
= label_tag id, post_label_t(attribute, post: post), class: 'mb-0'
= label_tag id, post_label_t(attribute, post: post), class: 'mb-0 h3'
= render 'posts/required_checkbox', required: metadata.required, name: name, initial: metadata.empty?
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#show'
-# Mostramos la lista de valores actuales.

View file

@ -46,7 +46,7 @@
.row.no-gutters.placeholder-glow{ data: { 'array-target': 'current' } }
-# @todo issue-7537
- if !metadata.empty? && (indexed_post = site.indexed_posts.find_by(post_id: metadata.value))
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse
= 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

View file

@ -20,7 +20,7 @@
controllers = %w[modal array]
controllers << 'required-checkbox' if metadata.required
%div{ id: modal_id, data: { controller: controllers.join(' '), 'array-original-value': metadata.value.to_json, 'array-new-array-value': site_posts_new_related_post_path(site) } }
%div{ id: modal_id, data: { controller: controllers.join(' '), 'array-original-value': metadata.value.to_json, 'array-new-array-value': site_posts_new_related_post_path(site, inverse: metadata.inverse) } }
%template{ data: { 'array-target': 'placeholder' } }
.col.p-3{ 'aria-hidden': 'true' }
%span.placeholder.w-100
@ -29,7 +29,7 @@
= hidden_field_tag name, ''
.d-flex.align-items-center.justify-content-between
%div
= label_tag id, post_label_t(attribute, post: post)
= label_tag id, post_label_t(attribute, post: post), class: 'h3'
= render 'posts/required_checkbox', required: metadata.required, name: name, initial: metadata.empty?
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#show'
@ -48,7 +48,7 @@
-# @todo issue-7537
- metadata.value.each do |uuid|
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse
= 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
@ -91,6 +91,7 @@
para que sea externo al formulario actual.
- content_for :post_form do
%form{ id: post_form_id, 'hx-get': site_posts_form_path(site), 'hx-target': "##{post_form_loaded_id}" }
%input{ type: 'hidden', name: 'modal_id', value: modal_id }
%input{ type: 'hidden', name: 'show', value: post_modal_id }
%input{ type: 'hidden', name: 'hide', value: modal_id }
%input{ type: 'hidden', name: 'target', value: value_list_id }

View file

@ -47,7 +47,7 @@
-# @todo issue-7537
- metadata.value.each do |uuid|
- if (indexed_post = site.indexed_posts.find_by(post_id: uuid))
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type
= render 'posts/new_related_post', post: indexed_post, attribute: metadata.type, inverse: metadata.inverse
= 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

View file

@ -18,7 +18,7 @@
= hidden_field_tag name, ''
.d-flex.align-items-center.justify-content-between
%div
= label_tag id, post_label_t(attribute, post: post)
= label_tag id, post_label_t(attribute, post: post), class: 'h3'
= render 'posts/required_checkbox', required: metadata.required, name: name, initial: metadata.empty?
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#show'

View file

@ -29,7 +29,7 @@
= hidden_field_tag name, ''
.d-flex.align-items-center.justify-content-between
%div
= label_tag id, post_label_t(attribute, post: post)
= label_tag id, post_label_t(attribute, post: post), class: 'h3'
= render 'posts/required_checkbox', required: metadata.required, name: name, initial: metadata.empty?, type: 'radio'
= render 'bootstrap/btn', content: t('.edit'), action: 'modal#show'

View file

@ -16,6 +16,11 @@
result_id = pluck_param(:result_id)
form_id = random_id
except = %i[date]
if (inverse = pluck_param(:inverse, optional: true))
except << inverse.to_sym
end
options = {
id: form_id,
multipart: true,
@ -45,12 +50,17 @@
= hidden_field_tag 'result_id', result_id
= hidden_field_tag 'modal_id', modal_id
= hidden_field_tag "#{base}[layout]", post.layout.name
= hidden_field_tag 'hide', pluck_param((post.errors.empty? ? :show : :hide), optional: true) || pluck_param(:modal_id, optional: true)
= hidden_field_tag 'show', pluck_param((post.errors.empty? ? :hide : :show), optional: true)
- if inverse
= hidden_field_tag 'inverse', inverse
= render 'errors', post: post
= render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale, except: except
-# @todo Volver obligatorios?
- except.each do |attr|
%input{ type: 'hidden', name: "#{base}[#{attr}]", value: pluck_param(attr, optional: true) }
- if (value = pluck_param(attr, optional: true))
= hidden_field_tag "#{base}[#{attr}]", value
- content_for :"#{modal_id}_footer" do
-# = render 'posts/validation', site: site, invalid: { id: invalid_id }, submitting: { id: submitting_id }

View file

@ -1 +1 @@
= render 'posts/new_related_post', post: @indexed_post, modal_id: pluck_param(:modal_id, optional: true)
= render 'posts/new_related_post', post: @indexed_post, modal_id: pluck_param(:modal_id, optional: true), inverse: pluck_param(:inverse, optional: true)

View file

@ -769,6 +769,8 @@ en:
edit: "Edit"
new_predefined_array:
edit: "Edit"
new_predefined_value:
empty: "(Empty)"
new_array:
edit: "Edit"
new_has_one:

View file

@ -776,8 +776,10 @@ es:
new_has_and_belongs_to_many:
edit: "Editar"
new_predefined_array:
empty: "(Vacío)"
edit: "Editar"
new_predefined_value:
empty: "(Vacío)"
edit: "Editar"
new_array:
edit: "Editar"