Make order search, device results and decisions visible in the WebUI
This commit is contained in:
@@ -39,11 +39,23 @@ export function Requester({ id, ownId }: { id: unknown; ownId?: string }) {
|
||||
export function Status({ value }: { value: unknown }) { return <span className={'order-status state-' + String(value)}>{statusText(value)}</span>; }
|
||||
export function Fact({ label, children }: { label: string; children: ReactNode }) { return <div><dt>{label}</dt><dd>{children}</dd></div>; }
|
||||
|
||||
export function OrderRows({ items, customerName, decisionList, open }: {
|
||||
items: RecordValue[]; customerName?: string; decisionList?: boolean; open: (row: RecordValue) => void
|
||||
export function ApprovalDecision({ order, ownId }: { order: RecordValue; ownId?: string }) {
|
||||
const decision = order.decision && typeof order.decision === 'object' ? record(order.decision) : null;
|
||||
if (typeof decision?.principal !== 'string' || typeof decision.at !== 'string') {
|
||||
return <span className="muted">{order.approval_state === 'expired' ? 'Automatisch abgelaufen' : 'Entscheidung nicht belegt'}</span>;
|
||||
}
|
||||
return <><Requester id={decision.principal} ownId={ownId}/>
|
||||
{decision.testsimulation === true && <small>Simulierter Testentscheid</small>}
|
||||
<small><time dateTime={decision.at}>{when(decision.at)}</time></small></>;
|
||||
}
|
||||
|
||||
export function OrderRows({ items, customerName, decisionList, decisionHistory, ownId, open }: {
|
||||
items: RecordValue[]; customerName?: string; decisionList?: boolean; decisionHistory?: boolean;
|
||||
ownId?: string; open: (row: RecordValue) => void
|
||||
}) {
|
||||
return <div className="table fleet-table order-list"><table><thead><tr>
|
||||
<th>Auftrag</th><th>Kunde</th><th>Geräte</th><th>{decisionList ? 'Eingereicht von' : 'Erstellt'}</th><th>Status</th>
|
||||
{decisionHistory && <th scope="col">Entschieden von und am</th>}
|
||||
</tr></thead><tbody>{items.map(row => {
|
||||
const all = targets(row);
|
||||
const devices = all.slice(0, 2).map(deviceName).join(', ');
|
||||
@@ -53,8 +65,9 @@ export function OrderRows({ items, customerName, decisionList, open }: {
|
||||
{revision && <small>Version {String(revision.version)}</small>}</td>
|
||||
<td data-label="Kunde">{display(row.customer_name, customerName)}</td>
|
||||
<td data-label="Geräte">{devices || (typeof row.planned_job_count === 'number' ? String(row.planned_job_count) : 'Unbekannt')}{all.length > 2 && ' und '+(all.length-2)+' weitere'}</td>
|
||||
<td data-label={decisionList ? 'Eingereicht von' : 'Erstellt'}>{decisionList ? <Requester id={row.requester}/> : when(row.created_at)}</td>
|
||||
<td data-label={decisionList ? 'Eingereicht von' : 'Erstellt'}>{decisionList ? <Requester id={row.requester} ownId={ownId}/> : when(row.created_at)}</td>
|
||||
<td data-label="Status"><Status value={decisionList ? row.approval_state : statusOf(row)}/></td>
|
||||
{decisionHistory && <td data-label="Entschieden von und am"><ApprovalDecision order={row} ownId={ownId}/></td>}
|
||||
</tr>;
|
||||
})}</tbody></table></div>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user