import CottonValues import SwiftUI /// A search or kept list opens a record linked from each result, retaining /// its result id as the conversation anchor when the target draws this table. struct TableLinkedListRoute: View { let table: String let link: String var filter: [String: RecordValue] = [:] @Environment(\.tableDefinitions) private var definitions var body: some View { if let definition = definitions[table] { // The list the linked table declares for these records, so a route to // it reads as that list does ("Kept messages", its own empty words). let declared = definition.column(link)?.linkTo.flatMap { definitions[$0] }?.related? .first { $0.table == table && $0.column == nil && ($0.filter ?? [:]) == filter && $0.open == link } RelatedRecordList( definition: definition, relation: declared ?? RelatedRecords( label: definition.plural, table: table, column: nil, filter: filter, new: nil, open: link), record: TableRecord(id: "", values: [:])) } } }