feat(plan): show project name instead of raw id in cell
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { GridData, ResolvedCell } from "../lib/queries/plan";
|
import { GridData, ResolvedCell } from "../lib/queries/plan";
|
||||||
|
import type { Project } from "../lib/queries/projects";
|
||||||
import PlanRangeChips from "./PlanRangeChips";
|
import PlanRangeChips from "./PlanRangeChips";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: GridData | undefined;
|
data: GridData | undefined;
|
||||||
canEdit: boolean;
|
canEdit: boolean;
|
||||||
|
projects: Project[];
|
||||||
onCellClick: (
|
onCellClick: (
|
||||||
userId: number,
|
userId: number,
|
||||||
date: string,
|
date: string,
|
||||||
@@ -32,7 +34,12 @@ function isWeekend(dateStr: string): boolean {
|
|||||||
return day === 0 || day === 6;
|
return day === 0 || day === 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PlanGrid({ data, canEdit, onCellClick }: Props) {
|
export default function PlanGrid({
|
||||||
|
data,
|
||||||
|
canEdit,
|
||||||
|
projects,
|
||||||
|
onCellClick,
|
||||||
|
}: Props) {
|
||||||
if (!data)
|
if (!data)
|
||||||
return (
|
return (
|
||||||
<div className="admin-loading">
|
<div className="admin-loading">
|
||||||
@@ -72,7 +79,16 @@ export default function PlanGrid({ data, canEdit, onCellClick }: Props) {
|
|||||||
className={cls}
|
className={cls}
|
||||||
onClick={() => onCellClick(u.id, date, cell)}
|
onClick={() => onCellClick(u.id, date, cell)}
|
||||||
>
|
>
|
||||||
<PlanRangeChips cell={cell} readonly={!canEdit} />
|
<PlanRangeChips
|
||||||
|
cell={cell}
|
||||||
|
project={
|
||||||
|
cell?.project_id
|
||||||
|
? (projects.find((p) => p.id === cell.project_id) ??
|
||||||
|
null)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
readonly={!canEdit}
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { ResolvedCell } from "../lib/queries/plan";
|
import { ResolvedCell } from "../lib/queries/plan";
|
||||||
|
import type { Project } from "../lib/queries/projects";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
cell: ResolvedCell | null;
|
cell: ResolvedCell | null;
|
||||||
|
project: Project | null;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,19 +17,32 @@ const CATEGORY_LABELS: Record<string, string> = {
|
|||||||
other: "Jiné",
|
other: "Jiné",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function PlanRangeChips({ cell, readonly }: Props) {
|
export default function PlanRangeChips({ cell, project, readonly }: Props) {
|
||||||
|
void readonly;
|
||||||
if (!cell) return null;
|
if (!cell) return null;
|
||||||
|
const projectLabel = project
|
||||||
|
? project.project_number
|
||||||
|
? `${project.project_number} — ${project.name}`
|
||||||
|
: project.name
|
||||||
|
: null;
|
||||||
|
const projectTitle = project
|
||||||
|
? project.project_number
|
||||||
|
? `${project.project_number} — ${project.name}`
|
||||||
|
: project.name
|
||||||
|
: undefined;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="plan-chip-block">
|
||||||
<span className={`plan-chip plan-chip--${cell.category}`}>
|
<div className="plan-chip-line">
|
||||||
{CATEGORY_LABELS[cell.category] ?? cell.category}
|
<span className={`plan-chip plan-chip--${cell.category}`}>
|
||||||
</span>
|
{CATEGORY_LABELS[cell.category] ?? cell.category}
|
||||||
{cell.project_id && (
|
|
||||||
<span style={{ marginLeft: 6, fontSize: 12, fontWeight: 600 }}>
|
|
||||||
{`#${cell.project_id}`}
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
{projectLabel && (
|
||||||
{cell.note && <span className="plan-cell-note">{cell.note}</span>}
|
<span className="plan-chip-project" title={projectTitle}>
|
||||||
|
{projectLabel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{cell.note && <div className="plan-cell-note">{cell.note}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,7 +448,12 @@ export default function PlanWork() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<PlanGrid data={grid} canEdit={canEdit} onCellClick={openCell} />
|
<PlanGrid
|
||||||
|
data={grid}
|
||||||
|
projects={projects}
|
||||||
|
canEdit={canEdit}
|
||||||
|
onCellClick={openCell}
|
||||||
|
/>
|
||||||
|
|
||||||
<PlanCellModal
|
<PlanCellModal
|
||||||
key={modalKey}
|
key={modalKey}
|
||||||
|
|||||||
@@ -116,6 +116,31 @@
|
|||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.plan-chip-block {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
text-align: left;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.plan-chip-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.plan-chip-project {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text, #1f2937);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.plan-toolbar {
|
.plan-toolbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
|||||||
Reference in New Issue
Block a user