Cotton code
454 lines · 9.5 KB · JSONRaw
{  "format_version": 1,  "id": "goal",  "name": "Goal",  "plural": "Goals",  "record_route": "/goals/goal/[id]",  "picture": {"photo": "photo:87c22d5f2f77f1dde01c6bd272ac151bac3d75afbacdbc8590de699ea71e63dc", "object": "tool-goals"},  "builtin": true,  "links": [    {      "label": "Deleted",      "table": "bin",      "where": {        "table": "goal"      }    }  ],  "deletion": {    "bin": true  },  "engine": "goals",  "columns": [    {      "key": "title",      "type": "text",      "required": true,      "placeholder": "What are you working towards?",      "name": "Goal"    },    {      "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",  "type": "choice",  "choices": [    "active",    "paused",    "achieved",    "dropped"  ],  "stamps": {    "achieved": "done",    "dropped": "dropped"  },  "name": "Status",  "labels": {    "active": "Active",    "paused": "Paused",    "achieved": "Achieved",    "dropped": "Dropped"  }},    {      "key": "achieved_at",      "name": "Reached",      "type": "date",      "readonly": true    },    {      "key": "sort_order",      "name": "Order",      "type": "number"    },    {      "key": "project",      "name": "Project",      "type": "link",      "link_to": "project"    }  ],  "title": "title",  "date": "target_date",  "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",          "object": "snooze",          "does": "times",          "sets": {            "status": "paused"          }        },        {          "label": "Set aside",          "object": "archive",          "does": "puts-away",          "sets": {            "status": "dropped"          }        }      ]    },    {      "heading": null,      "columns": [],      "when": {        "column": "status",        "values": [          "paused",          "dropped"        ]      },      "actions": [        {          "label": "Resume",          "object": "retry",          "sets": {            "status": "active"          }        }      ]    }  ],  "group": {    "column": "status",    "sections": [      {        "heading": null,        "values": [          "active",          "paused"        ]      },      {        "heading": "Behind you",        "values": [          "achieved",          "dropped"        ]      }    ]  },  "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.",  "create": {    "label": "New goal"  },  "empty": {    "title": "No goals yet.",    "message": "Tap + to name something you are working towards."  },  "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",    "object": "restore",    "kind": "update",    "verb": "update_record",    "data": {      "table": "goal",      "patch": {        "status": "active"      }    },    "bindings": {      "id": "$id"    },    "when": {      "status": "achieved"    },    "receipt": "Reopened",    "undo": "achieved"  },  {    "id": "delete",    "label": "Delete",    "kind": "delete",    "verb": "delete_record",    "data": {      "table": "goal"    },    "bindings": {      "id": "$id"    },    "confirm": "Undo on the receipt brings it back.",    "receipt": "Deleted",    "does": "destroys"  },  {    "id": "open-project",    "label": "Open project",    "kind": "open",    "opens": "project"  }],  "parts": {  "shape": "desk",  "head": {    "facts": [],    "state": "status"  },  "links": [],  "lists": [],  "acts": {    "main": "achieved",    "more": [      "reopen",      "open-project"    ],    "away": "delete"  },  "cards": [    {      "column": "target_date",      "label": "by when"    },    {      "column": "achieved_at",      "label": "achieved"    }  ],  "strip": [],  "body": "why"},  "tool": {    "name": "Goals",    "key": "goals",    "icon": "target",    "card_stock": "sage",    "route": "/goals"  ,"purpose":"What you are working towards and your progress."},  "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": []    }  ]}