Complete grouped collaborative editorial queues and native review coverage
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -2,6 +2,8 @@ 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';
|
||||
import SubjectForm from './editorial-subject-form';
|
||||
import type { SubjectField } from './editorial-subject-form';
|
||||
|
||||
type Edition = {
|
||||
id: string;
|
||||
@@ -27,6 +29,13 @@ type Edition = {
|
||||
fields: Record<string, string | number | null>;
|
||||
territory_context?: { id: string; name: string }[];
|
||||
};
|
||||
_subject?: {
|
||||
kind: string;
|
||||
key: string;
|
||||
fields: Record<string, string | number | boolean | null>;
|
||||
new_record: boolean;
|
||||
withdraw?: boolean;
|
||||
};
|
||||
};
|
||||
files: {
|
||||
id: string;
|
||||
@@ -55,8 +64,16 @@ export default function EditorialEdition({
|
||||
canApprove,
|
||||
independentRequired,
|
||||
subject = 'resource',
|
||||
subjectKind,
|
||||
editUrl,
|
||||
subjectFields = [],
|
||||
subjectInitial = {},
|
||||
}: {
|
||||
subject?: 'resource' | 'portfolio' | 'demography';
|
||||
subject?: 'resource' | 'portfolio' | 'demography' | 'structural';
|
||||
subjectKind?: string;
|
||||
editUrl?: string;
|
||||
subjectFields?: SubjectField[];
|
||||
subjectInitial?: Record<string, string | number | boolean | null>;
|
||||
resource: {
|
||||
id: number | string;
|
||||
title: string;
|
||||
@@ -79,7 +96,10 @@ export default function EditorialEdition({
|
||||
canApprove: boolean;
|
||||
independentRequired: boolean;
|
||||
}) {
|
||||
const editionBase = `/management/editorial/${subject === 'resource' ? 'resources' : subject}/${resource.id}`;
|
||||
const editionBase =
|
||||
subject === 'structural'
|
||||
? `/management/editorial/subjects/${subjectKind}/${resource.id}`
|
||||
: `/management/editorial/${subject === 'resource' ? 'resources' : subject}/${resource.id}`;
|
||||
const form = useForm({
|
||||
version: edition?.version ?? 1,
|
||||
action: '',
|
||||
@@ -103,7 +123,9 @@ export default function EditorialEdition({
|
||||
reject: 'Rejeitar',
|
||||
legal_validate: 'Validar juridicamente',
|
||||
approve: 'Aprovar',
|
||||
publish: 'Publicar',
|
||||
publish: edition?.payload.resource._subject?.withdraw
|
||||
? 'Publicar retirada'
|
||||
: 'Publicar',
|
||||
archive: 'Arquivar',
|
||||
};
|
||||
return (
|
||||
@@ -112,7 +134,14 @@ export default function EditorialEdition({
|
||||
<Link className="underline" href="/management/editorial">
|
||||
Fila e notificações
|
||||
</Link>
|
||||
{subject === 'demography' ? (
|
||||
{subject === 'structural' ? (
|
||||
<Link
|
||||
className="underline"
|
||||
href={editUrl ?? '/management/editorial/subjects'}
|
||||
>
|
||||
Alterar no contexto original
|
||||
</Link>
|
||||
) : subject === 'demography' ? (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/demography?batch=${resource.id}`}
|
||||
@@ -153,6 +182,14 @@ export default function EditorialEdition({
|
||||
{resource.public_edition_no && (
|
||||
<p>Versão pública: edição {resource.public_edition_no}.</p>
|
||||
)}
|
||||
{!edition && subject === 'structural' && (
|
||||
<SubjectForm
|
||||
base={editionBase}
|
||||
revision={1}
|
||||
fields={subjectFields}
|
||||
initial={subjectInitial}
|
||||
/>
|
||||
)}
|
||||
{edition ? (
|
||||
<>
|
||||
<h2 className="font-semibold">
|
||||
@@ -161,20 +198,75 @@ export default function EditorialEdition({
|
||||
</h2>
|
||||
{!edition.fresh && (
|
||||
<p role="alert">
|
||||
Os anexos mudaram ou deixaram de estar disponíveis.
|
||||
Guarde uma nova edição e volte a conferir antes da
|
||||
aprovação.
|
||||
O conteúdo, contexto ou anexos mudaram ou deixaram
|
||||
de estar disponíveis. Guarde uma nova edição e volte
|
||||
a conferir antes da aprovação.
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm break-all">
|
||||
Identificador da edição: {edition.id}
|
||||
<br />
|
||||
Hash do conteúdo e{' '}
|
||||
{subject === 'portfolio' ? 'contexto' : 'anexos'}:{' '}
|
||||
{edition.content_hash}
|
||||
{['portfolio', 'structural'].includes(subject)
|
||||
? 'contexto'
|
||||
: 'anexos'}
|
||||
: {edition.content_hash}
|
||||
</p>
|
||||
<h3 className="font-semibold">Conferir conteúdo</h3>
|
||||
<p>{edition.payload.resource.title}</p>
|
||||
{edition.payload.resource._subject?.withdraw && (
|
||||
<p role="status">
|
||||
Proposta de retirada: o registo actual só será
|
||||
retirado depois da publicação desta decisão.
|
||||
</p>
|
||||
)}
|
||||
{subject === 'structural' &&
|
||||
edition.payload.resource._subject && (
|
||||
<>
|
||||
<dl className="grid gap-2 sm:grid-cols-2">
|
||||
{subjectFields.map((field) => {
|
||||
const value =
|
||||
edition.payload.resource._subject
|
||||
?.fields[field.name];
|
||||
return (
|
||||
<div key={field.name}>
|
||||
<dt className="font-medium">
|
||||
{field.label}
|
||||
</dt>
|
||||
<dd className="break-words whitespace-pre-wrap">
|
||||
{value === null ||
|
||||
value === '' ||
|
||||
value === undefined
|
||||
? 'Não indicado'
|
||||
: typeof value ===
|
||||
'boolean'
|
||||
? value
|
||||
? 'Sim'
|
||||
: 'Não'
|
||||
: String(value)}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</dl>
|
||||
{current && (
|
||||
<SubjectForm
|
||||
key={edition.id}
|
||||
base={editionBase}
|
||||
revision={edition.revision_no}
|
||||
fields={subjectFields}
|
||||
initial={
|
||||
edition.payload.resource._subject
|
||||
.fields
|
||||
}
|
||||
withdraw={
|
||||
edition.payload.resource._subject
|
||||
.withdraw
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<p className="whitespace-pre-wrap">
|
||||
{edition.payload.resource.description}
|
||||
</p>
|
||||
@@ -408,7 +500,10 @@ export default function EditorialEdition({
|
||||
canApprove)) &&
|
||||
(action !== 'approve' ||
|
||||
canApprove) &&
|
||||
(subject !== 'portfolio' ||
|
||||
(![
|
||||
'portfolio',
|
||||
'structural',
|
||||
].includes(subject) ||
|
||||
action !== 'publish' ||
|
||||
canApprove) &&
|
||||
(edition.fresh ||
|
||||
|
||||
Reference in New Issue
Block a user