feat: add Svelte DnD action and enhance flow management features

- Added "svelte-dnd-action" dependency to facilitate drag-and-drop functionality.
- Introduced new "Fluxos de Trabalho" section in the dashboard for managing workflow templates and instances.
- Updated permission handling for sectors and flow templates in the backend.
- Enhanced schema definitions to support flow templates, instances, and associated documents.
- Improved UI components to include new workflow management features across various dashboard pages.
This commit is contained in:
2025-11-25 00:21:35 -03:00
parent 409872352c
commit f8d9c17f63
16 changed files with 4073 additions and 5 deletions

View File

@@ -120,6 +120,31 @@ export const reportStatus = v.union(
v.literal("falhou")
);
// Status de templates de fluxo
export const flowTemplateStatus = v.union(
v.literal("draft"),
v.literal("published"),
v.literal("archived")
);
export type FlowTemplateStatus = Infer<typeof flowTemplateStatus>;
// Status de instâncias de fluxo
export const flowInstanceStatus = v.union(
v.literal("active"),
v.literal("completed"),
v.literal("cancelled")
);
export type FlowInstanceStatus = Infer<typeof flowInstanceStatus>;
// Status de passos de instância de fluxo
export const flowInstanceStepStatus = v.union(
v.literal("pending"),
v.literal("in_progress"),
v.literal("completed"),
v.literal("blocked")
);
export type FlowInstanceStepStatus = Infer<typeof flowInstanceStepStatus>;
export const situacaoContrato = v.union(
v.literal("em_execucao"),
v.literal("rescendido"),
@@ -128,6 +153,85 @@ export const situacaoContrato = v.union(
);
export default defineSchema({
// Setores da organização
setores: defineTable({
nome: v.string(),
sigla: v.string(),
criadoPor: v.id("usuarios"),
createdAt: v.number(),
})
.index("by_nome", ["nome"])
.index("by_sigla", ["sigla"]),
// Templates de fluxo
flowTemplates: defineTable({
name: v.string(),
description: v.optional(v.string()),
status: flowTemplateStatus,
createdBy: v.id("usuarios"),
createdAt: v.number(),
})
.index("by_status", ["status"])
.index("by_createdBy", ["createdBy"]),
// Passos de template de fluxo
flowSteps: defineTable({
flowTemplateId: v.id("flowTemplates"),
name: v.string(),
description: v.optional(v.string()),
position: v.number(),
expectedDuration: v.number(), // em dias
setorId: v.id("setores"),
defaultAssigneeId: v.optional(v.id("usuarios")),
requiredDocuments: v.optional(v.array(v.string())),
})
.index("by_flowTemplateId", ["flowTemplateId"])
.index("by_flowTemplateId_and_position", ["flowTemplateId", "position"]),
// Instâncias de fluxo
flowInstances: defineTable({
flowTemplateId: v.id("flowTemplates"),
targetType: v.string(), // ex: 'contrato', 'projeto'
targetId: v.string(), // ID genérico do alvo
managerId: v.id("usuarios"),
status: flowInstanceStatus,
startedAt: v.number(),
finishedAt: v.optional(v.number()),
currentStepId: v.optional(v.id("flowInstanceSteps")),
})
.index("by_flowTemplateId", ["flowTemplateId"])
.index("by_targetType_and_targetId", ["targetType", "targetId"])
.index("by_managerId", ["managerId"])
.index("by_status", ["status"]),
// Passos de instância de fluxo
flowInstanceSteps: defineTable({
flowInstanceId: v.id("flowInstances"),
flowStepId: v.id("flowSteps"),
setorId: v.id("setores"),
assignedToId: v.optional(v.id("usuarios")),
status: flowInstanceStepStatus,
startedAt: v.optional(v.number()),
finishedAt: v.optional(v.number()),
notes: v.optional(v.string()),
dueDate: v.optional(v.number()),
})
.index("by_flowInstanceId", ["flowInstanceId"])
.index("by_flowInstanceId_and_status", ["flowInstanceId", "status"])
.index("by_setorId", ["setorId"])
.index("by_assignedToId", ["assignedToId"]),
// Documentos de instância de fluxo
flowInstanceDocuments: defineTable({
flowInstanceStepId: v.id("flowInstanceSteps"),
uploadedById: v.id("usuarios"),
storageId: v.id("_storage"),
name: v.string(),
uploadedAt: v.number(),
})
.index("by_flowInstanceStepId", ["flowInstanceStepId"])
.index("by_uploadedById", ["uploadedById"]),
contratos: defineTable({
contratadaId: v.id("empresas"),
objeto: v.string(),
@@ -210,6 +314,7 @@ export default defineSchema({
simboloId: v.id("simbolos"),
simboloTipo: simboloTipo,
gestorId: v.optional(v.id("usuarios")),
setorId: v.optional(v.id("setores")), // Setor do funcionário
statusFerias: v.optional(
v.union(v.literal("ativo"), v.literal("em_ferias"))
),
@@ -349,7 +454,8 @@ export default defineSchema({
.index("by_simboloTipo", ["simboloTipo"])
.index("by_cpf", ["cpf"])
.index("by_rg", ["rg"])
.index("by_gestor", ["gestorId"]),
.index("by_gestor", ["gestorId"])
.index("by_setor", ["setorId"]),
atestados: defineTable({
funcionarioId: v.id("funcionarios"),