@axium/tasks 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/TaskList.svelte +36 -21
  2. package/package.json +1 -1
@@ -6,11 +6,22 @@
6
6
  import { fetchAPI } from '@axium/client/requests';
7
7
  import type { Task, TaskList } from '@axium/tasks/common';
8
8
  import type { WithRequired } from 'utilium';
9
+ import { download } from 'utilium/dom.js';
9
10
 
10
11
  let { list = $bindable(), lists = $bindable() }: { list: WithRequired<TaskList, 'tasks'>; lists?: WithRequired<TaskList, 'tasks'>[] } =
11
12
  $props();
12
13
 
13
14
  let tasks = $state(list.tasks);
15
+
16
+ function exportTask(task: Task): string {
17
+ const children = tasks
18
+ .filter(t => t.parentId === task.id)
19
+ .map(exportTask)
20
+ .map(str => '\t' + str)
21
+ .join('\n');
22
+
23
+ return `[${task.completed ? 'x' : ' '}] ${task.summary}` + children;
24
+ }
14
25
  </script>
15
26
 
16
27
  {#snippet task_tree(root: Task)}
@@ -42,18 +53,16 @@
42
53
  <Popover>
43
54
  <div
44
55
  class="menu-item"
45
- onclick={e => {
46
- e.stopPropagation();
56
+ onclick={() =>
47
57
  fetchAPI('DELETE', 'tasks/:id', {}, root.id).then(() => {
48
58
  tasks.splice(tasks.indexOf(root), 1);
49
- });
50
- }}
59
+ })}
51
60
  >
52
61
  <Icon i="trash" /> Delete
53
62
  </div>
54
63
  {#if page.data.session?.user.preferences.debug}
55
64
  <div class="menu-item" onclick={() => copy('text/plain', root.id)}>
56
- <Icon i="copy" --size="14px" /> Copy ID
65
+ <Icon i="hashtag" --size="14px" /> Copy ID
57
66
  </div>
58
67
  {/if}
59
68
  </Popover>
@@ -77,30 +86,38 @@
77
86
  <Popover>
78
87
  <div
79
88
  class="menu-item"
80
- onclick={e => {
81
- e.stopPropagation();
89
+ onclick={() =>
82
90
  fetchAPI('DELETE', 'task_lists/:id', {}, list.id).then(() => {
83
91
  if (!lists) goto('/tasks');
84
92
  else lists.splice(lists.indexOf(list), 1);
85
- });
86
- }}
93
+ })}
87
94
  >
88
95
  <Icon i="trash" /> Delete
89
96
  </div>
97
+ <div
98
+ class="menu-item"
99
+ onclick={() =>
100
+ download(
101
+ list.name + '.txt',
102
+ list.tasks
103
+ .filter(task => !task.parentId)
104
+ .map(exportTask)
105
+ .join('\n')
106
+ )}
107
+ >
108
+ <Icon i="regular/file-export" /> Export
109
+ </div>
110
+ <div class="menu-item" onclick={() => copy('text/plain', `${location.origin}/tasks/${list.id}`)}>
111
+ <Icon i="link-horizontal" /> Copy Link
112
+ </div>
90
113
  {#if lists}
91
- <div
92
- class="menu-item"
93
- onclick={e => {
94
- e.currentTarget.parentElement?.togglePopover();
95
- open(`/tasks/${list.id}`);
96
- }}
97
- >
114
+ <div class="menu-item" onclick={() => open(`/tasks/${list.id}`)}>
98
115
  <Icon i="arrow-up-right-from-square" /> Open in New Tab
99
116
  </div>
100
117
  {/if}
101
118
  {#if page.data.session?.user.preferences.debug}
102
119
  <div class="menu-item" onclick={() => copy('text/plain', list.id)}>
103
- <Icon i="copy" --size="14px" /> Copy ID
120
+ <Icon i="hashtag" --size="14px" /> Copy ID
104
121
  </div>
105
122
  {/if}
106
123
  </Popover>
@@ -108,12 +125,10 @@
108
125
  <div>
109
126
  <button
110
127
  class="icon-text"
111
- onclick={e => {
112
- e.stopPropagation();
128
+ onclick={() =>
113
129
  fetchAPI('PUT', 'task_lists/:id', { summary: '' }, list.id)
114
130
  .then(t => t)
115
- .then(tasks.push.bind(tasks));
116
- }}
131
+ .then(tasks.push.bind(tasks))}
117
132
  >
118
133
  <Icon i="regular/circle-plus" /> Add Task
119
134
  </button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/tasks",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "description": "Tasks for Axium",
6
6
  "funding": {