Die Sichtbarkeit wird an der Akte gewaehlt, auf der Kachel markiert und in der Liste gefiltert. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b03f571cd8
commit
0108a296bc
7 files changed
+62
-47
No files matched your search
@@ -15,6 +15,7 @@ from app.access.policy import (
|
|||||||
case_rights,
|
case_rights,
|
||||||
deadline_rights,
|
deadline_rights,
|
||||||
element_rights,
|
element_rights,
|
||||||
|
ensure_member_or_personal,
|
||||||
get_case,
|
get_case,
|
||||||
get_deadline,
|
get_deadline,
|
||||||
get_element,
|
get_element,
|
||||||
@@ -22,6 +23,7 @@ from app.access.policy import (
|
|||||||
get_task,
|
get_task,
|
||||||
list_cases,
|
list_cases,
|
||||||
list_matters,
|
list_matters,
|
||||||
|
room_name,
|
||||||
matter_rights,
|
matter_rights,
|
||||||
parse_context,
|
parse_context,
|
||||||
parse_query_context,
|
parse_query_context,
|
||||||
@@ -119,6 +121,15 @@ router = APIRouter()
|
|||||||
_login_attempts: dict[str, list[datetime]] = {}
|
_login_attempts: dict[str, list[datetime]] = {}
|
||||||
|
|
||||||
|
|
||||||
|
def _chosen_home(conn, principal: Principal, requested: UUID | None) -> UUID:
|
||||||
|
scope_id = requested or principal.scope_id
|
||||||
|
room = conn.execute("SELECT id, kind FROM data_rooms WHERE id = %s", (scope_id,)).fetchone()
|
||||||
|
if room is None:
|
||||||
|
raise not_found()
|
||||||
|
ensure_member_or_personal(conn, principal.account_id, room["kind"], room["id"])
|
||||||
|
return room["id"]
|
||||||
|
|
||||||
|
|
||||||
def _created(path: str, payload: dict) -> JSONResponse:
|
def _created(path: str, payload: dict) -> JSONResponse:
|
||||||
return JSONResponse(status_code=201, content=payload, headers={"Location": path})
|
return JSONResponse(status_code=201, content=payload, headers={"Location": path})
|
||||||
|
|
||||||
@@ -412,13 +423,24 @@ def find_principal(email: str, principal: Principal = Depends(get_principal), co
|
|||||||
|
|
||||||
@router.get("/api/v1/cases")
|
@router.get("/api/v1/cases")
|
||||||
def cases(principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
def cases(principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||||
items = [case_summary(case, rights) for case, rights in list_cases(conn, principal.account_id)]
|
items = []
|
||||||
|
for case, rights in list_cases(conn, principal.account_id):
|
||||||
|
summary = case_summary(case, rights)
|
||||||
|
summary["home_scope_name"] = room_name(conn, case["home_scope_id"])
|
||||||
|
items.append(summary)
|
||||||
return {"items": items, "next_cursor": None}
|
return {"items": items, "next_cursor": None}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/api/v1/cases")
|
@router.post("/api/v1/cases")
|
||||||
def post_case(body: CaseIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
def post_case(body: CaseIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||||
case = create_case(conn, principal.account_id, principal.scope_id, body.title, body.parent_case_id, body.rights_mode)
|
case = create_case(
|
||||||
|
conn,
|
||||||
|
principal.account_id,
|
||||||
|
_chosen_home(conn, principal, body.home_scope_id),
|
||||||
|
body.title,
|
||||||
|
body.parent_case_id,
|
||||||
|
body.rights_mode,
|
||||||
|
)
|
||||||
rights = case_rights(conn, principal.account_id, case)
|
rights = case_rights(conn, principal.account_id, case)
|
||||||
return _created(f"/api/v1/cases/{case['id']}", case_summary(case, rights))
|
return _created(f"/api/v1/cases/{case['id']}", case_summary(case, rights))
|
||||||
|
|
||||||
@@ -477,7 +499,12 @@ def matters(principal: Principal = Depends(get_principal), conn: Connection = De
|
|||||||
@router.post("/api/v1/matters")
|
@router.post("/api/v1/matters")
|
||||||
def post_matter(body: MatterIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
def post_matter(body: MatterIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||||
matter = create_matter(
|
matter = create_matter(
|
||||||
conn, principal.account_id, principal.scope_id, body.title, body.parent_matter_id, _ctx_model(body.context)
|
conn,
|
||||||
|
principal.account_id,
|
||||||
|
_chosen_home(conn, principal, body.home_scope_id),
|
||||||
|
body.title,
|
||||||
|
body.parent_matter_id,
|
||||||
|
_ctx_model(body.context),
|
||||||
)
|
)
|
||||||
return _created(f"/api/v1/matters/{matter['id']}", matter_summary(conn, principal.account_id, matter))
|
return _created(f"/api/v1/matters/{matter['id']}", matter_summary(conn, principal.account_id, matter))
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class CaseIn(APIModel):
|
|||||||
title: str = Field(min_length=1, max_length=200)
|
title: str = Field(min_length=1, max_length=200)
|
||||||
parent_case_id: UUID | None = None
|
parent_case_id: UUID | None = None
|
||||||
rights_mode: Literal["inherit_parent", "explicit"] = "inherit_parent"
|
rights_mode: Literal["inherit_parent", "explicit"] = "inherit_parent"
|
||||||
|
home_scope_id: UUID | None = None
|
||||||
|
|
||||||
|
|
||||||
class CasePatch(APIModel):
|
class CasePatch(APIModel):
|
||||||
@@ -71,6 +72,7 @@ class MatterIn(APIModel):
|
|||||||
title: str = Field(min_length=1, max_length=200)
|
title: str = Field(min_length=1, max_length=200)
|
||||||
parent_matter_id: UUID | None = None
|
parent_matter_id: UUID | None = None
|
||||||
context: ContextIn | None = None
|
context: ContextIn | None = None
|
||||||
|
home_scope_id: UUID | None = None
|
||||||
|
|
||||||
|
|
||||||
class MatterPatch(APIModel):
|
class MatterPatch(APIModel):
|
||||||
|
|||||||
@@ -268,6 +268,7 @@ def matter_summary(conn, actor: UUID, matter: dict) -> dict:
|
|||||||
"version": matter["version"],
|
"version": matter["version"],
|
||||||
"parent_matter_id": str(matter["parent_matter_id"]) if matter["parent_matter_id"] else None,
|
"parent_matter_id": str(matter["parent_matter_id"]) if matter["parent_matter_id"] else None,
|
||||||
"home_scope_id": str(matter["home_scope_id"]),
|
"home_scope_id": str(matter["home_scope_id"]),
|
||||||
|
"home_scope_name": room_name(conn, matter["home_scope_id"]),
|
||||||
"contexts": matter_contexts(conn, actor, matter),
|
"contexts": matter_contexts(conn, actor, matter),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export function CaseList() {
|
|||||||
const { session } = useContext(SessionContext);
|
const { session } = useContext(SessionContext);
|
||||||
const [items, setItems] = useState([]);
|
const [items, setItems] = useState([]);
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
|
const [roomId, setRoomId] = useState(session.rooms[0]?.id || "");
|
||||||
|
const [roomFilter, setRoomFilter] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [creating, setCreating] = useState(false);
|
const [creating, setCreating] = useState(false);
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ export function CaseList() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
await api("/api/v1/cases", { method: "POST", body: { title } });
|
await api("/api/v1/cases", { method: "POST", body: { title, home_scope_id: roomId } });
|
||||||
setTitle("");
|
setTitle("");
|
||||||
markDirty(false);
|
markDirty(false);
|
||||||
setCreating(false);
|
setCreating(false);
|
||||||
@@ -41,16 +43,24 @@ export function CaseList() {
|
|||||||
<header className="page-head">
|
<header className="page-head">
|
||||||
<div>
|
<div>
|
||||||
<h1>Akten</h1>
|
<h1>Akten</h1>
|
||||||
<p className="muted">Eine Akte sammelt die Vorgänge. Neu angelegt wird sie in „{session.scope.name}“.</p>
|
<p className="muted">Eine Akte sammelt die Vorgänge. Der Datenraum an der Akte bestimmt, wer sie sieht.</p>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" onClick={() => setCreating(true)}>Akte anlegen</button>
|
<button type="button" onClick={() => setCreating(true)}>Akte anlegen</button>
|
||||||
</header>
|
</header>
|
||||||
<ErrorNote error={error} />
|
<ErrorNote error={error} />
|
||||||
{items.length ? (
|
<div className="filters">
|
||||||
|
<button type="button" className={roomFilter ? "quiet" : ""} onClick={() => setRoomFilter("")}>Alle</button>
|
||||||
|
{session.rooms.map((room) => (
|
||||||
|
<button key={room.id} type="button" className={roomFilter === room.id ? "" : "quiet"} onClick={() => setRoomFilter(room.id)}>
|
||||||
|
{room.name}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{items.filter((item) => !roomFilter || item.home_scope_id === roomFilter).length ? (
|
||||||
<div className="tiles">
|
<div className="tiles">
|
||||||
{items.map((item) => (
|
{items.filter((item) => !roomFilter || item.home_scope_id === roomFilter).map((item) => (
|
||||||
<Link key={item.id} className="tile" to={`/cases/${item.id}`}>
|
<Link key={item.id} className="tile" to={`/cases/${item.id}`}>
|
||||||
<span className="tile__kind">Akte</span>
|
<span className="tile__kind">{item.home_scope_name || "Akte"}</span>
|
||||||
<strong>{item.title}</strong>
|
<strong>{item.title}</strong>
|
||||||
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
|
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -73,6 +83,14 @@ export function CaseList() {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
Datenraum
|
||||||
|
<select value={roomId} onChange={(event) => setRoomId(event.target.value)}>
|
||||||
|
{session.rooms.map((room) => (
|
||||||
|
<option key={room.id} value={room.id}>{room.name}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
<button type="submit">Akte anlegen</button>
|
<button type="submit">Akte anlegen</button>
|
||||||
</form>
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -174,7 +192,7 @@ export function CaseDetail() {
|
|||||||
<Chronology items={events} />
|
<Chronology items={events} />
|
||||||
</section>
|
</section>
|
||||||
<Modal open={modal === "matter"} title="Vorgang anlegen" onClose={() => setModal("")}>
|
<Modal open={modal === "matter"} title="Vorgang anlegen" onClose={() => setModal("")}>
|
||||||
<NewMatter caseId={id} onChange={() => { setModal(""); load(); }} />
|
<NewMatter caseId={id} homeScopeId={record.home_scope_id} onChange={() => { setModal(""); load(); }} />
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal open={modal === "add"} title="Hinzufügen" onClose={() => setModal("")}>
|
<Modal open={modal === "add"} title="Hinzufügen" onClose={() => setModal("")}>
|
||||||
<div className="choice">
|
<div className="choice">
|
||||||
@@ -222,7 +240,7 @@ function sourceKind(element) {
|
|||||||
return "Referenz";
|
return "Referenz";
|
||||||
}
|
}
|
||||||
|
|
||||||
function NewMatter({ caseId, onChange }) {
|
function NewMatter({ caseId, homeScopeId, onChange }) {
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
||||||
@@ -230,7 +248,7 @@ function NewMatter({ caseId, onChange }) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
const matter = await api("/api/v1/matters", { method: "POST", body: { title } });
|
const matter = await api("/api/v1/matters", { method: "POST", body: { title, ...(homeScopeId ? { home_scope_id: homeScopeId } : {}) } });
|
||||||
await api(`/api/v1/matters/${matter.id}/case-links`, { method: "POST", body: { case_id: caseId } });
|
await api(`/api/v1/matters/${matter.id}/case-links`, { method: "POST", body: { case_id: caseId } });
|
||||||
setTitle("");
|
setTitle("");
|
||||||
markDirty(false);
|
markDirty(false);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export function MatterList() {
|
|||||||
const suffix = params.toString() ? `?${params}` : "";
|
const suffix = params.toString() ? `?${params}` : "";
|
||||||
return (
|
return (
|
||||||
<Link key={item.id} className="tile" to={`/matters/${item.id}${suffix}`}>
|
<Link key={item.id} className="tile" to={`/matters/${item.id}${suffix}`}>
|
||||||
<span className="tile__kind">Vorgang</span>
|
<span className="tile__kind">{item.home_scope_name || "Vorgang"}</span>
|
||||||
<strong>{item.title}</strong>
|
<strong>{item.title}</strong>
|
||||||
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
|
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -11,21 +11,9 @@ const NAV = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export function Shell() {
|
export function Shell() {
|
||||||
const { session, changeScope, logout } = useContext(SessionContext);
|
const { session, logout } = useContext(SessionContext);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [error, setError] = useState("");
|
|
||||||
|
|
||||||
async function onScope(event) {
|
|
||||||
const room = session.rooms.find((item) => item.id === event.target.value);
|
|
||||||
if (!room || room.id === session.scope.id) return;
|
|
||||||
setError("");
|
|
||||||
try {
|
|
||||||
await changeScope(room);
|
|
||||||
} catch (err) {
|
|
||||||
setError(err.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSearch(event) {
|
function onSearch(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -34,16 +22,6 @@ export function Shell() {
|
|||||||
navigate(`/search?q=${encodeURIComponent(term)}`);
|
navigate(`/search?q=${encodeURIComponent(term)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scopeSelect() {
|
|
||||||
return (
|
|
||||||
<select value={session.scope.id} onChange={onScope} aria-label="Datenraum">
|
|
||||||
{session.rooms.map((room) => (
|
|
||||||
<option key={room.id} value={room.id}>{room.name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<aside className="desktop-sidebar" aria-label="Hauptnavigation">
|
<aside className="desktop-sidebar" aria-label="Hauptnavigation">
|
||||||
@@ -59,16 +37,9 @@ export function Shell() {
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="desktop-sidebar__scope">
|
|
||||||
<label>
|
|
||||||
Datenraum
|
|
||||||
{scopeSelect()}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div className="desktop-sidebar__footer">
|
<div className="desktop-sidebar__footer">
|
||||||
<div className="desktop-sidebar__user-text">
|
<div className="desktop-sidebar__user-text">
|
||||||
<span className="desktop-sidebar__user-name">{session.account.display_name}</span>
|
<span className="desktop-sidebar__user-name">{session.account.display_name}</span>
|
||||||
<span className="desktop-sidebar__user-tier">{session.scope.name}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="button" className="desktop-sidebar__logout" onClick={logout} title="Abmelden">
|
<button type="button" className="desktop-sidebar__logout" onClick={logout} title="Abmelden">
|
||||||
<NavIcon name="logout" />
|
<NavIcon name="logout" />
|
||||||
@@ -82,10 +53,6 @@ export function Shell() {
|
|||||||
<NavLink to="/" className="app-logo">Tsumugu</NavLink>
|
<NavLink to="/" className="app-logo">Tsumugu</NavLink>
|
||||||
<button type="button" className="quiet" onClick={logout}>Abmelden</button>
|
<button type="button" className="quiet" onClick={logout}>Abmelden</button>
|
||||||
</div>
|
</div>
|
||||||
<label className="scope mobile-only">
|
|
||||||
Datenraum
|
|
||||||
{scopeSelect()}
|
|
||||||
</label>
|
|
||||||
<form className="search" onSubmit={onSearch}>
|
<form className="search" onSubmit={onSearch}>
|
||||||
<input
|
<input
|
||||||
value={query}
|
value={query}
|
||||||
@@ -96,7 +63,6 @@ export function Shell() {
|
|||||||
<button type="submit">Suchen</button>
|
<button type="submit">Suchen</button>
|
||||||
</form>
|
</form>
|
||||||
</header>
|
</header>
|
||||||
{error ? <p className="error banner">{error}</p> : null}
|
|
||||||
<div className="app-main">
|
<div className="app-main">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
|||||||
.tile strong { font-size: 16px; font-weight: 700; line-height: 1.3; }
|
.tile strong { font-size: 16px; font-weight: 700; line-height: 1.3; }
|
||||||
.tile span, .tile__kind { font-size: 12px; color: var(--text3); font-weight: 600; }
|
.tile span, .tile__kind { font-size: 12px; color: var(--text3); font-weight: 600; }
|
||||||
.tile__kind { text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
|
.tile__kind { text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
|
||||||
|
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||||
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||||
.choice button { min-height: 72px; }
|
.choice button { min-height: 72px; }
|
||||||
.modal-overlay {
|
.modal-overlay {
|
||||||
|
|||||||
Reference in new issue
Block a user