concrete/contract/list-source
A list's source is a list, a table, a list slot or a compute, and its item can take the source's element.
A list's source is a list, a table, a list slot or a compute, and its item can take the source's element.
Graded by the contracts stage of concrete check, in the contract venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
A list is a table whose source is another list: a fact table such as
fact.property.units, a list slot of this section or another, a list-valued member
read through a row (a unit's floor plans), or a compute(). A fill is a source too,
declared as the list's fill rather than as source. A source that names one value
has no elements to make items from. The property's media lists
(fact.property.uploads, fact.property.property_media, fact.property.floor_plans,
fact.property.property_documents) are read, never a source: a list of the property's media picks out of the one its item
names as its from.
The item is a function of each element, so it must be able to take one. A table's element is a row, whose members are read only through a row (or an object that declares one); a media list's element is an asset of its kind.
A list sourced by a table is that table in the content, so adding, removing or reordering an item edits the table: where a list's membership is written follows from its source, as a value slot's edit does (where an edit goes).
Check-caught.
Fix
Source the list from a list, and give a table-sourced list an item that declares a row from the element.
Before and after
import { fact, list, text } from "@homepages/concrete";
list({
label: "Units",
source: fact.property.units,
item: () => text.short({ label: "Unit" }),
});import { fact, list, object, row, text } from "@homepages/concrete";
list({
label: "Units",
source: fact.property.units,
item: (el) => {
const unit = row({ label: "Unit", from: fact.property.units, source: el });
return object({
fields: { unit, name: text.short({ label: "Unit name", source: unit.label }) },
});
},
});concrete/contract/object
An object groups value slots, rows, lists of value slots and lists of objects one level deep, holds no value of its own, is labelled by its label field, and names no field like its binding's own keys.
concrete/contract/row-source
A row names its table in `from`; its source is a row slot it mirrors, a compute, the element inside an item, or a pick, and is never a table or a list.
