mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 11:47:47 +01:00
Bug fixes and improvements in database views
This commit is contained in:
@@ -152,7 +152,7 @@ export type UpdateMutation = Updateable<MutationTable>;
|
||||
interface TombstoneTable {
|
||||
id: ColumnType<string, string, never>;
|
||||
data: ColumnType<string, string, never>;
|
||||
created_at: ColumnType<string, string, never>;
|
||||
deleted_at: ColumnType<string, string, never>;
|
||||
}
|
||||
|
||||
export type SelectTombsonte = Selectable<TombstoneTable>;
|
||||
|
||||
@@ -49,6 +49,7 @@ export class ViewCreateMutationHandler
|
||||
index: generateNodeIndex(maxIndex, null),
|
||||
layout: input.viewType,
|
||||
parentId: input.databaseId,
|
||||
groupBy: input.groupBy,
|
||||
};
|
||||
|
||||
await workspace.nodes.createNode({
|
||||
|
||||
@@ -210,7 +210,7 @@ export class NodeReactionService {
|
||||
.values({
|
||||
id: tombstoneId,
|
||||
data: JSON.stringify(deletedNodeReaction),
|
||||
created_at: new Date().toISOString(),
|
||||
deleted_at: new Date().toISOString(),
|
||||
})
|
||||
.executeTakeFirst();
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ export class NodeService {
|
||||
.values({
|
||||
id: deletedNode.id,
|
||||
data: JSON.stringify(deletedNode),
|
||||
created_at: new Date().toISOString(),
|
||||
deleted_at: new Date().toISOString(),
|
||||
})
|
||||
.execute();
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ export const BoardView = () => {
|
||||
(field) => field.id === view.groupBy
|
||||
);
|
||||
|
||||
if (!groupByField || groupByField.type !== 'select') {
|
||||
return null;
|
||||
}
|
||||
const selectOptions =
|
||||
groupByField && groupByField.type === 'select'
|
||||
? Object.values(groupByField.options ?? {})
|
||||
: [];
|
||||
|
||||
const selectOptions = Object.values(groupByField.options ?? {});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="flex flex-row justify-between border-b">
|
||||
@@ -34,15 +34,17 @@ export const BoardView = () => {
|
||||
</div>
|
||||
<ViewSearchBar />
|
||||
<div className="mt-2 flex w-full min-w-full max-w-full flex-row gap-2 overflow-auto pr-5">
|
||||
{selectOptions.map((option) => {
|
||||
return (
|
||||
<BoardViewColumn
|
||||
key={option.id}
|
||||
field={groupByField}
|
||||
option={option}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{groupByField &&
|
||||
groupByField.type === 'select' &&
|
||||
selectOptions.map((option) => {
|
||||
return (
|
||||
<BoardViewColumn
|
||||
key={option.id}
|
||||
field={groupByField}
|
||||
option={option}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
@@ -20,14 +20,15 @@ export const DatabaseViews = () => {
|
||||
databaseId: database.id,
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!activeViewId) {
|
||||
setActiveViewId(data?.[0]?.id ?? null);
|
||||
}
|
||||
}, [data, activeViewId]);
|
||||
|
||||
const views = data ?? [];
|
||||
const activeView = views.find((view) => view.id === activeViewId);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (views.length > 0 && !views.some((view) => view.id === activeViewId)) {
|
||||
setActiveViewId(views[0]?.id ?? null);
|
||||
}
|
||||
}, [views, activeViewId]);
|
||||
|
||||
return (
|
||||
<DatabaseViewsContext.Provider
|
||||
value={{ views, activeViewId: activeViewId ?? '', setActiveViewId }}
|
||||
|
||||
Reference in New Issue
Block a user