// Keys a status table's slips need — a run of the assistant, a call an // assistant made — drawn once for any table that names them: // // * column `red_when`: a record holding one of those values writes its // slip's foot in red (a failed run, a refused call); // * column `placeholder`: what a blank column reads as in a slip's foot // ("An unnamed connection"). // // The rest a status table reads is drawn once elsewhere: `opens` (a run opens // the note it wrote) is `RecordOpens`/`opening` in `PictureKeys.swift`; a // subtitle of several columns is `slipSubtitle`; `answers` ("Cancel") is // `AnswerKeys.swift`; `by_day` (the calls by day) is `daySections` in // `ListKeys.swift` — newest day first, a record with no day last, never // dropped. // // The spellings are the shared ones (~/m5b17-shared-keys.md; Rust's // `crates/cotton-core/src/definitions`). Pure, so the rules are settled by // tests; `SlipFace` and `RecordsSection` only draw them. import CottonKit import CottonValues import Foundation extension TableDefinition { /// Whether the record's slip writes its foot in red: one of its columns /// holds a value that column's `red_when` names. public func isRed(_ record: TableRecord) -> Bool { columns.contains { column in guard let red = column.redWhen, let value = record[column.key].text else { return false } return red.contains(value) } } }