mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 04:26:22 +00:00
feat: no mostrar opciones que no se pueden ejecutar con el filtro actual
This commit is contained in:
parent
c49182e278
commit
67a56c540a
8 changed files with 34 additions and 11 deletions
|
@ -11,6 +11,16 @@ module AasmEventsConcern
|
|||
aasm.events.map(&:name) - self::IGNORED_EVENTS
|
||||
end
|
||||
|
||||
# Encuentra todos los eventos que se pueden ejecutar con el filtro
|
||||
# actual.
|
||||
#
|
||||
# @return [Array<Symbol>]
|
||||
def self.transitionable_events(current_state)
|
||||
self.events.select do |event|
|
||||
aasm.events.find { |x| x.name == event }.transitions_from_state? current_state
|
||||
end
|
||||
end
|
||||
|
||||
# Todos los estados de la máquina de estados
|
||||
#
|
||||
# @return [Array<Symbol>]
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
- ActivityPub.events.each do |event|
|
||||
= render 'components/dropdown_button', form_id: form_id, text: t(".submenu_#{event}"), name: 'activity_pub_action', value: event
|
||||
- current_state = params[:activity_pub_state]&.to_sym || ActivityPub.states.first
|
||||
|
||||
- ActivityPub.aasm.events.each do |event|
|
||||
- next if ActivityPub::IGNORED_EVENTS.include? event.name
|
||||
- next unless event.transitions_from_state?(current_state)
|
||||
= render 'components/dropdown_button', form_id: form_id, text: t(".submenu_#{event.name}"), name: 'activity_pub_action', value: event.name
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
- current_state = params[:activity_pub_state]&.to_sym || ActivityPub.states.first
|
||||
|
||||
.d-flex.py-2
|
||||
- if ActivityPub.transitionable_events(current_state).present?
|
||||
= render 'components/dropdown', text: t('.text_checked') do
|
||||
= render 'components/comments_checked_submenu', form_id: form_id
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
- InstanceModeration.events.each do |event|
|
||||
- InstanceModeration.transitionable_events(current_state).each do |event|
|
||||
= render 'components/dropdown_button', text: t(".submenu_#{event}"), name: 'instance_moderation_action', value: event, form_id: form_id
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
- current_state = params[:state]&.to_sym || InstanceModeration.states.first
|
||||
|
||||
.d-flex.py-2
|
||||
- if InstanceModeration.transitionable_events(current_state).present?
|
||||
= render 'components/dropdown', text: t('.text_checked') do
|
||||
= render 'components/instances_checked_submenu', form_id: form_id
|
||||
= render 'components/instances_checked_submenu', form_id: form_id, current_state: current_state
|
||||
|
||||
= render 'components/dropdown', text: t('.text_show') do
|
||||
= render 'components/instances_show_submenu', site: site
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
- ActorModeration.events.each do |actor_event|
|
||||
- ActorModeration.transitionable_events(current_state).each do |actor_event|
|
||||
= render 'components/dropdown_button', text: t(".submenu_#{actor_event}"), name: 'actor_moderation_action', value: actor_event, form_id: form_id
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
- current_state = params[:actor_state]&.to_sym || ActorModeration.states.first
|
||||
|
||||
.d-flex.py-2
|
||||
- if ActorModeration.transitionable_events(current_state).present?
|
||||
= render 'components/dropdown', text: t('.text_checked') do
|
||||
= render 'components/profiles_checked_submenu', form_id: form_id
|
||||
= render 'components/profiles_checked_submenu', form_id: form_id, current_state: current_state
|
||||
|
||||
= render 'components/dropdown', text: t('.text_show') do
|
||||
= render 'components/profiles_show_submenu', actor_moderations: actor_moderations
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.row.no-gutters.pt-2{ data: { controller: 'select-all' } }
|
||||
.col-1.d-flex.align-items-center
|
||||
= render 'components/select_all', id: 'select-all-comments', form_id: form_id
|
||||
.col-md-9
|
||||
.col-11
|
||||
-# Filtros
|
||||
= render 'components/comments_filters', activity_pubs: moderation_queue, form_id: form_id
|
||||
.col-12
|
||||
|
|
Loading…
Reference in a new issue