feat(checklist): adiciona opção de desmarcar todos os itens
O botão "Concluir todos" agora alterna para "Desmarcar todos" quando todos os itens do checklist estão marcados como concluídos. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2c21daee79
commit
bc5ba0c73a
2 changed files with 57 additions and 12 deletions
|
|
@ -2722,6 +2722,34 @@ export const completeAllChecklistItems = mutation({
|
|||
},
|
||||
});
|
||||
|
||||
export const uncompleteAllChecklistItems = mutation({
|
||||
args: {
|
||||
ticketId: v.id("tickets"),
|
||||
actorId: v.id("users"),
|
||||
},
|
||||
handler: async (ctx, { ticketId, actorId }) => {
|
||||
const ticket = await ctx.db.get(ticketId);
|
||||
if (!ticket) {
|
||||
throw new ConvexError("Ticket não encontrado");
|
||||
}
|
||||
const ticketDoc = ticket as Doc<"tickets">;
|
||||
const viewer = await requireTicketStaff(ctx, actorId, ticketDoc);
|
||||
ensureChecklistEditor(viewer);
|
||||
|
||||
const checklist = normalizeTicketChecklist(ticketDoc.checklist);
|
||||
if (checklist.length === 0) return { ok: true };
|
||||
|
||||
const now = Date.now();
|
||||
const nextChecklist = checklist.map((item) => {
|
||||
if (item.done === false) return item;
|
||||
return { ...item, done: false, doneAt: undefined, doneBy: undefined };
|
||||
});
|
||||
|
||||
await ctx.db.patch(ticketId, { checklist: nextChecklist, updatedAt: now });
|
||||
return { ok: true };
|
||||
},
|
||||
});
|
||||
|
||||
export const applyChecklistTemplate = mutation({
|
||||
args: {
|
||||
ticketId: v.id("tickets"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue