Skip to content

Commit

Permalink
Merge pull request #179 from cabcookie:split-notes-in-blocks
Browse files Browse the repository at this point in the history
Notizen in separaten Blöcken speichern
  • Loading branch information
cabcookie authored Aug 26, 2024
2 parents 000f36a + 68d5228 commit 71add59
Show file tree
Hide file tree
Showing 120 changed files with 7,996 additions and 9,284 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ next-env.d.ts
amplify_outputs*
scripts/import-data/*
scripts/env.json
components/ui-elements/notes-writer/mentions/example
20 changes: 12 additions & 8 deletions amplify/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ const backend = defineBackend({
storage,
});

const dataResources = backend.data.resources;

Object.values(dataResources.cfnResources.amplifyDynamoDbTables).forEach(
(table) => {
table.pointInTimeRecoveryEnabled = true;
table.deletionProtectionEnabled = true;
table.applyRemovalPolicy(RemovalPolicy.RETAIN);
}
const backendType = backend.auth.resources.userPool.node.tryGetContext(
"amplify-backend-type"
);
if (backendType !== "sandbox") {
const dataResources = backend.data.resources;
Object.values(dataResources.cfnResources.amplifyDynamoDbTables).forEach(
(table) => {
table.pointInTimeRecoveryEnabled = true;
table.deletionProtectionEnabled = true;
table.applyRemovalPolicy(RemovalPolicy.RETAIN);
}
);
}
69 changes: 60 additions & 9 deletions amplify/data/activity-schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { a } from "@aws-amplify/backend";

const activitySchema = {
TodoStatus: a.enum(["OPEN", "DONE"]),
ProjectActivity: a
.model({
owner: a
Expand All @@ -13,27 +14,77 @@ const activitySchema = {
})
.secondaryIndexes((index) => [index("projectsId")])
.authorization((allow) => [allow.owner()]),
NoteBlockPerson: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
personId: a.id().required(),
person: a.belongsTo("Person", "personId"),
noteBlockId: a.id().required(),
noteBlock: a.belongsTo("NoteBlock", "noteBlockId"),
})
.authorization((allow) => [allow.owner()]),
NoteBlock: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
content: a.json(),
type: a.string().required(),
formatVersion: a.integer().required(),
activityId: a.id().required(),
activity: a.belongsTo("Activity", "activityId"),
todoId: a.id(),
todo: a.belongsTo("Todo", "todoId"),
people: a.hasMany("NoteBlockPerson", "noteBlockId"),
})
.secondaryIndexes((index) => [index("type")])
.authorization((allow) => [allow.owner()]),
ProjectTodo: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
todoId: a.id().required(),
todo: a.belongsTo("Todo", "todoId"),
projectIdTodoStatus: a.string().required(),
})
.secondaryIndexes((index) => [
index("projectIdTodoStatus"),
index("todoId"),
])
.authorization((allow) => [allow.owner()]),
Todo: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
todo: a.json().required(),
status: a.ref("TodoStatus").required(),
doneOn: a.date(),
activity: a.hasOne("NoteBlock", "todoId"),
projects: a.hasMany("ProjectTodo", "todoId"),
dailyTodos: a.hasMany("DailyPlanTodo", "todoId"),
})
.secondaryIndexes((index) => [index("status")])
.authorization((allow) => [allow.owner()]),
Activity: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
notionId: a.integer(),
notes: a.string(),
formatVersion: a.integer().default(1),
notesJson: a.json(),
hasOpenTasks: a.string().required(),
forProjects: a.hasMany("ProjectActivity", "activityId"),
meetingActivitiesId: a.id(),
forMeeting: a.belongsTo("Meeting", "meetingActivitiesId"),
finishedOn: a.datetime(),
dailyTasks: a.hasMany("DailyPlanTask", "activityId"),
noteBlocks: a.hasMany("NoteBlock", "activityId"),
noteBlockIds: a.string().required().array(),
notes: a.string(), // DEPRECATED
notesJson: a.json(), // DEPRECATED
})
.secondaryIndexes((index) => [
index("hasOpenTasks")
.sortKeys(["finishedOn"])
.queryField("listActivitiesByOpenTasks"),
])
.authorization((allow) => [allow.owner()]),
};

Expand Down
1 change: 1 addition & 0 deletions amplify/data/person-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const personSchmema = {
details: a.hasMany("PersonDetail", "personId"),
learnings: a.hasMany("PersonLearning", "personId"),
profile: a.hasOne("User", "personId"),
noteBlocks: a.hasMany("NoteBlockPerson", "personId"),
})
.authorization((allow) => [allow.owner()]),
};
Expand Down
12 changes: 4 additions & 8 deletions amplify/data/planning-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,22 @@ const planningSchema = {
dayGoal: a.string().required(),
context: a.ref("Context").required(),
status: a.ref("DailyPlanStatus").required(),
tasks: a.hasMany("DailyPlanTask", "dailyPlanId"),
todos: a.hasMany("DailyPlanTodo", "dailyPlanId"),
})
.secondaryIndexes((index) => [
index("status").sortKeys(["day"]).queryField("listByStatus"),
])
.authorization((allow) => [allow.owner()]),
DailyPlanTask: a
DailyPlanTodo: a
.model({
owner: a
.string()
.authorization((allow) => [allow.owner().to(["read", "delete"])]),
dailyPlanId: a.id().required(),
dailyPlan: a.belongsTo("DailyPlan", "dailyPlanId"),
activityId: a.id().required(),
activity: a.belongsTo("Activity", "activityId"),
taskIndex: a.integer().required(),
isInFocus: a.boolean().required(),
task: a.json().required(),
todoId: a.id().required(),
todo: a.belongsTo("Todo", "todoId"),
})
.identifier(["dailyPlanId", "activityId", "taskIndex"])
.authorization((allow) => [allow.owner()]),
};

Expand Down
1 change: 0 additions & 1 deletion amplify/data/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const schema = a
note: a.string(),
formatVersion: a.integer().default(1),
noteJson: a.json(),
hasOpenTasks: a.string().required(),
status: a.id().required(),
movedToActivityId: a.string(),
})
Expand Down
14 changes: 6 additions & 8 deletions api/ContextAccounts.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { type Schema } from "@/amplify/data/resource";
import { emptyDocument } from "@/components/ui-elements/editors/helpers/document";
import { toast } from "@/components/ui/use-toast";
import {
calcAccountAndSubsidariesPipeline,
calcOrder,
getQuotaFromTerritoryOrSubsidaries,
} from "@/helpers/accounts";
import {
EditorJsonContent,
emptyDocument,
transformNotesVersion,
} from "@/helpers/ui-notes-writer";
import { transformNotesVersion } from "@/helpers/ui-notes-writer";
import { JSONContent } from "@tiptap/core";
import { SelectionSet, generateClient } from "aws-amplify/data";
import { filter, flow, get, join, map, sortBy, sum } from "lodash/fp";
import { FC, ReactNode, createContext, useContext } from "react";
Expand All @@ -21,7 +19,7 @@ type UpdateAccountProps = {
id: string;
name?: string;
crmId?: string;
introduction?: EditorJsonContent;
introduction?: JSONContent;
};

interface AccountsContextType {
Expand Down Expand Up @@ -58,7 +56,7 @@ export type Account = {
id: string;
name: string;
crmId?: string;
introduction: EditorJsonContent;
introduction: JSONContent;
controller?: {
id: string;
name: string;
Expand Down Expand Up @@ -179,7 +177,7 @@ const addOrderNumberToAccounts = (
[]
);

const fetchAccounts = async () => {
export const fetchAccounts = async () => {
const { data, errors } = await client.models.Account.list({
limit: 500,
selectionSet,
Expand Down
164 changes: 0 additions & 164 deletions api/ContextOpenTasks.tsx

This file was deleted.

Loading

0 comments on commit 71add59

Please sign in to comment.