summaryrefslogtreecommitdiff
path: root/web/templates/partials/tasks-tab.html
blob: 520bf0d61d81e972fb4b274977a43c3f0db0a0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{{define "tasks-tab"}}
<div class="space-y-6 text-shadow-sm"
     hx-get="/tabs/tasks"
     hx-trigger="refresh-tasks from:body"
     hx-target="#tab-content"
     hx-swap="innerHTML">

    <!-- Quick Add Form (Todoist) -->
    {{if .Projects}}
    <details class="mb-6">
        <summary class="cursor-pointer text-sm text-white/70 hover:text-white font-medium transition-colors mb-2">
            + Quick Add Todoist Task
        </summary>
        <form hx-post="/tasks"
              hx-target="#tab-content"
              hx-swap="innerHTML"
              class="mt-3 space-y-3 bg-black/30 p-4 rounded-lg border border-white/10 max-w-md">

            <input type="text"
                   name="content"
                   placeholder="Task content"
                   required
                   class="w-full px-3 py-2 bg-black/40 border border-white/20 rounded-lg text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-white/30 focus:border-transparent">

            <select name="project_id"
                    class="w-full px-3 py-2 bg-black/40 border border-white/20 rounded-lg text-sm text-white focus:ring-2 focus:ring-white/30 focus:border-transparent">
                <option value="">Select project (optional)...</option>
                {{range .Projects}}
                <option value="{{.ID}}">{{.Name}}</option>
                {{end}}
            </select>

            <button type="submit"
                    class="w-full bg-white/10 hover:bg-white/20 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors border border-white/10">
                Add Task
            </button>
        </form>
    </details>
    {{end}}

    <!-- Tasks List -->
    {{if .Atoms}}
    <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
        {{range .Atoms}}
        <div class="bg-card bg-card-hover transition-colors rounded-lg border border-white/5 {{if .IsFuture}}opacity-60{{end}}">
            <div class="flex items-start gap-2 sm:gap-3 p-3 sm:p-4">
                <!-- Checkbox for completing -->
                <input type="checkbox"
                       hx-post="/complete-atom"
                       hx-vals='{"id": "{{.ID}}", "source": "{{.Source}}"}'
                       hx-target="closest div.rounded-lg"
                       hx-swap="outerHTML"
                       class="mt-1 h-5 w-5 rounded bg-black/40 border-white/30 text-white/80 focus:ring-white/30 cursor-pointer flex-shrink-0">
                <span class="text-lg flex-shrink-0">{{.SourceIcon}}</span>
                <div class="flex-1 min-w-0">
                    <div class="flex items-start justify-between gap-2">
                        <h3 class="text-sm {{if .IsOverdue}}text-amber-300 font-medium{{else if .IsFuture}}text-white/50 font-normal{{else}}text-white font-medium{{end}} break-words cursor-pointer hover:underline"
                            hx-get="/tasks/detail?id={{.ID}}&source={{.Source}}"
                            hx-target="#task-edit-content"
                            hx-swap="innerHTML"
                            onclick="document.getElementById('task-edit-modal').classList.remove('hidden')">{{.Title}}</h3>
                        {{if .URL}}
                        <a href="{{.URL}}" target="_blank" class="text-white/70 hover:text-white flex-shrink-0" onclick="event.stopPropagation()">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
                            </svg>
                        </a>
                        {{end}}
                    </div>
                    <div class="flex flex-wrap items-center gap-2 mt-1 text-xs text-white/50">
                        {{if .DueDate}}
                        <span class="{{if .IsOverdue}}text-amber-300/80{{end}}">{{.DueDate.Format "Jan 2"}}{{if .HasSetTime}}, {{.DueDate.Format "3:04pm"}}{{end}}</span>
                        {{end}}
                        {{if gt .Priority 2}}
                        <span class="text-amber-300/80">P{{.Priority}}</span>
                        {{end}}
                        {{if .Description}}
                        <span class="text-white/40">+details</span>
                        {{end}}
                    </div>
                </div>
            </div>
            {{if .Description}}
            <details class="border-t border-white/10">
                <summary class="px-3 sm:px-4 py-2 text-xs text-white/50 cursor-pointer hover:bg-white/5">Tap to expand</summary>
                <div class="px-3 sm:px-4 pb-3 text-sm text-white/70">{{.Description}}</div>
            </details>
            {{end}}
        </div>
        {{end}}
    </div>
    {{else}}
    <div class="card p-6 text-center">
        <p class="text-white/50 text-sm">No current tasks.</p>
    </div>
    {{end}}

    <!-- Future Tasks (Collapsed by default) -->
    {{if .FutureAtoms}}
    <details class="mt-4">
        <summary class="bg-black/40 backdrop-blur-sm rounded-lg p-3 cursor-pointer hover:bg-black/50 transition-colors text-sm text-white/60 flex items-center justify-between">
            <span>+{{len .FutureAtoms}} later</span>
            <svg class="w-4 h-4 transform transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
        </summary>
        <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 mt-2">
            {{range .FutureAtoms}}
            <div class="bg-card bg-card-hover transition-colors rounded-lg border border-white/5 opacity-60">
                <div class="flex items-start gap-2 sm:gap-3 p-3 sm:p-4">
                    <input type="checkbox"
                           hx-post="/complete-atom"
                           hx-vals='{"id": "{{.ID}}", "source": "{{.Source}}"}'
                           hx-target="closest div.bg-white\\/5"
                           hx-swap="outerHTML"
                           class="mt-1 h-5 w-5 rounded bg-black/40 border-white/30 text-white/80 focus:ring-white/30 cursor-pointer flex-shrink-0">
                    <span class="text-lg flex-shrink-0">{{.SourceIcon}}</span>
                    <div class="flex-1 min-w-0">
                        <div class="flex items-start justify-between gap-2">
                            <h3 class="text-sm text-white/50 font-normal break-words">{{.Title}}</h3>
                            {{if .URL}}
                            <a href="{{.URL}}" target="_blank" class="text-white/50 hover:text-white/70 flex-shrink-0">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
                                </svg>
                            </a>
                            {{end}}
                        </div>
                        <div class="flex flex-wrap items-center gap-2 mt-1 text-xs text-white/40">
                            {{if .DueDate}}
                            <span>{{.DueDate.Format "Jan 2"}}{{if .HasSetTime}}, {{.DueDate.Format "3:04pm"}}{{end}}</span>
                            {{end}}
                        </div>
                    </div>
                </div>
            </div>
            {{end}}
        </div>
    </details>
    {{end}}
</div>
{{end}}