Skip to content

feat: show the PDF in the document view where the site draws it - #285

Merged
erseco merged 2 commits into
integra/limpieza-tras-revision-283from
integra/vista-documento-pdf
Sep 8, 2026
Merged

feat: show the PDF in the document view where the site draws it#285
erseco merged 2 commits into
integra/limpieza-tras-revision-283from
integra/vista-documento-pdf

Conversation

@erseco

@erseco erseco commented Sep 6, 2026

Copy link
Copy Markdown
Member

Stacked on #284, which is stacked on #283.

The left column of the document view opened with the field-by-field summary.
It now opens with the document as it will be issued, which is what people
actually look at. The layout itself does not change: the view was already a
two-column grid with the actions on the right.

Where it applies

Only where the PDF is drawn in this process. Collabora and LibreOffice WASM
reach a service or the browser to produce one, which is not something to hang
a page render on — there the view stays as it was. A document with no type has
nothing to draw either.

The frame points at admin_post_documentate_preview, the handler the export
buttons already used, so the file is streamed by the same code behind the same
edit_post check and the same nonce. No new way in is opened.

The field summary is kept, folded

It is the only view that respects the área/gestión split and the only one that
shows which fields are still empty, so it sits under the document in a closed
<details>.

"Previsualizar PDF" leaves the document view

It opened, in another tab, what is now already on screen. The editor keeps it,
which is where it still earns its place.

Worth knowing before merging

An área user now sees the whole rendered document — gestión's figures included
— as soon as they open the view. That is not a new permission: the same
user already had "Previsualizar PDF" and "Descargar PDF" in the same view, both
served by this same handler, so the document was always one click away. What
changes is that it is on screen by default rather than behind a button.

If that default is wrong for this workflow, the fix is one condition in
Documentate_App_Detail::render_pdf_preview() — say the word and I will gate
the frame on whoever may see every field.

Checks

make lint, make phpmd, make check-plugin, make test (2794 tests) and
make test-e2e (106 tests) all pass on this branch.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

WordPress Playground Preview

The changes in this pull request can previewed and tested using a WordPress Playground instance.

Open WordPress Playground Preview

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Apilado sobre la limpieza. La columna izquierda de la ficha encabezaba con el
resumen campo a campo; ahora encabeza con el documento tal y como se va a
emitir, que es lo que la gente va a mirar. La maquetación no cambia: la ficha
ya era una rejilla de dos columnas con las acciones a la derecha.

Solo donde el PDF se dibuja en este proceso. Con Collabora o con WASM hace
falta un servicio o el navegador para producirlo, y de eso no se cuelga el
render de una página; ahí la ficha se queda como estaba. Un documento sin tipo
tampoco tiene nada que dibujar.

El marco apunta al mismo `admin_post_documentate_preview` que ya usaban los
botones de exportar, así que el fichero lo sirve el mismo código, tras la
misma comprobación de `edit_post` y el mismo nonce. No se abre ninguna puerta
nueva.

El resumen de campos sigue ahí, plegado debajo: es la única vista que respeta
el reparto área/gestión y la única donde se ve qué campos quedan vacíos.

Y «Previsualizar PDF» desaparece de la ficha, porque abre en otra pestaña lo
que ya está en pantalla. El editor lo conserva, que es donde sí hace falta.

Un test que comprobaba que solo administración va a wp-admin buscaba la
subcadena «post.php», y `admin-post.php` la contiene; ahora busca la etiqueta
del enlace, que no es ambigua.
La lista repartía cinco etiquetas para dos destinos: «Corregir», «Continuar» y
«Revisar» abrían el editor, «Ver PDF» y «Ver» abrían la ficha. Quien lee una
bandeja no necesita que le cuenten en qué punto del circuito está —para eso
está la columna de estado, justo al lado—, sino si puede tocar el documento o
solo mirarlo.

«Ver PDF» además bajaba a `#exportar`. La ficha ahora abre con el PDF, así que
el ancla saltaba precisamente por encima de lo que iba a buscar.

Lo que no cambia es a quién le sale «Editar»: administración puede modificar un
documento que está en gestión, pero todavía no le toca, así que su fila sigue
diciendo «Ver». Esa distinción vivía repartida entre tres condiciones y ahora
tiene un nombre, `opens_the_editor()`.
@erseco
erseco force-pushed the integra/vista-documento-pdf branch from 81ec903 to 5e89945 Compare September 8, 2026 18:51
@erseco
erseco merged commit 60092da into main Sep 8, 2026
14 of 21 checks passed
@erseco
erseco deleted the integra/vista-documento-pdf branch September 8, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant