From cbba822f31b12d5607210aa2dec749915d8184c7 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 29 Feb 2024 16:27:48 -0300 Subject: [PATCH] feat: recordar el estado del details --- .../controllers/details_controller.js | 17 +++++++++++++++++ app/views/layouts/_details.haml | 9 +++++++-- app/views/moderation_queue/index.haml | 9 +++------ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 app/javascript/controllers/details_controller.js diff --git a/app/javascript/controllers/details_controller.js b/app/javascript/controllers/details_controller.js new file mode 100644 index 00000000..57935e1e --- /dev/null +++ b/app/javascript/controllers/details_controller.js @@ -0,0 +1,17 @@ +import { Controller } from "stimulus"; + +export default class extends Controller { + static targets = []; + + connect() { + const state = window.sessionStorage.getItem(this.element.id); + + if (state === "open") { + this.element.setAttribute("open", true); + } + } + + store(event = undefined) { + window.sessionStorage.setItem(this.element.id, event.newState); + } +} diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index 99ba4894..ce38bddd 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -1,6 +1,11 @@ --# Detail Cola de Moderación +-# + Detail Cola de Moderación -%details.details.py-2 + @param :id [String] El ID opcional sirve para mantener el historial de + cuál estaba abierto y recuperarlo al cargar la página + @param :summary [String] El resumen + +%details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' } } %summary .row .col-11.pr-2 diff --git a/app/views/moderation_queue/index.haml b/app/views/moderation_queue/index.haml index df2c219d..799fc641 100644 --- a/app/views/moderation_queue/index.haml +++ b/app/views/moderation_queue/index.haml @@ -3,14 +3,11 @@ %h1= t('.title') .row .col - - summary = t('.instances') - = render 'layouts/details', summary: summary do + = render 'layouts/details', id: 'summary', summary: t('.instances') do = render 'moderation_queue/instances', site: @site, instance_moderations: @instance_moderations, fediblock_states: @site.fediblock_states %hr - - summary = t('.accounts') - = render 'layouts/details', summary: summary do + = render 'layouts/details', id: 'accounts', summary: t('.accounts') do = render 'moderation_queue/accounts', site: @site, post: @post, actor_moderations: @actor_moderations %hr - - summary = t('.comments') - = render 'layouts/details', summary: summary do + = render 'layouts/details', id: 'comments', summary: t('.comments') do = render 'moderation_queue/comments', site: @site, post: @post, moderation_queue: @moderation_queue