feat: card checklists (#141)
* feat: setup checklist schema * feat: scaffold checklist router * feat: add create new checklist modal * feat: create new checklist item * feat: toggle checklist item completed state * feat: update checklist name * feat: delete checklist * feat: show checklists progress on cards * feat: tweak light mode styling * feat: focus item form on creation of new checklist * feat: tweak new checklist item form styling * feat: add checklist activity * feat: show checklist progress on public board page * feat: display checklist items on public card modal * chore: add translations
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
import { checklists } from "./checklists";
|
||||
import { imports } from "./imports";
|
||||
import { labels } from "./labels";
|
||||
import { lists } from "./lists";
|
||||
@@ -31,6 +32,15 @@ export const activityTypes = [
|
||||
"card.updated.comment.added",
|
||||
"card.updated.comment.updated",
|
||||
"card.updated.comment.deleted",
|
||||
// Checklist activities
|
||||
"card.updated.checklist.added",
|
||||
"card.updated.checklist.renamed",
|
||||
"card.updated.checklist.deleted",
|
||||
"card.updated.checklist.item.added",
|
||||
"card.updated.checklist.item.updated",
|
||||
"card.updated.checklist.item.completed",
|
||||
"card.updated.checklist.item.uncompleted",
|
||||
"card.updated.checklist.item.deleted",
|
||||
"card.archived",
|
||||
] as const;
|
||||
|
||||
@@ -84,6 +94,7 @@ export const cardsRelations = relations(cards, ({ one, many }) => ({
|
||||
}),
|
||||
comments: many(comments),
|
||||
activities: many(cardActivities),
|
||||
checklists: many(checklists),
|
||||
}));
|
||||
|
||||
export const cardActivities = pgTable("card_activity", {
|
||||
|
||||
90
packages/db/src/schema/checklists.ts
Normal file
90
packages/db/src/schema/checklists.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { relations } from "drizzle-orm";
|
||||
import {
|
||||
bigint,
|
||||
bigserial,
|
||||
boolean,
|
||||
integer,
|
||||
pgTable,
|
||||
timestamp,
|
||||
uuid,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
import { cards } from "./cards";
|
||||
import { users } from "./users";
|
||||
|
||||
export const checklists = pgTable("card_checklist", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
index: integer("index").notNull(),
|
||||
cardId: bigint("cardId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => cards.id, { onDelete: "cascade" }),
|
||||
createdBy: uuid("createdBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
}).enableRLS();
|
||||
|
||||
export const checklistsRelations = relations(checklists, ({ one, many }) => ({
|
||||
card: one(cards, {
|
||||
fields: [checklists.cardId],
|
||||
references: [cards.id],
|
||||
relationName: "checklistsCard",
|
||||
}),
|
||||
createdBy: one(users, {
|
||||
fields: [checklists.createdBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistsCreatedByUser",
|
||||
}),
|
||||
deletedBy: one(users, {
|
||||
fields: [checklists.deletedBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistsDeletedByUser",
|
||||
}),
|
||||
items: many(checklistItems),
|
||||
}));
|
||||
|
||||
export const checklistItems = pgTable("card_checklist_item", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
title: varchar("title", { length: 500 }).notNull(),
|
||||
completed: boolean("completed").notNull().default(false),
|
||||
index: integer("index").notNull(),
|
||||
checklistId: bigint("checklistId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => checklists.id, { onDelete: "cascade" }),
|
||||
createdBy: uuid("createdBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
}).enableRLS();
|
||||
|
||||
export const checklistItemsRelations = relations(checklistItems, ({ one }) => ({
|
||||
checklist: one(checklists, {
|
||||
fields: [checklistItems.checklistId],
|
||||
references: [checklists.id],
|
||||
relationName: "checklistItemsChecklist",
|
||||
}),
|
||||
createdBy: one(users, {
|
||||
fields: [checklistItems.createdBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistItemsCreatedByUser",
|
||||
}),
|
||||
deletedBy: one(users, {
|
||||
fields: [checklistItems.deletedBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistItemsDeletedByUser",
|
||||
}),
|
||||
}));
|
||||
@@ -2,6 +2,7 @@ export * from "./auth";
|
||||
export * from "./boards";
|
||||
export * from "./auth";
|
||||
export * from "./cards";
|
||||
export * from "./checklists";
|
||||
export * from "./feedback";
|
||||
export * from "./imports";
|
||||
export * from "./labels";
|
||||
|
||||
Reference in New Issue
Block a user