feat(editorial): preserve public portfolio fiches during private review
This commit is contained in:
@@ -3,6 +3,7 @@ import { Frame, card, button } from '@/pages/investment/shared';
|
||||
import { states } from './shared';
|
||||
|
||||
type Access = {
|
||||
portfolio?: { index: string };
|
||||
clusters?: { index: string };
|
||||
editorial?: { index: string };
|
||||
procurement?: { index: string; create: string };
|
||||
@@ -28,6 +29,20 @@ export default function ContentHub({
|
||||
acção respeita a sua autorização actual.
|
||||
</p>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{access.portfolio && (
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-semibold">
|
||||
Carteira de investimento
|
||||
</h2>
|
||||
<p>
|
||||
Rever versões das fichas de projectos, clusters e
|
||||
corredores, preservando a publicação anterior.
|
||||
</p>
|
||||
<Link className={button} href={access.portfolio.index}>
|
||||
Gerir fichas e revisões da carteira
|
||||
</Link>
|
||||
</section>
|
||||
)}
|
||||
{access.clusters && (
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-semibold">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Field, button, control } from './shared';
|
||||
import { states } from './editorial-workflow';
|
||||
import { labels as portfolioLabels } from '../portfolio/shared';
|
||||
|
||||
type Edition = {
|
||||
id: string;
|
||||
@@ -15,6 +16,8 @@ type Edition = {
|
||||
title: string;
|
||||
description?: string;
|
||||
editorial_content?: string | null;
|
||||
source?: string;
|
||||
content?: Record<string, string | null>;
|
||||
};
|
||||
files: {
|
||||
id: string;
|
||||
@@ -22,6 +25,11 @@ type Edition = {
|
||||
version_no: number;
|
||||
sha256: string;
|
||||
}[];
|
||||
links?: {
|
||||
target_type: string;
|
||||
target_key: string;
|
||||
context?: { name?: string; code?: string; sector?: string };
|
||||
}[];
|
||||
};
|
||||
approval: string | null;
|
||||
legal_validation: string | null;
|
||||
@@ -37,9 +45,11 @@ export default function EditorialEdition({
|
||||
current,
|
||||
canApprove,
|
||||
independentRequired,
|
||||
subject = 'resource',
|
||||
}: {
|
||||
subject?: 'resource' | 'portfolio';
|
||||
resource: {
|
||||
id: number;
|
||||
id: number | string;
|
||||
title: string;
|
||||
published: boolean;
|
||||
public_edition_no?: number | null;
|
||||
@@ -60,6 +70,7 @@ export default function EditorialEdition({
|
||||
canApprove: boolean;
|
||||
independentRequired: boolean;
|
||||
}) {
|
||||
const editionBase = `/management/editorial/${subject === 'portfolio' ? 'portfolio' : 'resources'}/${resource.id}`;
|
||||
const form = useForm({
|
||||
version: edition?.version ?? 1,
|
||||
action: '',
|
||||
@@ -92,15 +103,31 @@ export default function EditorialEdition({
|
||||
<Link className="underline" href="/management/editorial">
|
||||
Fila e notificações
|
||||
</Link>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/portal-services/resources/${resource.id}/article`}
|
||||
>
|
||||
Alterar artigo
|
||||
</Link>
|
||||
<Link className="underline" href="/management/portal-services">
|
||||
Alterar metadados/documento
|
||||
</Link>
|
||||
{subject === 'portfolio' ? (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/portfolio/${resource.id}`}
|
||||
>
|
||||
Alterar ficha da carteira
|
||||
</Link>
|
||||
) : (
|
||||
<>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/portal-services/resources/${resource.id}/article`}
|
||||
>
|
||||
Alterar artigo
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
{subject === 'resource' && (
|
||||
<Link
|
||||
className="underline"
|
||||
href="/management/portal-services"
|
||||
>
|
||||
Alterar metadados/documento
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<p>
|
||||
{resource.published
|
||||
@@ -126,13 +153,44 @@ export default function EditorialEdition({
|
||||
<p className="text-sm break-all">
|
||||
Identificador da edição: {edition.id}
|
||||
<br />
|
||||
Hash do conteúdo e anexos: {edition.content_hash}
|
||||
Hash do conteúdo e{' '}
|
||||
{subject === 'portfolio' ? 'contexto' : 'anexos'}:{' '}
|
||||
{edition.content_hash}
|
||||
</p>
|
||||
<h3 className="font-semibold">Conferir conteúdo</h3>
|
||||
<p>{edition.payload.resource.title}</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{edition.payload.resource.description}
|
||||
</p>
|
||||
{subject === 'portfolio' && (
|
||||
<>
|
||||
<p>Fonte: {edition.payload.resource.source}</p>
|
||||
<dl>
|
||||
{Object.entries(
|
||||
edition.payload.resource.content ?? {},
|
||||
).map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">
|
||||
{portfolioLabels[key] ?? key}
|
||||
</dt>
|
||||
<dd className="whitespace-pre-wrap">
|
||||
{value}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</>
|
||||
)}
|
||||
{subject === 'portfolio' &&
|
||||
edition.payload.links?.map((link) => (
|
||||
<p key={link.target_key}>
|
||||
Contexto: {link.context?.name} ·{' '}
|
||||
{link.context?.code}
|
||||
{link.context?.sector
|
||||
? ` · ${link.context.sector}`
|
||||
: ''}
|
||||
</p>
|
||||
))}
|
||||
{edition.payload.resource.editorial_content && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
{
|
||||
@@ -193,7 +251,7 @@ export default function EditorialEdition({
|
||||
assigned_to: data.assigned_to || null,
|
||||
}));
|
||||
form.post(
|
||||
`/management/editorial/resources/${resource.id}/editions/${edition.id}`,
|
||||
`${editionBase}/editions/${edition.id}`,
|
||||
{
|
||||
onSuccess: () =>
|
||||
form.reset('action', 'reason'),
|
||||
@@ -225,8 +283,16 @@ export default function EditorialEdition({
|
||||
canApprove)) &&
|
||||
(action !== 'approve' ||
|
||||
canApprove) &&
|
||||
(subject !== 'portfolio' ||
|
||||
action !== 'publish' ||
|
||||
canApprove) &&
|
||||
(edition.fresh ||
|
||||
action === 'archive'),
|
||||
[
|
||||
'archive',
|
||||
'return',
|
||||
'reject',
|
||||
'start_review',
|
||||
].includes(action)),
|
||||
)
|
||||
.map((action) => (
|
||||
<option key={action} value={action}>
|
||||
@@ -286,10 +352,7 @@ export default function EditorialEdition({
|
||||
) : (
|
||||
<p>
|
||||
Versão histórica para consulta.{' '}
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/editorial/resources/${resource.id}`}
|
||||
>
|
||||
<Link className="underline" href={editionBase}>
|
||||
Voltar à edição actual
|
||||
</Link>
|
||||
</p>
|
||||
@@ -307,7 +370,7 @@ export default function EditorialEdition({
|
||||
<li key={e.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/editorial/resources/${resource.id}?edition=${e.id}`}
|
||||
href={`${editionBase}?edition=${e.id}`}
|
||||
>
|
||||
Edição {e.revision_no}: {states[e.state] ?? e.state}
|
||||
</Link>
|
||||
|
||||
@@ -38,11 +38,15 @@ export default function EditorialWorkflow({
|
||||
opportunitiesUrl,
|
||||
opportunityPending,
|
||||
clustersUrl,
|
||||
portfolioUrl,
|
||||
portfolioPending = 0,
|
||||
}: {
|
||||
resourceAccess: boolean;
|
||||
opportunitiesUrl: string | null;
|
||||
opportunityPending: number;
|
||||
clustersUrl?: string | null;
|
||||
portfolioUrl?: string | null;
|
||||
portfolioPending?: number;
|
||||
filters?: { state?: string; kind?: string };
|
||||
items: { data: Item[]; current_page: number; last_page: number };
|
||||
notices: {
|
||||
@@ -63,6 +67,11 @@ export default function EditorialWorkflow({
|
||||
próprio.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{portfolioUrl && (
|
||||
<Link className="underline" href={portfolioUrl}>
|
||||
Carteira: {portfolioPending} fichas pendentes
|
||||
</Link>
|
||||
)}
|
||||
{clustersUrl && (
|
||||
<Link className="underline" href={clustersUrl}>
|
||||
Competitividade dos clusters
|
||||
|
||||
@@ -29,6 +29,7 @@ export default function Show(props: Props) {
|
||||
}
|
||||
|
||||
type Props = {
|
||||
editorialEnabled?: boolean;
|
||||
competitiveness?: ApprovedCompetitiveness | null;
|
||||
complements?: ComplementOption[];
|
||||
geography: StructureGeography;
|
||||
@@ -63,6 +64,7 @@ type Props = {
|
||||
};
|
||||
|
||||
function Editor({
|
||||
editorialEnabled = false,
|
||||
competitiveness,
|
||||
complements = [],
|
||||
record,
|
||||
@@ -423,43 +425,57 @@ function Editor({
|
||||
Guardar rascunho
|
||||
</button>
|
||||
</form>
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
approval.post(`${base}/${record.id}/publish`);
|
||||
}}
|
||||
>
|
||||
<p>
|
||||
O gestor autorizado pode aprovar e publicar esta
|
||||
ficha. Registe a referência da sua decisão.
|
||||
{editorialEnabled ? (
|
||||
<p className="rounded border p-4">
|
||||
A edição privada preserva a ficha pública anterior.{' '}
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/editorial/portfolio/${record.id}`}
|
||||
>
|
||||
Conferir versões, submeter, aprovar e publicar
|
||||
no circuito editorial
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
<Field label="Referência da autorização e revisão">
|
||||
<textarea
|
||||
className={control}
|
||||
required
|
||||
minLength={15}
|
||||
value={approval.data.approval_evidence}
|
||||
onChange={(e) =>
|
||||
approval.setData(
|
||||
'approval_evidence',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{approval.errors.approval_evidence && (
|
||||
<p role="alert">
|
||||
{approval.errors.approval_evidence}
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={approval.processing || form.isDirty}
|
||||
) : (
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
approval.post(`${base}/${record.id}/publish`);
|
||||
}}
|
||||
>
|
||||
Validar e publicar
|
||||
</button>
|
||||
</form>
|
||||
<p>
|
||||
O gestor autorizado pode aprovar e publicar esta
|
||||
ficha. Registe a referência da sua decisão.
|
||||
</p>
|
||||
<Field label="Referência da autorização e revisão">
|
||||
<textarea
|
||||
className={control}
|
||||
required
|
||||
minLength={15}
|
||||
value={approval.data.approval_evidence}
|
||||
onChange={(e) =>
|
||||
approval.setData(
|
||||
'approval_evidence',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{approval.errors.approval_evidence && (
|
||||
<p role="alert">
|
||||
{approval.errors.approval_evidence}
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={approval.processing || form.isDirty}
|
||||
>
|
||||
Validar e publicar
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user