mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-24 19:16:23 +00:00
fix: mostrar la relación deshabilitada #17616
This commit is contained in:
parent
d5ce99deee
commit
c82203a9f6
6 changed files with 22 additions and 12 deletions
|
@ -9,18 +9,22 @@ module Metadata
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
# Genera un Hash de { title | slug => uuid }, excluyendo el Post
|
# Excluye el Post actual y todos los que ya tengan una relación
|
||||||
# actual y todos los que ya tengan una relación inversa, para no
|
# inversa, para no romperla.
|
||||||
# romperla.
|
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Array]
|
||||||
def values
|
def values
|
||||||
@values ||= posts.map do |p|
|
@values ||= posts.map do |p|
|
||||||
next if p.uuid.value == post.uuid.value
|
next if p.uuid.value == post.uuid.value
|
||||||
next unless inverse? && (p[inverse].empty? || [p[inverse].value].flatten.include?(post.uuid.value))
|
|
||||||
|
|
||||||
[title(p), p.uuid.value]
|
disabled = false
|
||||||
end.compact.to_h
|
|
||||||
|
if inverse?
|
||||||
|
disabled = p[inverse].empty? || ![p[inverse].value].flatten.include?(post.uuid.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
[title(p), p.uuid.value, disabled]
|
||||||
|
end.compact
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
:ruby
|
:ruby
|
||||||
help_id = "#{id}_help"
|
help_id = "#{id}_help"
|
||||||
checkbox_attributes = local_assigns.slice(:id, :type, :name, :value, :required, :checked, :data)
|
checkbox_attributes = local_assigns.slice(:id, :type, :name, :value, :required, :checked, :data, :disabled)
|
||||||
checkbox_attributes[:type] ||= 'checkbox'
|
checkbox_attributes[:type] ||= 'checkbox'
|
||||||
|
|
||||||
.custom-control{ class: "custom-#{checkbox_attributes[:type]}" }
|
.custom-control{ class: "custom-#{checkbox_attributes[:type]}" }
|
||||||
|
|
|
@ -56,9 +56,10 @@
|
||||||
|
|
||||||
- content_for :"#{id}_body" do
|
- content_for :"#{id}_body" do
|
||||||
.form-group.mb-0{ id: value_list_id }
|
.form-group.mb-0{ id: value_list_id }
|
||||||
- metadata.values.each_pair do |value, uuid|
|
- metadata.values.each do |(value, uuid, disabled)|
|
||||||
= render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do
|
= render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do
|
||||||
= render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, type: 'radio'
|
= render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, type: 'radio', disabled: disabled do
|
||||||
|
= t('posts.attributes.new_belongs_to.disabled') if disabled
|
||||||
|
|
||||||
-#
|
-#
|
||||||
Según la definición del campo, si hay un filtro, tenemos que poder
|
Según la definición del campo, si hay un filtro, tenemos que poder
|
||||||
|
|
|
@ -57,9 +57,10 @@
|
||||||
|
|
||||||
- content_for :"#{id}_body" do
|
- content_for :"#{id}_body" do
|
||||||
.form-group.mb-0{ id: value_list_id }
|
.form-group.mb-0{ id: value_list_id }
|
||||||
- metadata.values.each_pair do |value, uuid|
|
- metadata.values.each do |(value, uuid, disabled)|
|
||||||
= render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do
|
= render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do
|
||||||
= render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, data: { action: 'required-checkbox#change', 'required-checkbox-target': 'checkbox' }
|
= render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, data: { action: 'required-checkbox#change', 'required-checkbox-target': 'checkbox' }, disabled: disabled do
|
||||||
|
= t('posts.attributes.new_has_many.disabled') if disabled
|
||||||
|
|
||||||
-#
|
-#
|
||||||
Según la definición del campo, si hay un filtro, tenemos que poder
|
Según la definición del campo, si hay un filtro, tenemos que poder
|
||||||
|
|
|
@ -757,6 +757,7 @@ en:
|
||||||
label: Draft
|
label: Draft
|
||||||
new_has_many:
|
new_has_many:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
|
disabled: "It's already associated to an article."
|
||||||
new_has_and_belongs_to_many:
|
new_has_and_belongs_to_many:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
new_predefined_array:
|
new_predefined_array:
|
||||||
|
@ -769,6 +770,7 @@ en:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
new_belongs_to:
|
new_belongs_to:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
|
disabled: "It's already associated to an article."
|
||||||
required_checkbox:
|
required_checkbox:
|
||||||
required: "Please select at least one option."
|
required: "Please select at least one option."
|
||||||
reorder:
|
reorder:
|
||||||
|
|
|
@ -765,6 +765,7 @@ es:
|
||||||
label: Borrador
|
label: Borrador
|
||||||
new_has_many:
|
new_has_many:
|
||||||
edit: "Editar"
|
edit: "Editar"
|
||||||
|
disabled: "Ya está relacionado con otro artículo."
|
||||||
new_has_and_belongs_to_many:
|
new_has_and_belongs_to_many:
|
||||||
edit: "Editar"
|
edit: "Editar"
|
||||||
new_predefined_array:
|
new_predefined_array:
|
||||||
|
@ -779,6 +780,7 @@ es:
|
||||||
edit: "Editar"
|
edit: "Editar"
|
||||||
new_belongs_to:
|
new_belongs_to:
|
||||||
edit: "Editar"
|
edit: "Editar"
|
||||||
|
disabled: "Ya está relacionado con otro artículo."
|
||||||
required_checkbox:
|
required_checkbox:
|
||||||
required: "Seleccioná al menos una opción."
|
required: "Seleccioná al menos una opción."
|
||||||
reorder:
|
reorder:
|
||||||
|
|
Loading…
Reference in a new issue