Cotton code
273 lines · 5.3 KB · JSONRaw
{  "format_version": 1,  "id": "yoga_session",  "name": "Session",  "plural": "Sessions",  "picture": null,  "builtin": false,  "engine": null,  "visibility": "public",  "columns": [    {      "key": "name",      "name": "Session",      "type": "text",      "required": true,      "placeholder": "Pre-natal"    },    {      "key": "class",      "name": "Class",      "type": "link",      "link_to": "yoga_class",      "required": true,      "contributes": {        "label": "Sessions"      }    },    {      "key": "on",      "name": "On",      "type": "date",      "required": true    },    {      "key": "starts",      "name": "Starts",      "type": "time"    },    {      "key": "trainer",      "name": "Trainer",      "type": "link",      "link_to": "yoga_trainer",      "contributes": {        "label": "Sessions"      }    },    {      "key": "photo",      "name": "Photo",      "type": "photo",      "computed": {        "lookup": {          "through": "class",          "column": "photo"        }      }    },    {      "key": "minutes",      "name": "Minutes",      "type": "number",      "computed": {        "lookup": {          "through": "class",          "column": "minutes"        }      },      "reading": "{value} min"    },    {      "key": "about",      "name": "About the class",      "type": "longtext",      "computed": {        "lookup": {          "through": "class",          "column": "description"        }      }    },    {      "key": "trainer_photo",      "name": "Trainer's photo",      "type": "photo",      "computed": {        "lookup": {          "through": "trainer",          "column": "photo"        }      }    },    {      "key": "capacity",      "name": "Places",      "type": "number",      "computed": {        "lookup": {          "through": "class",          "column": "capacity"        }      },      "reading": "{value} places"    },    {      "key": "booked",      "name": "Booked",      "type": "number",      "computed": {        "rollup": {          "table": "yoga_booking",          "link": "session",          "op": "sum",          "column": "quantity"        }      },      "reading": "{value} booked"    },    {      "key": "present",      "name": "Here",      "type": "number",      "computed": {        "rollup": {          "table": "yoga_booking",          "link": "session",          "op": "sum",          "column": "present"        }      },      "reading": "{value} here"    },    {      "key": "places_left",      "name": "Places left",      "type": "number",      "computed": {        "formula": {          "op": "difference",          "of": [            "capacity",            "booked"          ]        }      },      "reading": "{value} places left"    }  ],  "title": "name",  "date": "on",  "project": null,  "order": null,  "slip": {    "title": "name",    "photo": "photo",    "toggle": null,    "subtitle": [      "starts",      "trainer"    ],    "trailing": "places_left"  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "name",        "class",        "on",        "starts",        "trainer"      ]    },    {      "heading": "Places",      "columns": [        "capacity",        "booked",        "present",        "places_left"      ]    },    {      "heading": "About",      "columns": [        "about"      ]    }  ],  "sort": {    "column": "on",    "descending": false,    "tie": "starts"  },  "empty": {    "title": "No sessions",    "message": "Each class makes a session on the day it runs."  },  "by_day": "on",  "acts": [    {      "id": "book",      "label": "Book",      "object": "plus",      "kind": "create",      "verb": "reserve_record",      "bindings": {        "data.name": "name",        "data.on": "on"      },      "picks": [        {          "argument": "data.member",          "kind": "record",          "table": "yoga_member",          "label": "Member"        },        {          "kind": "number",          "argument": "data.quantity",          "label": "Places",          "min": 1,          "default": 1        }      ]    }  ],  "instructions": "One row per class on the day it runs: the class, its day and start, and the trainer who takes it (a substitute is simply another trainer on that session). Book a member with reserve_record {tool: \"yoga\", slot: <session id>, data: {member, name, on, quantity}}: it refuses when the session is full. Booked and here are counted from the bookings and attendance, never typed; photo, minutes, level and the class words are read from the class.",  "card": {    "face": "event",    "fields": [      {        "slot": "photo",        "column": "photo"      },      {        "slot": "title",        "column": "name"      },      {        "slot": "subtitle",        "column": "minutes"      },      {        "slot": "date",        "column": "on",        "form": "weekday_date",        "also": [          "starts"        ]      },      {        "slot": "place",        "column": "places_left"      },      {        "slot": "people",        "column": "trainer",        "max": 1      },      {        "slot": "body",        "column": "about"      }    ],    "pages": [      "about"    ]  }}