feat: task templates (vibe-kanban) (#197)

* I've successfully implemented task templates for vibe-kanban with the following features:

- Created a new `task_templates` table with fields for:
  - `id` (UUID primary key)
  - `project_id` (nullable for global templates)
  - `title` (default task title)
  - `description` (default task description)
  - `template_name` (display name for the template)
  - Timestamps for tracking creation/updates

- Created `TaskTemplate` model with full CRUD operations
- Added REST API endpoints:
  - `GET /api/templates` - List all templates
  - `GET /api/templates/global` - List only global templates
  - `GET /api/projects/:project_id/templates` - List templates for a project (includes global)
  - `GET /api/templates/:id` - Get specific template
  - `POST /api/templates` - Create template
  - `PUT /api/templates/:id` - Update template
  - `DELETE /api/templates/:id` - Delete template

1. **Task Creation Dialog**:
   - Added template selector dropdown when creating new tasks
   - Templates are fetched based on project context
   - Selecting a template pre-fills title and description fields
   - User can edit pre-filled values before creating the task

2. **Global Settings**:
   - Added "Task Templates" section to manage global templates
   - Full CRUD interface with table view
   - Create/Edit dialog for template management

3. **Project Settings**:
   - Modified project form to use tabs when editing
   - Added "Task Templates" tab for project-specific templates
   - Same management interface as global settings

- **Scope Management**: Templates can be global (available to all projects) or project-specific
- **User Experience**: Template selection is optional and doesn't interfere with normal task creation
- **Data Validation**: Unique template names within same scope (global or per-project)
- **UI Polish**: Clean interface with loading states, error handling, and confirmation dialogs

The implementation allows users to create reusable task templates that streamline the task creation process by pre-filling common values while still allowing full editing before submission.

* improve styling

* address review comments

* fix unqiue contraint on tempaltes

* distinguish between local and global templates in UI

* keyboard shortcuts for task creation

* add dropdown on project page to select templates

* update types

* add default global task templates

* Add task templates from kanban (#219)

* Create project templates from kanban

* Fixes

* remove duplicate

---------

Co-authored-by: Louis Knight-Webb <louis@bloop.ai>
This commit is contained in:
Gabriel Gordon-Hall
2025-07-16 15:46:42 +01:00
committed by GitHub
parent 4f694f1fc6
commit 471d28defd
29 changed files with 2042 additions and 251 deletions

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "UPDATE task_templates \n SET title = $2, description = $3, template_name = $4, updated_at = datetime('now', 'subsec')\n WHERE id = $1 \n RETURNING id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 4
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "290ce5c152be8d36e58ff42570f9157beb07ab9e77a03ec6fc30b4f56f9b8f6b"
}

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"\n FROM task_templates \n WHERE id = $1",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "36e4ba7bbd81b402d5a20b6005755eafbb174c8dda442081823406ac32809a94"
}

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "INSERT INTO task_templates (id, project_id, title, description, template_name) \n VALUES ($1, $2, $3, $4, $5) \n RETURNING id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 5
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "3d6bd16fbce59efe30b7f67ea342e0e4ea6d1432389c02468ad79f1f742d4031"
}

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"\n FROM task_templates \n WHERE project_id IS NULL\n ORDER BY template_name ASC",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 0
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "461cc1b0bb6fd909afc9dd2246e8526b3771cfbb0b22ae4b5d17b51af587b9e2"
}

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "DELETE FROM task_templates WHERE id = $1",
"describe": {
"columns": [],
"parameters": {
"Right": 1
},
"nullable": []
},
"hash": "8f01ebd64bdcde6a090479f14810d73ba23020e76fd70854ac57f2da251702c3"
}

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"\n FROM task_templates \n ORDER BY project_id IS NULL DESC, template_name ASC",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 0
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "96036c4f9e0f48bdc5a4a4588f0c5f288ac7aaa5425cac40fc33f337e1a351f2"
}

View File

@@ -0,0 +1,56 @@
{
"db_name": "SQLite",
"query": "SELECT id as \"id!: Uuid\", project_id as \"project_id?: Uuid\", title, description, template_name, created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"\n FROM task_templates \n WHERE project_id = $1 OR project_id IS NULL\n ORDER BY project_id IS NULL, template_name ASC",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "project_id?: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "description",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "template_name",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 6,
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
true,
true,
false,
true,
false,
false,
false
]
},
"hash": "fdb06a7d9050f98d73e743b6522c7443d603931c082bd38f13b8f1f127b88711"
}