This commit is contained in:
2026-11-02 08:08:05 +02:00
parent 13a6cb9922
commit 504b01b244
246 changed files with 24499 additions and 185 deletions
+126 -3
View File
@@ -12,8 +12,15 @@ import {
controlClass,
} from '@/components/procurement';
import { Button } from '@/components/ui/button';
import { WorkContextSettings } from '@/components/work-context-settings';
import type { WorkContextState } from '@/types/work-context';
type Profile = { id: number; name: string; permissions: string[] };
type Profile = {
id: number;
name: string;
permissions: string[];
work_contexts: string[];
};
type Member = {
user_id: number;
profile_id: number;
@@ -160,6 +167,7 @@ export default function Parameters({
active,
version,
permissions,
workflowTasks = {},
profiles,
memberships,
users,
@@ -173,6 +181,8 @@ export default function Parameters({
aiPlan,
aiDomains = {},
aiDataScopes = {},
workContextConfiguration,
enabledWorkContexts = [],
}: {
ready: boolean;
comparisonPolicy: ComparisonPolicy;
@@ -181,9 +191,12 @@ export default function Parameters({
aiPlan?: AiPlan;
aiDomains?: Record<string, string>;
aiDataScopes?: Record<string, string>;
workContextConfiguration?: WorkContextState;
enabledWorkContexts?: string[];
active: boolean;
version: number;
permissions: { [key: string]: string };
workflowTasks?: Record<string, { key: string; label: string }[]>;
profiles: Profile[];
memberships: Member[];
users: Person[];
@@ -203,6 +216,7 @@ export default function Parameters({
id: '',
name: '',
permissions: [] as string[],
work_contexts: [] as string[],
});
const user = useForm({
version,
@@ -353,6 +367,13 @@ export default function Parameters({
ready={intelligenceReady}
/>
)}
{workContextConfiguration && (
<WorkContextSettings
context={workContextConfiguration}
enabled={enabledWorkContexts}
version={version}
/>
)}
<Panel title="Regras de comparação de propostas">
<p className="mb-4 text-sm">
{comparisonPolicy.configured
@@ -656,6 +677,8 @@ export default function Parameters({
id: String(p.id),
name: p.name,
permissions: p.permissions,
work_contexts:
p.work_contexts ?? [],
})
}
>
@@ -693,9 +716,55 @@ export default function Parameters({
}
/>
</label>
{workContextConfiguration && (
<fieldset className="space-y-2">
<legend className="font-medium">
Contextos autorizados deste perfil
</legend>
<p className="text-sm">
A associação não acrescenta
permissões funcionais nem opções
contratadas.
</p>
{Object.entries(
workContextConfiguration.options,
).map(([key, option]) => (
<label
className="flex items-center gap-2"
key={key}
>
<input
type="checkbox"
checked={profile.data.work_contexts.includes(
key,
)}
onChange={(e) =>
profile.setData(
'work_contexts',
e.target.checked
? [
...profile
.data
.work_contexts,
key,
]
: profile.data.work_contexts.filter(
(value) =>
value !==
key,
),
)
}
/>
{option.areaLabel} ·{' '}
{option.label}
</label>
))}
</fieldset>
)}
<fieldset className="grid gap-3 sm:grid-cols-2">
<legend className="mb-2 font-medium">
Permissões funcionais
Tarefas e permissões do perfil
</legend>
{Object.entries(permissions).map(
([key, label]) => (
@@ -726,11 +795,64 @@ export default function Parameters({
)
}
/>
{label}
<span>
{label}
<span className="mt-1 block text-xs text-muted-foreground">
{(
workflowTasks[
key
] ?? []
).map((task) => (
<span
className="block"
key={task.key}
>
{task.label}
</span>
))}
</span>
</span>
</label>
),
)}
</fieldset>
<div className="rounded-md border p-4 text-sm">
<p className="font-medium">
Tarefas associadas a este perfil no
workflow
</p>
<p className="mt-2 text-muted-foreground">
Seleccione as tarefas nas permissões
acima e atribua o perfil às pessoas. O
contexto, departamento, equipa do
processo, validade do acesso e
independência continuam a limitar cada
intervenção. Administração, por si só,
não autoriza decisões de compras. Estas
associações não alteram o percurso
aprovado.
</p>
{profile.data.permissions.length === 0 ? (
<p className="mt-3">
Sem tarefas seleccionadas.
</p>
) : (
<ul className="mt-3 list-disc space-y-1 pl-5">
{profile.data.permissions
.flatMap(
(permission) =>
workflowTasks[
permission
] ?? [],
)
.map((task) => (
<li key={task.key}>
{task.label}
</li>
))}
</ul>
)}
</div>
<div className="flex gap-3">
<Button disabled={profile.processing}>
{profile.data.id
@@ -746,6 +868,7 @@ export default function Parameters({
id: '',
name: '',
permissions: [],
work_contexts: [],
})
}
>