Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Kanban Cards to display selections #182

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "query-builder",
"version": "1.16.0",
"version": "1.17.0",
"description": "Introduces new user interfaces for building queries in Roam",
"main": "./build/main.js",
"author": {
Expand Down
40 changes: 35 additions & 5 deletions src/components/Kanban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
useState,
} from "react";
import { Column, Result } from "../utils/types";
import { Button, Icon, Popover, Tooltip } from "@blueprintjs/core";
import { Button, HTMLTable, Icon, Popover, Tooltip } from "@blueprintjs/core";
import Draggable from "react-draggable";
import setInputSettings from "roamjs-components/util/setInputSettings";
import openBlockInSidebar from "roamjs-components/writes/openBlockInSidebar";
Expand All @@ -28,6 +28,8 @@ const KanbanCard = (card: {
$priority: number;
$reprioritize: Reprioritize;
$displayKey: string;
$columnKey: string;
$selectionValues: string[];
$getColumnElement: (x: number) => HTMLDivElement | undefined;
result: Result;
}) => {
Expand Down Expand Up @@ -74,10 +76,36 @@ const KanbanCard = (card: {
}}
>
<div className={`rounded-xl bg-white p-4 hover:bg-gray-200`}>
{toCellValue({
value: card.result[card.$displayKey],
uid: card.result[`${card.$displayKey}-uid`],
})}
<div className="card-display-value">
{toCellValue({
value: card.result[card.$displayKey],
uid: card.result[`${card.$displayKey}-uid`],
})}
</div>
<div className="card-selections mt-3">
<HTMLTable condensed={true}>
<tbody>
{card.$selectionValues.map((sv) => {
if (sv === card.$displayKey || sv === card.$columnKey)
return null;
const value = toCellValue({
value:
card.result[`${sv}-display`] || card.result[sv] || "",
uid: (card.result[`${sv}-uid`] as string) || "",
});

return (
<tr key={sv}>
<td className="font-semibold text-sm text-gray-700 p-1">
{sv}:
</td>
<td className="text-sm text-gray-700 p-1">{value}</td>
</tr>
);
})}
</tbody>
</HTMLTable>
</div>
</div>
</div>
</Draggable>
Expand Down Expand Up @@ -443,6 +471,8 @@ const Kanban = ({
$reprioritize={reprioritizeAndUpdateBlock}
$getColumnElement={getColumnElement}
$displayKey={displayKey}
$columnKey={columnKey}
$selectionValues={resultKeys.map((rk) => rk.key)}
/>
))}
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ svg.rs-svg-container {
.roamjs-export-dialog-body .bp3-tab-list {
padding: 10px 20px;
border-bottom: 1px solid rgba(16,22,26,0.15);
}`);
}

.roamjs-kanban-card .card-selections tr:first-child td {
box-shadow: none;
}
.roamjs-query-results-view .roamjs-kanban-card .card-selections table.bp3-html-table td {
padding: 0.50rem;
}
`);
const isCanvasPage = (title: string) => {
const canvasPageFormat =
(extensionAPI.settings.get("canvas-page-format") as string) ||
Expand Down