summaryrefslogtreecommitdiff
path: root/web/templates/partials/tasks-tab.html
blob: 92e7979dafef8bfcd8ccf9e65a29c634bb71317d (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{{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 - Collapsible -->
    <section class="card">
        <button type="button"
                onclick="document.getElementById('quick-add-form').classList.toggle('hidden')"
                class="w-full p-3 sm:p-4 text-left flex justify-between items-center">
            <span class="font-medium text-white">+ Quick Add</span>
            <svg class="w-4 h-4 text-white/50" 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>
        </button>
        <form id="quick-add-form"
              class="hidden p-3 sm:p-4 pt-0 border-t border-white/10"
              hx-post="/unified-add"
              hx-swap="none"
              hx-on::after-request="if(event.detail.successful) { this.reset(); document.getElementById('trello-fields').style.display = 'none'; }">
            <div class="flex flex-wrap gap-2 items-end">
                <div class="flex-1 min-w-[150px]">
                    <input type="text"
                           name="title"
                           placeholder="Task name..."
                           class="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-white/30 focus:border-white/30"
                           required>
                </div>
                <div>
                    <input type="date"
                           name="due_date"
                           id="quick-add-date"
                           class="bg-black/40 border border-white/20 rounded-lg px-2 py-2 text-sm text-white focus:ring-2 focus:ring-white/30">
                    <script>
                        (function() {
                            var d = new Date();
                            var dateStr = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
                            document.getElementById('quick-add-date').value = dateStr;
                        })();
                    </script>
                </div>
                <div>
                    <select name="source"
                            class="bg-black/40 border border-white/20 rounded-lg px-2 py-2 text-sm text-white focus:ring-2 focus:ring-white/30"
                            onchange="document.getElementById('trello-fields').style.display = this.value === 'trello' ? 'flex' : 'none'">
                        <option value="todoist">Todoist</option>
                        <option value="trello">Trello</option>
                    </select>
                </div>
                <button type="submit"
                        class="bg-white/20 hover:bg-white/30 text-white px-3 py-2 rounded-lg transition-colors font-medium text-sm">
                    Add
                </button>
            </div>

            <!-- Trello Fields (Hidden by default) -->
            <div id="trello-fields" class="flex flex-wrap gap-2 mt-3" style="display: none;">
                <div>
                    <select name="board_id"
                            class="bg-black/40 border border-white/20 rounded-lg px-2 py-2 text-sm text-white"
                            hx-get="/partials/lists"
                            hx-target="#list-select"
                            hx-trigger="change"
                            hx-swap="innerHTML">
                        <option value="">Select Board...</option>
                        {{range .Boards}}
                        <option value="{{.ID}}">{{.Name}}</option>
                        {{end}}
                    </select>
                </div>
                <div>
                    <select id="list-select" name="list_id" class="bg-black/40 border border-white/20 rounded-lg px-2 py-2 text-sm text-white">
                        <option value="">Select List...</option>
                    </select>
                </div>
            </div>
        </form>
    </section>

    <!-- Tasks List -->
    {{if .Atoms}}
    <div class="space-y-2">
        {{range .Atoms}}
        <div class="task-item border-l-4 {{.ColorClass}} {{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 .task-item"
                       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-red-400 font-semibold{{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-red-400 font-medium{{end}}">{{.DueDate.Format "Jan 2"}}{{if .HasSetTime}}, {{.DueDate.Format "3:04pm"}}{{end}}</span>
                        {{end}}
                        {{if gt .Priority 2}}
                        <span class="text-red-400 font-medium">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="space-y-2 mt-2">
            {{range .FutureAtoms}}
            <div class="task-item border-l-4 {{.ColorClass}} 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 .task-item"
                           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}}