Cotton code
482 lines · 10.3 KB · JSONRaw
{  "format_version": 1,  "id": "goal",  "name": "Goal",  "plural": "Goals",  "builtin": true,  "visibility": "owner",  "date": "target_date",  "title": "title",  "columns": [    {      "key": "title",      "name": "Goal",      "type": "text",      "required": true,      "placeholder": "What are you working towards?"    },    {      "key": "why",      "name": "Why it matters",      "type": "longtext",      "placeholder": "Why does this matter?"    },    {      "key": "target_date",      "name": "By",      "type": "date",      "past_name": "Was"    },    {      "key": "status",      "name": "Status",      "type": "choice",      "choices": [        "active",        "paused",        "achieved",        "dropped"      ],      "labels": {        "active": "Active",        "paused": "Paused",        "achieved": "Achieved",        "dropped": "Dropped"      },      "stamps": {        "achieved": "done",        "dropped": "dropped"      }    },    {      "key": "achieved_at",      "name": "Reached",      "type": "date",      "readonly": true    },    {      "key": "sort_order",      "name": "Order",      "type": "number"    },    {      "key": "trashed_at",      "type": "date",      "format": "calendar-datetime",      "readonly": true    },    {      "key": "project",      "name": "Project",      "type": "link",      "link_to": "project"    }  ],  "instructions": "A goal is something the owner is working towards, with an optional target date and a reason it matters. It is active, paused, achieved or dropped; there is no partial progress, so never estimate a percentage. The owner orders goals by hand, so keep that order.",  "tables": [    {      "name": "cotton_goals",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    title TEXT NOT NULL",          "position": 2        },        {          "name": "why",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    why TEXT",          "position": 3        },        {          "name": "target_date",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    target_date TEXT",          "position": 4        },        {          "name": "status",          "type": "TEXT",          "default": "'active'",          "nullable": false,          "primary_key": false,          "declaration": "\n    status TEXT NOT NULL DEFAULT 'active'",          "position": 5        },        {          "name": "achieved_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    achieved_at TEXT",          "position": 6        },        {          "name": "sort_order",          "type": "REAL",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    sort_order REAL NOT NULL DEFAULT 0",          "position": 7        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 8        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 9        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 10        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 11        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    trashed_at TEXT",          "position": 12        }      ],      "constraints": [        {          "declaration": "\n    CHECK ((status = 'achieved') = (achieved_at IS NOT NULL))",          "position": 13        },        {          "declaration": "\n    CHECK (status IN ('active', 'paused', 'achieved', 'dropped'))",          "position": 14        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 15        }      ],      "prefix": "CREATE TABLE cotton_goals (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_goals_workspace_status ON cotton_goals (workspace_id, status, sort_order)",        "CREATE INDEX IF NOT EXISTS idx_cotton_goals_author ON cotton_goals (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "picture": {    "photo": "photo:87c22d5f2f77f1dde01c6bd272ac151bac3d75afbacdbc8590de699ea71e63dc",    "object": "tool-goals"  },  "engine": "goals",  "project": "project",  "order": "sort_order",  "slip": {    "title": "title",    "subtitle": "why",    "trailing": "target_date",    "photo": null,    "toggle": "status",    "toggle_on": [      "achieved"    ],    "caption": {      "status": "status",      "dates": [        "achieved_at",        "target_date"      ]    }  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title",        "why"      ]    },    {      "heading": "When",      "columns": [        "target_date",        "achieved_at"      ]    },    {      "heading": "Details",      "columns": [        "status",        "project"      ]    },    {      "heading": null,      "columns": [],      "when": {        "column": "status",        "values": [          "active"        ]      },      "actions": [        {          "label": "Pause",          "sets": {            "status": "paused"          },          "object": "snooze",          "does": "times"        },        {          "label": "Set aside",          "sets": {            "status": "dropped"          },          "object": "archive",          "does": "puts-away"        }      ]    },    {      "heading": null,      "columns": [],      "when": {        "column": "status",        "values": [          "paused",          "dropped"        ]      },      "actions": [        {          "label": "Resume",          "sets": {            "status": "active"          },          "object": "retry"        }      ]    }  ],  "record_route": "/goals/goal/[id]",  "group": {    "column": "status",    "sections": [      {        "heading": null,        "values": [          "active",          "paused"        ],        "due": {          "column": "target_date",          "late": "Overdue",          "soon": "This month",          "later": "Later",          "undated": "No date"        }      },      {        "heading": "Behind you",        "values": [          "achieved",          "dropped"        ]      }    ]  },  "empty": {    "title": "No goals yet.",    "message": "Tap + to name something you are working towards."  },  "create": {    "label": "New goal"  },  "deletion": {    "bin": true  },  "links": [    {      "label": "Deleted",      "table": "bin",      "where": {        "table": "goal"      }    }  ],  "commands": [    {      "id": "achieved",      "label": "Achieved",      "kind": "update",      "verb": "update_record",      "data": {        "table": "goal",        "patch": {          "status": "achieved"        }      },      "bindings": {        "id": "$id"      },      "when": {        "status": [          "active",          "paused"        ]      },      "receipt": "Reached",      "undo": "reopen",      "does": "completes"    },    {      "id": "reopen",      "label": "Reopen",      "kind": "update",      "verb": "update_record",      "data": {        "table": "goal",        "patch": {          "status": "active"        }      },      "bindings": {        "id": "$id"      },      "when": {        "status": "achieved"      },      "receipt": "Reopened",      "undo": "achieved",      "object": "restore"    },    {      "id": "delete",      "label": "Delete",      "kind": "delete",      "verb": "delete_record",      "data": {        "table": "goal"      },      "confirm": "Undo on the receipt brings it back.",      "bindings": {        "id": "$id"      },      "receipt": "Deleted",      "does": "destroys"    },    {      "id": "open-project",      "label": "Open project",      "kind": "open",      "opens": "project"    }  ],  "tool": {    "views": [      {        "id": "all",        "label": "All",        "visibility": "owner",        "is_default": true,        "read": {          "table": "goal"        }      }    ],    "name": "Goals",    "purpose": "What you are working towards and your progress.",    "key": "goals",    "icon": "target",    "card_stock": "sage",    "route": "/goals"  },  "parts": {    "shape": "desk",    "head": {      "facts": [],      "state": "status"    },    "links": [],    "body": "why",    "lists": [],    "acts": {      "main": "achieved",      "more": [        "reopen",        "open-project"      ],      "away": "delete"    },    "cards": [      {        "column": "target_date",        "label": "by when"      },      {        "column": "achieved_at",        "label": "achieved"      }    ],    "strip": []  }}