mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 05:26:22 +00:00
fix: no se pueden anidar formularios
usando el atributo form, podemos crear un formulario vacío y colocar inputs por fuera de su contexto. de lo contrario el primer botón de acción individual no funciona
This commit is contained in:
parent
0b3f4e33fb
commit
27d7589f9a
9 changed files with 28 additions and 27 deletions
|
@ -3,6 +3,10 @@
|
||||||
# Mantiene el registro de relaciones entre sitios e instancias
|
# Mantiene el registro de relaciones entre sitios e instancias
|
||||||
class InstanceModeration < ApplicationRecord
|
class InstanceModeration < ApplicationRecord
|
||||||
include AASM
|
include AASM
|
||||||
|
include AasmEventsConcern
|
||||||
|
|
||||||
|
IGNORED_EVENTS = []
|
||||||
|
IGNORED_STATES = []
|
||||||
|
|
||||||
belongs_to :site
|
belongs_to :site
|
||||||
belongs_to :instance, class_name: 'ActivityPub::Instance'
|
belongs_to :instance, class_name: 'ActivityPub::Instance'
|
||||||
|
@ -11,9 +15,6 @@ class InstanceModeration < ApplicationRecord
|
||||||
# todas las que no estén bloqueadas ya.
|
# todas las que no estén bloqueadas ya.
|
||||||
scope :may_block, -> { where.not(aasm_state: 'blocked') }
|
scope :may_block, -> { where.not(aasm_state: 'blocked') }
|
||||||
scope :may_pause, -> { where.not(aasm_state: 'paused') }
|
scope :may_pause, -> { where.not(aasm_state: 'paused') }
|
||||||
scope :paused, -> { where(aasm_state: 'paused') }
|
|
||||||
scope :blocked, -> { where(aasm_state: 'blocked') }
|
|
||||||
scope :allowed, -> { where(aasm_state: 'allowed') }
|
|
||||||
|
|
||||||
# Bloquear instancias en masa
|
# Bloquear instancias en masa
|
||||||
def self.block_all!
|
def self.block_all!
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-# Componente Checkbox
|
-# Componente Checkbox
|
||||||
- local_assigns[:name] ||= id
|
- local_assigns[:name] ||= id
|
||||||
.custom-control.custom-checkbox
|
.custom-control.custom-checkbox
|
||||||
%input.custom-control-input{ type: 'checkbox', id: id, **local_assigns }
|
%input.custom-control-input{ form: local_assigns[:form_id], type: 'checkbox', id: id, **local_assigns }
|
||||||
%label.custom-control-label{ for: id }= yield
|
%label.custom-control-label{ for: id }= yield
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-#
|
-#
|
||||||
@param name [String]
|
@param name [String]
|
||||||
@param value [String]
|
@param value [String]
|
||||||
%button.dropdown-item{type: 'submit', data: { target: 'dropdown.item' }, name: name, value: value }= text
|
%button.dropdown-item{type: 'submit', data: { target: 'dropdown.item' }, name: name, value: value, form: local_assigns[:form_id] }= text
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
= render 'components/dropdown_button', text: t('.submenu_pause'), name: 'instance_moderation_action', value: 'pause'
|
- InstanceModeration.events.each do |event|
|
||||||
= render 'components/dropdown_button', text: t('.submenu_allow'), name: 'instance_moderation_action', value: 'allow'
|
= render 'components/dropdown_button', text: t(".submenu_#{event}"), name: 'instance_moderation_action', value: event, form_id: form_id
|
||||||
= render 'components/dropdown_button', text: t('.submenu_block'), name: 'instance_moderation_action', value: 'block'
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.d-flex.py-2
|
.d-flex.py-2
|
||||||
= render 'components/dropdown', text: t('.text_checked') do
|
= render 'components/dropdown', text: t('.text_checked') do
|
||||||
= render 'components/instances_checked_submenu'
|
= render 'components/instances_checked_submenu', form_id: form_id
|
||||||
|
|
||||||
= render 'components/dropdown', text: t('.text_show') do
|
= render 'components/dropdown', text: t('.text_show') do
|
||||||
= render 'components/instances_show_submenu', site: site
|
= render 'components/instances_show_submenu', site: site
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-#
|
-#
|
||||||
@param id [String]
|
@param id [String]
|
||||||
= render 'components/checkbox', id: id, data: { action: 'select-all#toggle', target: 'select-all.toggle' } do
|
= render 'components/checkbox', id: id, form: local_assigns[:form_id], data: { action: 'select-all#toggle', target: 'select-all.toggle' } do
|
||||||
%span.sr-only= t('.label')
|
%span.sr-only= t('.label')
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
.row.no-gutters
|
.row.no-gutters
|
||||||
.col-1
|
.col-1
|
||||||
= render 'components/checkbox', id: activity_pub.id, name: 'activity_pub[]', value: activity_pub.id, data: { target: 'select-all.input' }
|
= render 'components/checkbox', id: activity_pub.id, name: 'activity_pub[]', value: activity_pub.id, data: { target: 'select-all.input' }, form: form_id
|
||||||
.col-11
|
.col-11
|
||||||
.d-flex.flex-row.align-items-center.justify-content-between
|
.d-flex.flex-row.align-items-center.justify-content-between
|
||||||
%h4.mb-0
|
%h4.mb-0
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
.row.no-gutters.pt-2
|
.row.no-gutters.pt-2
|
||||||
.col-1
|
.col-1
|
||||||
= render 'components/checkbox', id: instance.hostname, name: 'instance_moderation[]', value: instance_moderation.id, data: { target: 'select-all.input' }
|
= render 'components/checkbox', id: instance.hostname, form_id: form_id, name: 'instance_moderation[]', value: instance_moderation.id, data: { target: 'select-all.input' }
|
||||||
.col-11
|
.col-11
|
||||||
%h4
|
%h4
|
||||||
%a{ href: instance.uri }= sanitize(instance.content['title']) || instance.hostname
|
%a{ href: instance.uri }= sanitize(instance.content['title']) || instance.hostname
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
- form_id = 'instance_moderation_action_on_several'
|
||||||
%section
|
%section
|
||||||
%form{ action: site_instance_moderations_action_on_several_path, method: :post }
|
%form{ id: form_id, action: site_instance_moderations_action_on_several_path, method: :post }
|
||||||
.row.no-gutters.pt-2{ data: { controller: 'select-all' } }
|
.row.no-gutters.pt-2{ data: { controller: 'select-all' } }
|
||||||
.col-1.d-flex.align-items-center
|
.col-1.d-flex.align-items-center
|
||||||
= render 'components/select_all', id: 'instances'
|
= render 'components/select_all', id: 'instances', form_id: form_id
|
||||||
.col-11
|
.col-11
|
||||||
-# Filtros
|
-# Filtros
|
||||||
= render 'components/instances_filters', site: site
|
= render 'components/instances_filters', site: site, form_id: form_id
|
||||||
|
|
||||||
.col-12
|
.col-12
|
||||||
- if instance_moderations.count.zero?
|
- if instance_moderations.count.zero?
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
- instance_moderations.each do |instance_moderation|
|
- instance_moderations.each do |instance_moderation|
|
||||||
- cache [instance_moderation.aasm_state, instance_moderation.instance] do
|
- cache [instance_moderation.aasm_state, instance_moderation.instance] do
|
||||||
%hr
|
%hr
|
||||||
= render 'moderation_queue/instance', instance_moderation: instance_moderation, instance: instance_moderation.instance
|
= render 'moderation_queue/instance', instance_moderation: instance_moderation, instance: instance_moderation.instance, form_id: form_id
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
%div
|
%div
|
||||||
|
|
Loading…
Reference in a new issue