Compare commits
456 commits
renovate/w
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
90ecea74c7 | ||
|
9bde803ef9 | ||
|
82ac8aeb6c | ||
|
b73d285c88 | ||
|
dd252273d7 | ||
|
47cc400417 | ||
|
5826e2ebcc | ||
|
e5b60b7cd3 | ||
|
a47167197d | ||
|
e811695cb0 | ||
|
87ad58b4b7 | ||
|
3e8e5bb554 | ||
|
322724c2a6 | ||
|
37956b5933 | ||
|
be64831035 | ||
|
8458e8f687 | ||
|
c6d6da3171 | ||
|
1af4f7811a | ||
|
35155034e0 | ||
|
feeaca2c02 | ||
|
4784e3a22f | ||
|
ba28617464 | ||
|
766f2b7461 | ||
|
6c1cd9f911 | ||
|
48cb3defc4 | ||
|
59cb0c82f9 | ||
|
6d587fad6e | ||
|
458df80443 | ||
|
96a8308d16 | ||
|
0a29197715 | ||
|
172d353df7 | ||
|
a895bde661 | ||
|
4ebe17f4f3 | ||
|
59b0f12424 | ||
|
44549bb441 | ||
|
c8aa3db205 | ||
|
74a9b9ab1b | ||
|
5b733ffa8a | ||
|
b62ec79939 | ||
|
17b31e0b95 | ||
|
bc1e366750 | ||
|
d4c179c862 | ||
|
d77addd266 | ||
|
5be75f3c54 | ||
|
8e905de41b | ||
|
07d38a4aa3 | ||
|
ab75e3ab50 | ||
|
b806a01e95 | ||
|
820db3e96d | ||
|
f405b2105b | ||
|
3af20b6220 | ||
|
38fc157f24 | ||
|
01f648c20c | ||
|
1be516a905 | ||
|
fd71de4b5d | ||
|
31e39aa6c8 | ||
|
f01107fd73 | ||
|
a7731370a0 | ||
|
84a1abf347 | ||
|
ee3965eae9 | ||
|
fad72e091b | ||
|
eb80bfa00d | ||
|
43258ab74e | ||
|
877e425055 | ||
|
054d70cbe5 | ||
|
3d88fdaadd | ||
|
eae7cc5a6b | ||
|
e2f02cfc61 | ||
|
00e0a23d48 | ||
|
114724faaa | ||
|
c206fc6f34 | ||
|
6f2dedcb48 | ||
|
4655e1ce34 | ||
|
f360ebfe98 | ||
|
812f519de9 | ||
|
104fe7433b | ||
|
db627ed28a | ||
|
cbec1f24aa | ||
|
bb8ed57b7c | ||
|
3248dcd663 | ||
|
06c1a54886 | ||
|
9022954257 | ||
|
12215c043d | ||
|
3e21a8ed6e | ||
|
f1852f1f33 | ||
|
c2321703a7 | ||
|
3060d09287 | ||
|
af7f8400e9 | ||
|
367ad1e5a5 | ||
|
9126d22822 | ||
|
2923504bf4 | ||
|
2cda229b69 | ||
|
44c0d55fba | ||
|
80226df0de | ||
|
ed47aa4119 | ||
|
4c0ce26f2d | ||
|
a5925baff0 | ||
|
b08dd58552 | ||
|
0620b8f0b3 | ||
|
ff1968aa36 | ||
|
63fb8a1962 | ||
|
940063784b | ||
|
78a6d38641 | ||
|
2dc36c032b | ||
|
1d7f857070 | ||
|
7f281fc5e9 | ||
|
df74f9d80c | ||
|
d1d7cd535e | ||
|
e2d5c6e12f | ||
|
0ada383395 | ||
|
68219ee224 | ||
|
2f2fb357c1 | ||
|
5585966584 | ||
|
e999b38d3b | ||
|
f8450f58a4 | ||
|
72b731d620 | ||
|
266f877455 | ||
|
13157e3bba | ||
|
fd3c15d064 | ||
|
5b606936c3 | ||
|
d120e8c82d | ||
|
ec227a6872 | ||
|
5bd7c77b68 | ||
|
d58f8b4ba1 | ||
|
8ce242bb65 | ||
|
5f5ed410df | ||
|
3970d0fd31 | ||
|
cc378b83fe | ||
|
8c394d8024 | ||
|
b84da722ca | ||
|
c35810f28f | ||
|
9f26ae1ee6 | ||
|
34ffd1d572 | ||
|
64cf1c8ccf | ||
|
1fdda07f65 | ||
|
9856fab38f | ||
|
8e3f54ae42 | ||
|
8f25f5d353 | ||
|
94d6f38e89 | ||
|
c421701fb7 | ||
|
176ad565cc | ||
|
7b53e684aa | ||
|
f30c964c06 | ||
|
bbf4ef4697 | ||
|
63f2e6ba6f | ||
|
e9cf562969 | ||
|
878c6ea9e1 | ||
|
ca899d3b51 | ||
|
8b63df6f41 | ||
|
ebfbb5ca9b | ||
|
fd13b453f4 | ||
|
2cd442780d | ||
|
c342756efd | ||
|
cf745726bc | ||
|
c9546d52c0 | ||
|
6a828078a3 | ||
|
bc833091f2 | ||
|
f4a5f59400 | ||
|
7f581cbe27 | ||
|
a199fc7a8e | ||
|
e8f0b56651 | ||
|
ecd0df21c1 | ||
|
069d03932d | ||
|
9f3936544d | ||
|
89e428b4d2 | ||
|
ba2605af1b | ||
|
1eae7ece9c | ||
|
5f6cfa8e09 | ||
|
b1f2229d22 | ||
|
b44c71e6cc | ||
|
4e9c592090 | ||
|
a737fc5bc2 | ||
|
9e8c429864 | ||
|
95ad245b59 | ||
|
62ed7c5964 | ||
|
2bf9771e28 | ||
|
3c9c5eff12 | ||
|
aa64e9835c | ||
|
ede5cdd8cf | ||
|
5ffb13a3a8 | ||
|
20e9420638 | ||
|
c2ba1b2828 | ||
|
2fd9f0ee47 | ||
|
6e5501a5f1 | ||
|
937fd36f72 | ||
|
4dfcd8e70f | ||
|
13bc25ff5d | ||
|
0e072b582b | ||
|
b9335a7362 | ||
|
479fc7e433 | ||
|
02e73fa377 | ||
|
ad694ff8bc | ||
|
093ab766d4 | ||
|
9474240cb9 | ||
|
1c58fccd92 | ||
|
f7ca064127 | ||
|
ef6454483a | ||
|
dfb3561310 | ||
|
62e227c767 | ||
|
6624db1d49 | ||
|
b542221dac | ||
|
d57e27b4a6 | ||
|
0814890cac | ||
|
43e2d036d7 | ||
|
ce0f58c783 | ||
|
943d5f7975 | ||
|
a38075f376 | ||
|
e5d04c98da | ||
|
d76b526916 | ||
|
f85a08afb4 | ||
|
d67e5e386d | ||
|
e91b5fde02 | ||
|
ff5d1fc8c1 | ||
|
ddabd7f63a | ||
|
4c9a018c13 | ||
|
fadaac4ef1 | ||
|
b06e3cac3f | ||
|
1ecb186b7c | ||
|
070ef7e5aa | ||
|
e8613b48fc | ||
|
de7617fbaf | ||
|
0360cd0867 | ||
|
54e9513c14 | ||
|
fc0cf3fc87 | ||
|
0fccb3d5a9 | ||
|
9134269ead | ||
|
ba4913e2cb | ||
|
2eff239f9e | ||
|
fa77b20c13 | ||
|
3b713dede2 | ||
|
ad6b335d41 | ||
|
221edb2086 | ||
|
565765537d | ||
|
f70b1d2902 | ||
|
4fce71f729 | ||
|
84260841be | ||
|
6d9c4a7aa0 | ||
|
b24d5f2dce | ||
|
2683fec0a6 | ||
|
2df2bd38e2 | ||
|
91976e23f9 | ||
|
602ab8379e | ||
|
92f24e59a7 | ||
|
49217889b5 | ||
|
9c367877f4 | ||
|
064001e259 | ||
|
0316656d81 | ||
|
a18c6ab8d8 | ||
|
bdf992c9bf | ||
|
51c806c12b | ||
|
a6e9b36bd6 | ||
|
854068fff9 | ||
|
6576b6148c | ||
|
224cea33ce | ||
|
7e7fa807fd | ||
|
f083f181e2 | ||
|
2b82df5dbd | ||
|
e67fc7fb7e | ||
|
db8b8812af | ||
|
2013924949 | ||
|
1a11b43ca8 | ||
|
61427987c2 | ||
|
7b398f73f6 | ||
|
64726a6421 | ||
|
53858e0c31 | ||
|
2f0f648d28 | ||
|
6e026cc7cc | ||
|
d0fefd3c08 | ||
|
4dd397e3d2 | ||
|
2a41ccb980 | ||
|
38d72b59df | ||
|
add080d214 | ||
|
65f9def438 | ||
|
f1a726550e | ||
|
26d02d5593 | ||
|
5f678e2449 | ||
|
23598dd2ee | ||
|
d91d1fecf1 | ||
|
7a457eb161 | ||
|
d3171b59be | ||
|
63f5f446fd | ||
|
b8d77a617b | ||
|
d822709991 | ||
|
86a04da470 | ||
|
e6fbf1cb50 | ||
|
4fe6186ee6 | ||
|
6bf5f6efd4 | ||
|
03f448457a | ||
|
7f6f8963e7 | ||
|
65fd2f14a0 | ||
|
2e84c27d1e | ||
|
ee79a1d604 | ||
|
d17428d4d0 | ||
|
bca53ec8ae | ||
|
fef1af6ce7 | ||
|
3209206260 | ||
|
d819b9b0ba | ||
|
e95904351f | ||
|
a541afdf9d | ||
|
5d189035f2 | ||
|
dbea1f7a51 | ||
|
54de368642 | ||
|
878b5bf236 | ||
|
b4cba6f7d9 | ||
|
c06b781837 | ||
|
9616badc33 | ||
|
49f3b928cb | ||
|
7d4ba6249e | ||
|
8416b1f448 | ||
|
8be1f81848 | ||
|
d36577c04e | ||
|
2445f0eec8 | ||
|
96f5f00c07 | ||
|
041a1a4cc0 | ||
|
4a50e6aae2 | ||
|
f9b51306c3 | ||
|
106abfc842 | ||
|
3ba423ed23 | ||
|
244478400a | ||
|
a6b96f857d | ||
|
80eaf38090 | ||
|
79e7e4a8ae | ||
|
3766b5e51b | ||
|
c9e85cb52b | ||
|
42e72d14a4 | ||
|
6f93d6343c | ||
|
4a247b2a7d | ||
|
e93f95f8c2 | ||
|
b0ee316a26 | ||
|
332acf012c | ||
|
8fb00653e4 | ||
|
af630d3b8c | ||
|
797de0c543 | ||
|
74ad6e65e8 | ||
|
02ddf90cbb | ||
|
59801d797b | ||
|
d7b7328a0e | ||
|
377201dda9 | ||
|
5b8ebba4c0 | ||
|
9657b6b2d3 | ||
|
6e4a3ff199 | ||
|
3e770e11f1 | ||
|
48af80dcf9 | ||
|
b3300f5552 | ||
|
9bc04a3ffc | ||
|
b77b4105a0 | ||
|
f6437c81da | ||
|
deef7106e6 | ||
|
2521102712 | ||
|
ed02c6c81c | ||
|
5c5f3d88af | ||
|
1409750a30 | ||
|
5923bd8225 | ||
|
a5629bd556 | ||
|
2e2eebf206 | ||
|
e8572fe13b | ||
|
308971ad05 | ||
|
67cee63cf0 | ||
|
5a92228b96 | ||
|
ff655808b3 | ||
|
a8d4892a0f | ||
|
c936b92654 | ||
|
d323ed5b4b | ||
|
91ad503a11 | ||
|
35081befae | ||
|
17607df6ff | ||
|
149696b7de | ||
|
4582e98795 | ||
|
d6f82955a6 | ||
|
270432afe4 | ||
|
4d3b7c8759 | ||
|
c4f3e09cc7 | ||
|
bdd5ea27ac | ||
|
65b694d8e6 | ||
|
78abe20f7d | ||
|
7163dc351b | ||
|
7098b6315f | ||
|
dc70df54ba | ||
|
24dcbaba27 | ||
|
eedbba5657 | ||
|
1223d8b679 | ||
|
c6e7390f13 | ||
|
a84fb8b5df | ||
|
7bbd452f3b | ||
|
01c29578fb | ||
|
5d58c4baa3 | ||
|
b1493e2be6 | ||
|
50f19829d5 | ||
|
99cba7fc02 | ||
|
89c67c9726 | ||
|
3ab58a015c | ||
|
45b7434bda | ||
|
ae47298b3c | ||
|
9f36085505 | ||
|
cf6eea97b1 | ||
|
739b26ae9f | ||
|
f9e9c9d6e3 | ||
|
2cb482dc93 | ||
|
196b2f0c6c | ||
|
52e94df048 | ||
|
2454b0862d | ||
|
63bbc44ed6 | ||
|
05e8986916 | ||
|
600808beb0 | ||
|
30bc74a5aa | ||
|
d44d9f44bc | ||
|
ee89358be6 | ||
|
7e5e3f81b3 | ||
|
1bf41edb96 | ||
|
67b1b0b118 | ||
|
8d76bec525 | ||
|
0da9262cce | ||
|
1149d7adfd | ||
|
8e472211ff | ||
|
2ca0bc6dad | ||
|
51ffe93048 | ||
|
3440d71e74 | ||
|
067173f08e | ||
|
40fa551f28 | ||
|
a804df342e | ||
|
896196f08f | ||
|
245b134c92 | ||
|
667afa3c05 | ||
|
42e830eb73 | ||
|
8718efbc1c | ||
|
8c8a07f1de | ||
|
985f379845 | ||
|
5b8d142abb | ||
|
76cb94c488 | ||
|
4994db4f77 | ||
|
35d3cd6e83 | ||
|
7a46843a28 | ||
|
bafef06e90 | ||
|
d5445e0298 | ||
|
9bbaa67eec | ||
|
1f14e7bee8 | ||
|
e05b729c21 | ||
|
ad7ed86d36 | ||
|
e82a83c8cf | ||
|
31480eae72 | ||
|
c8162728b7 | ||
|
8b3072672a | ||
|
0e09f9fded | ||
|
ab406f00d9 | ||
|
2507f661e8 | ||
|
cf27131e48 | ||
|
54d8e341ab | ||
|
7b17ccbf1f | ||
|
ce7563ea4c | ||
|
d9f3555d8d | ||
|
b2dd63630c | ||
|
db1a41f845 | ||
|
08ae0046de | ||
|
c173542b23 | ||
|
518417c0de | ||
|
c2e58a2320 |
347 changed files with 25539 additions and 19868 deletions
174
.drone.yml
174
.drone.yml
|
@ -29,26 +29,91 @@ steps:
|
||||||
# AWS_SECRET_ACCESS_KEY:
|
# AWS_SECRET_ACCESS_KEY:
|
||||||
# from_secret: cache_aws_secret_access_key
|
# from_secret: cache_aws_secret_access_key
|
||||||
# settings:
|
# settings:
|
||||||
|
# debug: true
|
||||||
# restore: true
|
# restore: true
|
||||||
# bucket: kolaente.dev-drone-dependency-cache
|
# bucket: kolaente.dev-drone-dependency-cache
|
||||||
# endpoint: https://s3.fr-par.scw.cloud
|
# endpoint: https://s3.fr-par.scw.cloud
|
||||||
# region: fr-par
|
# region: fr-par
|
||||||
# path_style: true
|
# path_style: true
|
||||||
# cache_key: '{{ .Repo.Name }}_{{ checksum "yarn.lock" }}_{{ arch }}_{{ os }}'
|
# cache_key: '{{ .Repo.Name }}_{{ checksum "pnpm-lock.yaml" }}_{{ arch }}_{{ os }}'
|
||||||
# mount:
|
# mount:
|
||||||
# - '.cache'
|
# - .cache
|
||||||
|
|
||||||
- name: dependencies
|
- name: dependencies
|
||||||
image: node:18
|
image: node:18-alpine
|
||||||
pull: true
|
pull: true
|
||||||
environment:
|
environment:
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
CYPRESS_CACHE_FOLDER: .cache/cypress/
|
CYPRESS_CACHE_FOLDER: .cache/cypress
|
||||||
commands:
|
commands:
|
||||||
- yarn --frozen-lockfile --network-timeout 100000
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm install --fetch-timeout 100000
|
||||||
# depends_on:
|
# depends_on:
|
||||||
# - restore-cache
|
# - restore-cache
|
||||||
|
|
||||||
|
- name: lint
|
||||||
|
image: node:18-alpine
|
||||||
|
pull: true
|
||||||
|
environment:
|
||||||
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
|
commands:
|
||||||
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm run lint
|
||||||
|
depends_on:
|
||||||
|
- dependencies
|
||||||
|
|
||||||
|
- name: build-prod
|
||||||
|
image: node:18-alpine
|
||||||
|
pull: true
|
||||||
|
environment:
|
||||||
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
|
commands:
|
||||||
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm run build
|
||||||
|
depends_on:
|
||||||
|
- dependencies
|
||||||
|
|
||||||
|
- name: test-unit
|
||||||
|
image: node:18-alpine
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm run test:unit
|
||||||
|
depends_on:
|
||||||
|
- dependencies
|
||||||
|
|
||||||
|
- name: typecheck
|
||||||
|
failure: ignore
|
||||||
|
image: node:18-alpine
|
||||||
|
pull: true
|
||||||
|
environment:
|
||||||
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
|
commands:
|
||||||
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm run typecheck
|
||||||
|
depends_on:
|
||||||
|
- dependencies
|
||||||
|
|
||||||
|
- name: test-frontend
|
||||||
|
image: cypress/browsers:node16.14.0-chrome99-ff97
|
||||||
|
pull: true
|
||||||
|
environment:
|
||||||
|
CYPRESS_API_URL: http://api:3456/api/v1
|
||||||
|
CYPRESS_TEST_SECRET: averyLongSecretToSe33dtheDB
|
||||||
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
|
CYPRESS_CACHE_FOLDER: .cache/cypress
|
||||||
|
CYPRESS_DEFAULT_COMMAND_TIMEOUT: 60000
|
||||||
|
CYPRESS_RECORD_KEY:
|
||||||
|
from_secret: cypress_project_key
|
||||||
|
commands:
|
||||||
|
- sed -i 's/localhost/api/g' dist/index.html
|
||||||
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
|
- pnpm cypress install
|
||||||
|
- pnpm run serve:dist & npx wait-on http://localhost:4173
|
||||||
|
- pnpm run test:frontend --browser chrome --record
|
||||||
|
depends_on:
|
||||||
|
- build-prod
|
||||||
|
|
||||||
# - name: rebuild-cache
|
# - name: rebuild-cache
|
||||||
# image: meltwater/drone-cache:dev
|
# image: meltwater/drone-cache:dev
|
||||||
# pull: true
|
# pull: true
|
||||||
|
@ -63,70 +128,14 @@ steps:
|
||||||
# endpoint: https://s3.fr-par.scw.cloud
|
# endpoint: https://s3.fr-par.scw.cloud
|
||||||
# region: fr-par
|
# region: fr-par
|
||||||
# path_style: true
|
# path_style: true
|
||||||
# cache_key: '{{ .Repo.Name }}_{{ checksum "yarn.lock" }}_{{ arch }}_{{ os }}'
|
# cache_key: '{{ .Repo.Name }}_{{ checksum "pnpm-lock.yaml" }}_{{ arch }}_{{ os }}'
|
||||||
# mount:
|
# mount:
|
||||||
# - '.cache'
|
# - .cache
|
||||||
# depends_on:
|
# depends_on:
|
||||||
# - dependencies
|
# - dependencies
|
||||||
|
|
||||||
- name: lint
|
|
||||||
image: node:18
|
|
||||||
pull: true
|
|
||||||
environment:
|
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
|
||||||
CYPRESS_CACHE_FOLDER: .cache/cypress/
|
|
||||||
commands:
|
|
||||||
- yarn run lint
|
|
||||||
depends_on:
|
|
||||||
- dependencies
|
|
||||||
|
|
||||||
- name: build-prod
|
|
||||||
image: node:18
|
|
||||||
pull: true
|
|
||||||
environment:
|
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
|
||||||
commands:
|
|
||||||
- yarn build
|
|
||||||
depends_on:
|
|
||||||
- dependencies
|
|
||||||
|
|
||||||
- name: test-unit
|
|
||||||
image: node:18
|
|
||||||
pull: true
|
|
||||||
commands:
|
|
||||||
- yarn test:unit
|
|
||||||
depends_on:
|
|
||||||
- dependencies
|
|
||||||
|
|
||||||
- name: typecheck
|
|
||||||
failure: ignore
|
|
||||||
image: node:18
|
|
||||||
pull: true
|
|
||||||
commands:
|
|
||||||
- yarn typecheck
|
|
||||||
depends_on:
|
|
||||||
- dependencies
|
|
||||||
|
|
||||||
- name: test-frontend
|
|
||||||
image: cypress/browsers:node16.5.0-chrome94-ff93
|
|
||||||
pull: true
|
|
||||||
environment:
|
|
||||||
CYPRESS_API_URL: http://api:3456/api/v1
|
|
||||||
CYPRESS_TEST_SECRET: averyLongSecretToSe33dtheDB
|
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
|
||||||
CYPRESS_CACHE_FOLDER: .cache/cypress/
|
|
||||||
CYPRESS_DEFAULT_COMMAND_TIMEOUT: 60000
|
|
||||||
CYPRESS_RECORD_KEY:
|
|
||||||
from_secret: cypress_project_key
|
|
||||||
commands:
|
|
||||||
- sed -i 's/localhost/api/g' dist/index.html
|
|
||||||
- yarn serve:dist & npx wait-on http://localhost:4173
|
|
||||||
- yarn test:frontend --browser chrome --record
|
|
||||||
depends_on:
|
|
||||||
- build-prod
|
|
||||||
|
|
||||||
- name: deploy-preview
|
- name: deploy-preview
|
||||||
image: node:18
|
image: node:18-alpine
|
||||||
pull: true
|
pull: true
|
||||||
environment:
|
environment:
|
||||||
NETLIFY_AUTH_TOKEN:
|
NETLIFY_AUTH_TOKEN:
|
||||||
|
@ -138,7 +147,8 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- cp -r dist dist-preview
|
- cp -r dist dist-preview
|
||||||
# Override the default api url used for preview
|
# Override the default api url used for preview
|
||||||
- sed -i 's|localhost:3456|try.vikunja.io|g' dist-preview/index.html
|
- sed -i 's|http://localhost:3456|https://try.vikunja.io|g' dist-preview/index.html
|
||||||
|
- apk add --no-cache perl-utils
|
||||||
- shasum -a 384 -c ./scripts/deploy-preview-netlify.js.sha384
|
- shasum -a 384 -c ./scripts/deploy-preview-netlify.js.sha384
|
||||||
- node ./scripts/deploy-preview-netlify.js
|
- node ./scripts/deploy-preview-netlify.js
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -181,21 +191,22 @@ steps:
|
||||||
# endpoint: https://s3.fr-par.scw.cloud
|
# endpoint: https://s3.fr-par.scw.cloud
|
||||||
# region: fr-par
|
# region: fr-par
|
||||||
# path_style: true
|
# path_style: true
|
||||||
# cache_key: '{{ .Repo.Name }}_{{ checksum "yarn.lock" }}_{{ arch }}_{{ os }}'
|
# cache_key: '{{ .Repo.Name }}_{{ checksum "pnpm-lock.yaml" }}_{{ arch }}_{{ os }}'
|
||||||
# mount:
|
# mount:
|
||||||
# - '.cache'
|
# - .cache
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: node:18
|
image: node:18-alpine
|
||||||
pull: true
|
pull: true
|
||||||
group: build-static
|
group: build-static
|
||||||
environment:
|
environment:
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
commands:
|
commands:
|
||||||
- yarn --frozen-lockfile --network-timeout 100000
|
- corepack enable && pnpm config set store-dir .cache/.pnp
|
||||||
- yarn run lint
|
- pnpm install --fetch-timeout 100000
|
||||||
|
- pnpm run lint
|
||||||
- "echo '{\"VERSION\": \"'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'\"}' > src/version.json"
|
- "echo '{\"VERSION\": \"'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'\"}' > src/version.json"
|
||||||
- yarn run build
|
- pnpm run build
|
||||||
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
||||||
# depends_on:
|
# depends_on:
|
||||||
# - restore-cache
|
# - restore-cache
|
||||||
|
@ -256,21 +267,22 @@ steps:
|
||||||
# endpoint: https://s3.fr-par.scw.cloud
|
# endpoint: https://s3.fr-par.scw.cloud
|
||||||
# region: fr-par
|
# region: fr-par
|
||||||
# path_style: true
|
# path_style: true
|
||||||
# cache_key: '{{ .Repo.Name }}_{{ checksum "yarn.lock" }}_{{ arch }}_{{ os }}'
|
# cache_key: '{{ .Repo.Name }}_{{ checksum "pnpm-lock.yaml" }}_{{ arch }}_{{ os }}'
|
||||||
# mount:
|
# mount:
|
||||||
# - '.cache'
|
# - .cache
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: node:18
|
image: node:18-alpine
|
||||||
pull: true
|
pull: true
|
||||||
group: build-static
|
group: build-static
|
||||||
environment:
|
environment:
|
||||||
YARN_CACHE_FOLDER: .cache/yarn/
|
PNPM_CACHE_FOLDER: .cache/pnpm
|
||||||
commands:
|
commands:
|
||||||
- yarn --frozen-lockfile --network-timeout 100000
|
- corepack enable && pnpm config set store-dir .cache/pnpm
|
||||||
- yarn run lint
|
- pnpm install --fetch-timeout 100000
|
||||||
|
- pnpm run lint
|
||||||
- "echo '{\"VERSION\": \"'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'\"}' > src/version.json"
|
- "echo '{\"VERSION\": \"'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'\"}' > src/version.json"
|
||||||
- yarn run build
|
- pnpm run build
|
||||||
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
||||||
# depends_on:
|
# depends_on:
|
||||||
# - restore-cache
|
# - restore-cache
|
||||||
|
@ -647,6 +659,6 @@ steps:
|
||||||
from_secret: crowdin_key
|
from_secret: crowdin_key
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 997e1badebe484ac29557c4af356e63db4d3d57f3d32e92d482f117f8cec64da
|
hmac: c885a0e50db729842402494aa645dd3ac662828b691108550f6bf302158295ba
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* eslint-env node */
|
||||||
|
require("@rushstack/eslint-patch/modern-module-resolution")
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'root': true,
|
'root': true,
|
||||||
'env': {
|
'env': {
|
||||||
|
@ -9,7 +12,7 @@ module.exports = {
|
||||||
'extends': [
|
'extends': [
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:vue/vue3-essential',
|
'plugin:vue/vue3-essential',
|
||||||
'@vue/typescript',
|
'@vue/eslint-config-typescript/recommended',
|
||||||
],
|
],
|
||||||
'rules': {
|
'rules': {
|
||||||
'vue/html-quotes': [
|
'vue/html-quotes': [
|
||||||
|
@ -28,7 +31,6 @@ module.exports = {
|
||||||
'error',
|
'error',
|
||||||
'never',
|
'never',
|
||||||
],
|
],
|
||||||
'vue/script-setup-uses-vars': 'error',
|
|
||||||
|
|
||||||
// see https://segmentfault.com/q/1010000040813116/a-1020000041134455 (original in chinese)
|
// see https://segmentfault.com/q/1010000040813116/a-1020000041134455 (original in chinese)
|
||||||
'no-unused-vars': 'off',
|
'no-unused-vars': 'off',
|
||||||
|
@ -40,6 +42,7 @@ module.exports = {
|
||||||
'parserOptions': {
|
'parserOptions': {
|
||||||
'parser': '@typescript-eslint/parser',
|
'parser': '@typescript-eslint/parser',
|
||||||
'ecmaVersion': 2022,
|
'ecmaVersion': 2022,
|
||||||
|
'sourceType': 'module',
|
||||||
},
|
},
|
||||||
'ignorePatterns': [
|
'ignorePatterns': [
|
||||||
'*.test.*',
|
'*.test.*',
|
58
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
58
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
name: Bug Report
|
||||||
|
description: Found something you weren't expecting? Report it here!
|
||||||
|
labels: kind/bug
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
NOTE: If your issue is a security concern, please send an email to security@vikunja.io instead of opening a public issue.
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Please fill out this issue template to report a bug.
|
||||||
|
|
||||||
|
1. If you want to propose a new feature, please open a discussion thread in the forum: https://community.vikunja.io
|
||||||
|
2. Please ask questions or configuration/deploy problems on our [Matrix Room](https://matrix.to/#/#vikunja:matrix.org) or forum (https://community.vikunja.io).
|
||||||
|
3. Make sure you are using the latest release and
|
||||||
|
take a moment to check that your issue hasn't been reported before.
|
||||||
|
4. Please give all relevant information below for bug reports, because
|
||||||
|
incomplete details will be handled as an invalid report and closed.
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: |
|
||||||
|
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below).
|
||||||
|
- type: input
|
||||||
|
id: frontend-version
|
||||||
|
attributes:
|
||||||
|
label: Vikunja Frontend Version
|
||||||
|
description: Vikunja frontend version (or commit reference) of your instance
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: api-version
|
||||||
|
attributes:
|
||||||
|
label: Vikunja API Version
|
||||||
|
description: Vikunja API version (or commit reference) of your instance
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: browser-version
|
||||||
|
attributes:
|
||||||
|
label: Browser and version
|
||||||
|
description: If your issue is related to a frontend problem, please provide the browser and version you used to reproduce it.
|
||||||
|
- type: dropdown
|
||||||
|
id: can-reproduce
|
||||||
|
attributes:
|
||||||
|
label: Can you reproduce the bug on the Vikunja demo site?
|
||||||
|
options:
|
||||||
|
- "Yes"
|
||||||
|
- "No"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: screenshots
|
||||||
|
attributes:
|
||||||
|
label: Screenshots
|
||||||
|
description: If this issue involves the Web Interface, please provide one or more screenshots
|
17
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
17
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: API issues
|
||||||
|
url: https://code.vikunja.io/api/issues
|
||||||
|
about: This is the frontend repo. Please open api-related bug reports and discussions in the api 0repo. Not sure if your issue is frontend or api? Ask in Matrix or the forum first.
|
||||||
|
- name: Forum
|
||||||
|
url: https://community.vikunja.io/
|
||||||
|
about: Feature Requests, Questions, configuration or deployment problems should be discussed in the forum.
|
||||||
|
- name: Security-related issues
|
||||||
|
url: https://vikunja.io/contact/#security
|
||||||
|
about: For security concerns, please send a mail to security@vikunja.io instead of opening a public issue.
|
||||||
|
- name: Chat on Matrix
|
||||||
|
url: https://matrix.to/#/#vikunja:matrix.org
|
||||||
|
about: Please ask any quick questions here.
|
||||||
|
- name: Translations
|
||||||
|
url: https://crowdin.com/project/vikunja
|
||||||
|
about: Any problems or requests for new languages about translations should be handled in crowdin.
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -2,16 +2,21 @@
|
||||||
node_modules
|
node_modules
|
||||||
/dist*
|
/dist*
|
||||||
*.zip
|
*.zip
|
||||||
|
.direnv/
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
stats.html
|
stats.html
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.idea
|
.idea
|
||||||
|
|
2
.npmrc
Normal file
2
.npmrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
auto-install-peers=true
|
||||||
|
fetch-timeout=100000
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"eslint.packageManager": "yarn",
|
"eslint.packageManager": "pnpm",
|
||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll": true
|
"source.fixAll": true
|
||||||
|
|
2057
CHANGELOG.md
2057
CHANGELOG.md
File diff suppressed because it is too large
Load diff
24
Dockerfile
24
Dockerfile
|
@ -1,28 +1,32 @@
|
||||||
# Stage 1: Build application
|
# Stage 1: Build application
|
||||||
FROM node:18 AS compile-image
|
FROM node:18-alpine AS compile-image
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
ARG USE_RELEASE=false
|
ARG USE_RELEASE=false
|
||||||
ARG RELEASE_VERSION=main
|
ARG RELEASE_VERSION=main
|
||||||
|
|
||||||
ENV YARN_CACHE_FOLDER .cache/yarn/
|
ENV PNPM_CACHE_FOLDER .cache/pnpm/
|
||||||
COPY . ./
|
ADD . ./
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
if [ $USE_RELEASE = true ]; then \
|
if [ $USE_RELEASE = true ]; then \
|
||||||
rm -rf dist/ && \
|
|
||||||
wget https://dl.vikunja.io/frontend/vikunja-frontend-$RELEASE_VERSION.zip -O frontend-release.zip && \
|
wget https://dl.vikunja.io/frontend/vikunja-frontend-$RELEASE_VERSION.zip -O frontend-release.zip && \
|
||||||
unzip frontend-release.zip -d dist/ && \
|
unzip frontend-release.zip -d dist/ && \
|
||||||
exit 0; \
|
exit 0; \
|
||||||
fi && \
|
fi && \
|
||||||
|
# https://pnpm.io/installation#using-corepack
|
||||||
|
corepack enable && \
|
||||||
|
# we don't use corepack prepare here by intend since
|
||||||
|
# we have renovate to keep our dependencies up to date
|
||||||
# Build the frontend
|
# Build the frontend
|
||||||
yarn install --frozen-lockfile --network-timeout 100000 && \
|
pnpm install && \
|
||||||
|
apk add --no-cache git && \
|
||||||
echo '{"VERSION": "'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'"}' > src/version.json && \
|
echo '{"VERSION": "'$(git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')'"}' > src/version.json && \
|
||||||
yarn run build
|
pnpm run build
|
||||||
|
|
||||||
# Stage 2: copy
|
# Stage 2: copy
|
||||||
FROM nginx
|
FROM nginx:alpine
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY run.sh /run.sh
|
COPY run.sh /run.sh
|
||||||
|
@ -36,4 +40,10 @@ ENV PGID 1000
|
||||||
|
|
||||||
LABEL maintainer="maintainers@vikunja.io"
|
LABEL maintainer="maintainers@vikunja.io"
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
# for sh file
|
||||||
|
bash \
|
||||||
|
# installs usermod and groupmod
|
||||||
|
shadow
|
||||||
|
|
||||||
CMD "/run.sh"
|
CMD "/run.sh"
|
||||||
|
|
14
README.md
14
README.md
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[![Build Status](https://drone.kolaente.de/api/badges/vikunja/frontend/status.svg)](https://drone.kolaente.de/vikunja/frontend)
|
[![Build Status](https://drone.kolaente.de/api/badges/vikunja/frontend/status.svg)](https://drone.kolaente.de/vikunja/frontend)
|
||||||
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](LICENSE)
|
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](LICENSE)
|
||||||
[![Download](https://img.shields.io/badge/download-v0.18.2-brightgreen.svg)](https://dl.vikunja.io)
|
[![Download](https://img.shields.io/badge/download-v0.19.1-brightgreen.svg)](https://dl.vikunja.io)
|
||||||
[![Translation](https://badges.crowdin.net/vikunja/localized.svg)](https://crowdin.com/project/vikunja)
|
[![Translation](https://badges.crowdin.net/vikunja/localized.svg)](https://crowdin.com/project/vikunja)
|
||||||
|
|
||||||
This is the web frontend for Vikunja, written in Vue.js.
|
This is the web frontend for Vikunja, written in Vue.js.
|
||||||
|
@ -22,23 +22,27 @@ There is a [docker image available](https://hub.docker.com/r/vikunja/api) with s
|
||||||
## Project setup
|
## Project setup
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiles and hot-reloads for development
|
### Compiles and hot-reloads for development
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn run serve
|
pnpm run serve
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiles and minifies for production
|
### Compiles and minifies for production
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn run build
|
pnpm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lints and fixes files
|
### Lints and fixes files
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn run lint
|
pnpm run lint
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
[![Relm](https://vikunja.io/images/sponsors/relm.png)](https://relm.us)
|
||||||
|
|
59
cliff.toml
Normal file
59
cliff.toml
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
[changelog]
|
||||||
|
body = """
|
||||||
|
{% if version %}\
|
||||||
|
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
||||||
|
{% else %}\
|
||||||
|
## [unreleased]
|
||||||
|
{% endif %}\
|
||||||
|
|
||||||
|
|
||||||
|
{% for group, commits in commits | group_by(attribute="group") %}
|
||||||
|
### {{ group | upper_first }}
|
||||||
|
{% for commit in commits
|
||||||
|
| filter(attribute="scope")
|
||||||
|
| sort(attribute="scope") %}
|
||||||
|
* *({{commit.scope}})* {{ commit.message | upper_first }}
|
||||||
|
{%- if commit.breaking %}
|
||||||
|
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- for commit in commits %}
|
||||||
|
{%- if commit.scope -%}
|
||||||
|
{% else -%}
|
||||||
|
* {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }}))
|
||||||
|
{% if commit.breaking -%}
|
||||||
|
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
|
||||||
|
{% endif -%}
|
||||||
|
{% endif -%}
|
||||||
|
{% endfor -%}
|
||||||
|
{% raw %}\n{% endraw %}\
|
||||||
|
{% endfor %}\n
|
||||||
|
|
||||||
|
"""
|
||||||
|
#{% for group, commits in commits | group_by(attribute="group") %}
|
||||||
|
# ### {{ group | upper_first }}
|
||||||
|
# {% for commit in commits %}\
|
||||||
|
# - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }}))
|
||||||
|
# {% endfor %}\
|
||||||
|
#{% endfor %}\n
|
||||||
|
# remove the leading and trailing whitespace from the template
|
||||||
|
trim = true
|
||||||
|
|
||||||
|
[git]
|
||||||
|
conventional_commits = true
|
||||||
|
filter_unconventional = false
|
||||||
|
commit_parsers = [
|
||||||
|
{ message = ".*(deps).*", group = "Dependencies"},
|
||||||
|
{ message = "^feat", group = "Features"},
|
||||||
|
{ message = "^fix", group = "Bug Fixes"},
|
||||||
|
{ message = "^doc", group = "Documentation"},
|
||||||
|
{ message = "^perf", group = "Performance"},
|
||||||
|
{ message = "^refactor", group = "Refactor"},
|
||||||
|
{ message = "^style", group = "Styling"},
|
||||||
|
{ message = "^test", group = "Testing"},
|
||||||
|
{ message = "^chore\\(release\\): prepare for", skip = true},
|
||||||
|
{ message = "^chore", group = "Miscellaneous Tasks"},
|
||||||
|
{ body = ".*security", group = "Security"},
|
||||||
|
{ message = ".*", group = "Other", default_scope = "other"}, # Everything that's not a conventional commit goes into the "Other" category
|
||||||
|
]
|
||||||
|
|
|
@ -36,7 +36,7 @@ to get a shell inside the cypress container.
|
||||||
In that shell you can then execute the tests with
|
In that shell you can then execute the tests with
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn test:frontend
|
pnpm run test:frontend
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using The Cypress Dashboard
|
### Using The Cypress Dashboard
|
||||||
|
@ -44,5 +44,5 @@ yarn test:frontend
|
||||||
To open the Cypress Dashboard and run tests from there, run
|
To open the Cypress Dashboard and run tests from there, run
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
yarn cypress:open
|
pnpm run cypress:open
|
||||||
```
|
```
|
||||||
|
|
|
@ -9,7 +9,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 3456:3456
|
- 3456:3456
|
||||||
cypress:
|
cypress:
|
||||||
image: cypress/browsers:node12.18.3-chrome87-ff82
|
image: cypress/browsers:node16.14.0-chrome99-ff97
|
||||||
volumes:
|
volumes:
|
||||||
- ..:/project
|
- ..:/project
|
||||||
- $HOME/.cache:/home/node/.cache/
|
- $HOME/.cache:/home/node/.cache/
|
||||||
|
|
|
@ -16,10 +16,12 @@ describe('List View Gantt', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Shows tasks from the current and next month', () => {
|
it('Shows tasks from the current and next month', () => {
|
||||||
const now = new Date()
|
const now = Date.UTC(2022, 8, 25)
|
||||||
const nextMonth = now
|
cy.clock(now, ['Date'])
|
||||||
|
|
||||||
|
const nextMonth = new Date(now)
|
||||||
nextMonth.setDate(1)
|
nextMonth.setDate(1)
|
||||||
nextMonth.setMonth(now.getMonth() + 1)
|
nextMonth.setMonth(9)
|
||||||
|
|
||||||
cy.visit('/lists/1/gantt')
|
cy.visit('/lists/1/gantt')
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ describe('List View Gantt', () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const tasks = TaskFactory.create(1, {
|
const tasks = TaskFactory.create(1, {
|
||||||
start_date: formatISO(now),
|
start_date: formatISO(now),
|
||||||
end_date: formatISO(now.setDate(now.getDate() + 4))
|
end_date: formatISO(now.setDate(now.getDate() + 4)),
|
||||||
})
|
})
|
||||||
cy.visit('/lists/1/gantt')
|
cy.visit('/lists/1/gantt')
|
||||||
|
|
||||||
|
@ -63,7 +65,7 @@ describe('List View Gantt', () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
TaskFactory.create(1, {
|
TaskFactory.create(1, {
|
||||||
start_date: formatISO(now),
|
start_date: formatISO(now),
|
||||||
end_date: formatISO(now.setDate(now.getDate() + 4))
|
end_date: formatISO(now.setDate(now.getDate() + 4)),
|
||||||
})
|
})
|
||||||
cy.visit('/lists/1/gantt')
|
cy.visit('/lists/1/gantt')
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ describe('Lists', () => {
|
||||||
.click()
|
.click()
|
||||||
cy.get('#title')
|
cy.get('#title')
|
||||||
.type(`{selectall}${newListName}`)
|
.type(`{selectall}${newListName}`)
|
||||||
cy.get('footer.modal-card-foot .button')
|
cy.get('footer.card-footer .button')
|
||||||
.contains('Save')
|
.contains('Save')
|
||||||
.click()
|
.click()
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ describe('Namepaces', () => {
|
||||||
.should('equal', newNamespaces[0].title) // wait until the namespace data is loaded
|
.should('equal', newNamespaces[0].title) // wait until the namespace data is loaded
|
||||||
cy.get('#namespacetext')
|
cy.get('#namespacetext')
|
||||||
.type(`{selectall}${newNamespaceName}`)
|
.type(`{selectall}${newNamespaceName}`)
|
||||||
cy.get('footer.modal-card-foot .button')
|
cy.get('footer.card-footer .button')
|
||||||
.contains('Save')
|
.contains('Save')
|
||||||
.click()
|
.click()
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,19 @@ import {UserFactory} from '../../factories/user'
|
||||||
import {NamespaceFactory} from '../../factories/namespace'
|
import {NamespaceFactory} from '../../factories/namespace'
|
||||||
import {TaskFactory} from '../../factories/task'
|
import {TaskFactory} from '../../factories/task'
|
||||||
|
|
||||||
export function prepareLists(setLists = () => {}) {
|
export function createLists() {
|
||||||
beforeEach(() => {
|
|
||||||
UserFactory.create(1)
|
UserFactory.create(1)
|
||||||
NamespaceFactory.create(1)
|
NamespaceFactory.create(1)
|
||||||
const lists = ListFactory.create(1, {
|
const lists = ListFactory.create(1, {
|
||||||
title: 'First List'
|
title: 'First List'
|
||||||
})
|
})
|
||||||
setLists(lists)
|
|
||||||
TaskFactory.truncate()
|
TaskFactory.truncate()
|
||||||
|
return lists
|
||||||
|
}
|
||||||
|
|
||||||
|
export function prepareLists(setLists = () => {}) {
|
||||||
|
beforeEach(() => {
|
||||||
|
const lists = createLists()
|
||||||
|
setLists(lists)
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -12,15 +12,51 @@ import {LabelTaskFactory} from '../../factories/label_task'
|
||||||
import {BucketFactory} from '../../factories/bucket'
|
import {BucketFactory} from '../../factories/bucket'
|
||||||
|
|
||||||
import '../../support/authenticateUser'
|
import '../../support/authenticateUser'
|
||||||
|
import {TaskAttachmentFactory} from '../../factories/task_attachments'
|
||||||
|
|
||||||
|
function addLabelToTaskAndVerify(labelTitle: string) {
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Add Labels')
|
||||||
|
.click()
|
||||||
|
cy.get('.task-view .details.labels-list .multiselect input')
|
||||||
|
.type(labelTitle)
|
||||||
|
cy.get('.task-view .details.labels-list .multiselect .search-results')
|
||||||
|
.children()
|
||||||
|
.first()
|
||||||
|
.click()
|
||||||
|
|
||||||
|
cy.get('.global-notification', { timeout: 4000 })
|
||||||
|
.should('contain', 'Success')
|
||||||
|
cy.get('.task-view .details.labels-list .multiselect .input-wrapper span.tag')
|
||||||
|
.should('exist')
|
||||||
|
.should('contain', labelTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadAttachmentAndVerify(taskId: number) {
|
||||||
|
cy.intercept(`${Cypress.env('API_URL')}/tasks/${taskId}/attachments`).as('uploadAttachment')
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Add Attachments')
|
||||||
|
.click()
|
||||||
|
cy.get('input[type=file]', {timeout: 1000})
|
||||||
|
.selectFile('cypress/fixtures/image.jpg', {force: true}) // The input is not visible, but on purpose
|
||||||
|
cy.wait('@uploadAttachment')
|
||||||
|
|
||||||
|
cy.get('.attachments .attachments .files a.attachment')
|
||||||
|
.should('exist')
|
||||||
|
}
|
||||||
|
|
||||||
describe('Task', () => {
|
describe('Task', () => {
|
||||||
let namespaces
|
let namespaces
|
||||||
let lists
|
let lists
|
||||||
|
let buckets
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
UserFactory.create(1)
|
UserFactory.create(1)
|
||||||
namespaces = NamespaceFactory.create(1)
|
namespaces = NamespaceFactory.create(1)
|
||||||
lists = ListFactory.create(1)
|
lists = ListFactory.create(1)
|
||||||
|
buckets = BucketFactory.create(1, {
|
||||||
|
list_id: lists[0].id,
|
||||||
|
})
|
||||||
TaskFactory.truncate()
|
TaskFactory.truncate()
|
||||||
UserListFactory.truncate()
|
UserListFactory.truncate()
|
||||||
})
|
})
|
||||||
|
@ -80,6 +116,7 @@ describe('Task', () => {
|
||||||
describe('Task Detail View', () => {
|
describe('Task Detail View', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TaskCommentFactory.truncate()
|
TaskCommentFactory.truncate()
|
||||||
|
LabelTaskFactory.truncate()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Shows all task details', () => {
|
it('Shows all task details', () => {
|
||||||
|
@ -344,21 +381,31 @@ describe('Task', () => {
|
||||||
|
|
||||||
cy.visit(`/tasks/${tasks[0].id}`)
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
cy.get('.task-view .action-buttons .button')
|
addLabelToTaskAndVerify(labels[0].title)
|
||||||
.contains('Add Labels')
|
})
|
||||||
.click()
|
|
||||||
cy.get('.task-view .details.labels-list .multiselect input')
|
it('Can add a label to a task and it shows up on the kanban board afterwards', () => {
|
||||||
.type(labels[0].title)
|
const tasks = TaskFactory.create(1, {
|
||||||
cy.get('.task-view .details.labels-list .multiselect .search-results')
|
id: 1,
|
||||||
.children()
|
list_id: lists[0].id,
|
||||||
.first()
|
bucket_id: buckets[0].id,
|
||||||
|
})
|
||||||
|
const labels = LabelFactory.create(1)
|
||||||
|
LabelTaskFactory.truncate()
|
||||||
|
|
||||||
|
cy.visit(`/lists/${lists[0].id}/kanban`)
|
||||||
|
|
||||||
|
cy.get('.bucket .task')
|
||||||
|
.contains(tasks[0].title)
|
||||||
.click()
|
.click()
|
||||||
|
|
||||||
cy.get('.global-notification', { timeout: 4000 })
|
addLabelToTaskAndVerify(labels[0].title)
|
||||||
.should('contain', 'Success')
|
|
||||||
cy.get('.task-view .details.labels-list .multiselect .input-wrapper span.tag')
|
cy.get('.modal-content .close')
|
||||||
.should('exist')
|
.click()
|
||||||
.should('contain', labels[0].title)
|
|
||||||
|
cy.get('.bucket .task')
|
||||||
|
.should('contain.text', labels[0].title)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Can remove a label from a task', () => {
|
it('Can remove a label from a task', () => {
|
||||||
|
@ -417,5 +464,87 @@ describe('Task', () => {
|
||||||
cy.get('.global-notification')
|
cy.get('.global-notification')
|
||||||
.should('contain', 'Success')
|
.should('contain', 'Success')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Can set a priority for a task', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Set Priority')
|
||||||
|
.click()
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Priority')
|
||||||
|
.get('.select select')
|
||||||
|
.select('Urgent')
|
||||||
|
cy.get('.global-notification')
|
||||||
|
.should('contain', 'Success')
|
||||||
|
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Priority')
|
||||||
|
.get('.select select')
|
||||||
|
.should('have.value', '4')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Can set the progress for a task', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Set Progress')
|
||||||
|
.click()
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Progress')
|
||||||
|
.get('.select select')
|
||||||
|
.select('50%')
|
||||||
|
cy.get('.global-notification')
|
||||||
|
.should('contain', 'Success')
|
||||||
|
|
||||||
|
cy.wait(200)
|
||||||
|
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Progress')
|
||||||
|
.get('.select select')
|
||||||
|
.should('be.visible')
|
||||||
|
.should('have.value', '0.5')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Can add an attachment to a task', () => {
|
||||||
|
TaskAttachmentFactory.truncate()
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
uploadAttachmentAndVerify(tasks[0].id)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Can add an attachment to a task and see it appearing on kanban', () => {
|
||||||
|
TaskAttachmentFactory.truncate()
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
list_id: lists[0].id,
|
||||||
|
bucket_id: buckets[0].id,
|
||||||
|
})
|
||||||
|
const labels = LabelFactory.create(1)
|
||||||
|
LabelTaskFactory.truncate()
|
||||||
|
|
||||||
|
cy.visit(`/lists/${lists[0].id}/kanban`)
|
||||||
|
|
||||||
|
cy.get('.bucket .task')
|
||||||
|
.contains(tasks[0].title)
|
||||||
|
.click()
|
||||||
|
|
||||||
|
uploadAttachmentAndVerify(tasks[0].id)
|
||||||
|
|
||||||
|
cy.get('.modal-content .close')
|
||||||
|
.click()
|
||||||
|
|
||||||
|
cy.get('.bucket .task .footer .icon svg.fa-paperclip')
|
||||||
|
.should('exist')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,16 +1,44 @@
|
||||||
import '../../support/authenticateUser'
|
import '../../support/authenticateUser'
|
||||||
|
import {createLists} from '../list/prepareLists'
|
||||||
|
|
||||||
describe('Log out', () => {
|
function logout() {
|
||||||
it('Logs the user out', () => {
|
|
||||||
cy.visit('/')
|
|
||||||
|
|
||||||
cy.get('.navbar .user .username')
|
cy.get('.navbar .user .username')
|
||||||
.click()
|
.click()
|
||||||
cy.get('.navbar .user .dropdown-menu .dropdown-item')
|
cy.get('.navbar .user .dropdown-menu .dropdown-item')
|
||||||
.contains('Logout')
|
.contains('Logout')
|
||||||
.click()
|
.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Log out', () => {
|
||||||
|
it('Logs the user out', () => {
|
||||||
|
cy.visit('/')
|
||||||
|
|
||||||
|
expect(localStorage.getItem('token')).to.not.eq(null)
|
||||||
|
|
||||||
|
logout()
|
||||||
|
|
||||||
cy.url()
|
cy.url()
|
||||||
.should('contain', '/login')
|
.should('contain', '/login')
|
||||||
|
.then(() => {
|
||||||
|
expect(localStorage.getItem('token')).to.eq(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it.skip('Should clear the list history after logging the user out', () => {
|
||||||
|
const lists = createLists()
|
||||||
|
cy.visit(`/lists/${lists[0].id}`)
|
||||||
|
.then(() => {
|
||||||
|
expect(localStorage.getItem('listHistory')).to.not.eq(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
logout()
|
||||||
|
|
||||||
|
cy.wait(1000) // This makes re-loading of the list and associated entities (and the resulting error) visible
|
||||||
|
|
||||||
|
cy.url()
|
||||||
|
.should('contain', '/login')
|
||||||
|
.then(() => {
|
||||||
|
expect(localStorage.getItem('listHistory')).to.eq(null)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
17
cypress/factories/task_attachments.ts
Normal file
17
cypress/factories/task_attachments.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {Factory} from '../support/factory'
|
||||||
|
import {formatISO} from 'date-fns'
|
||||||
|
|
||||||
|
export class TaskAttachmentFactory extends Factory {
|
||||||
|
static table = 'task_attachments'
|
||||||
|
|
||||||
|
static factory() {
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: '{increment}',
|
||||||
|
task_id: 1,
|
||||||
|
file_id: 1,
|
||||||
|
created: formatISO(now),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
flake.lock
Normal file
25
flake.lock
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1664753041,
|
||||||
|
"narHash": "sha256-0ogaD8PaGHluARFeupofvk1Nq9gpVeZdlFM0Kcwguys=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a62844b302507c7531ad68a86cb7aa54704c9cb4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
10
flake.nix
Normal file
10
flake.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
description = "Vikunja frontend dev environment";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
in {
|
||||||
|
defaultPackage.x86_64-linux =
|
||||||
|
pkgs.mkShell { buildInputs = [ pkgs.nodePackages.pnpm pkgs.cypress ]; };
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Vikunja</title>
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<title>Vikunja</title>
|
||||||
<meta name="description" content="Vikunja (/vɪˈkuːnjə/) - The to-do app to organize your life.">
|
<meta name="description" content="Vikunja (/vɪˈkuːnjə/) - The to-do app to organize your life.">
|
||||||
<meta name="theme-color" content="#1973ff"/>
|
<meta name="theme-color" content="#1973ff"/>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[build]
|
[build]
|
||||||
command = "yarn build"
|
command = "pnpm run build"
|
||||||
publish = "dist-preview"
|
publish = "dist-preview"
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
|
|
120
package.json
120
package.json
|
@ -11,88 +11,96 @@
|
||||||
"build:dev": "vite build -m development --outDir dist-dev/",
|
"build:dev": "vite build -m development --outDir dist-dev/",
|
||||||
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",
|
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",
|
||||||
"cypress:open": "cypress open",
|
"cypress:open": "cypress open",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest --run",
|
||||||
"test:unit-watch": "vitest watch",
|
"test:unit-watch": "vitest watch",
|
||||||
"test:frontend": "cypress run",
|
"test:frontend": "cypress run",
|
||||||
"typecheck": "vue-tsc --noEmit && vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
"typecheck": "vue-tsc --noEmit && vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
||||||
"browserslist:update": "npx browserslist@latest --update-db"
|
"browserslist:update": "npx browserslist@latest --update-db"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "6.2.0",
|
||||||
|
"@fortawesome/free-regular-svg-icons": "6.2.0",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "6.2.0",
|
||||||
|
"@fortawesome/vue-fontawesome": "3.0.1",
|
||||||
"@github/hotkey": "2.0.1",
|
"@github/hotkey": "2.0.1",
|
||||||
"@kyvg/vue3-notification": "2.3.5",
|
"@kyvg/vue3-notification": "2.4.1",
|
||||||
"@sentry/tracing": "7.7.0",
|
"@sentry/tracing": "7.15.0",
|
||||||
"@sentry/vue": "7.7.0",
|
"@sentry/vue": "7.15.0",
|
||||||
"@types/is-touch-device": "1.0.0",
|
"@types/is-touch-device": "1.0.0",
|
||||||
"@types/sortablejs": "1.13.0",
|
"@types/lodash.clonedeep": "4.5.7",
|
||||||
"@vueuse/core": "8.9.4",
|
"@types/sortablejs": "1.15.0",
|
||||||
"@vueuse/router": "8.9.4",
|
"@vueuse/core": "9.3.0",
|
||||||
"blurhash": "1.1.5",
|
"@vueuse/router": "9.3.0",
|
||||||
|
"axios": "0.27.2",
|
||||||
|
"blurhash": "2.0.3",
|
||||||
"bulma-css-variables": "0.9.33",
|
"bulma-css-variables": "0.9.33",
|
||||||
"camel-case": "4.1.2",
|
"camel-case": "4.1.2",
|
||||||
"date-fns": "2.29.1",
|
"codemirror": "5.65.9",
|
||||||
"dompurify": "2.3.10",
|
"date-fns": "2.29.3",
|
||||||
"easymde": "2.16.1",
|
"dompurify": "2.4.0",
|
||||||
|
"easymde": "2.18.0",
|
||||||
"flatpickr": "4.6.13",
|
"flatpickr": "4.6.13",
|
||||||
"flexsearch": "0.7.21",
|
"flexsearch": "0.7.21",
|
||||||
|
"floating-vue": "2.0.0-beta.20",
|
||||||
"highlight.js": "11.6.0",
|
"highlight.js": "11.6.0",
|
||||||
"is-touch-device": "1.0.1",
|
"is-touch-device": "1.0.1",
|
||||||
"lodash.clonedeep": "4.5.0",
|
"lodash.clonedeep": "4.5.0",
|
||||||
"lodash.debounce": "4.0.8",
|
"lodash.debounce": "4.0.8",
|
||||||
"marked": "4.0.18",
|
"marked": "4.1.1",
|
||||||
"minimist": "1.2.6",
|
"minimist": "1.2.7",
|
||||||
|
"pinia": "2.0.23",
|
||||||
"register-service-worker": "1.7.2",
|
"register-service-worker": "1.7.2",
|
||||||
"snake-case": "3.0.4",
|
"snake-case": "3.0.4",
|
||||||
|
"sortablejs": "1.15.0",
|
||||||
"ufo": "0.8.5",
|
"ufo": "0.8.5",
|
||||||
"v-tooltip": "4.0.0-beta.17",
|
"vue": "3.2.40",
|
||||||
"vue": "3.2.37",
|
"vue-advanced-cropper": "2.8.6",
|
||||||
"vue-advanced-cropper": "2.8.3",
|
|
||||||
"vue-drag-resize": "2.0.3",
|
"vue-drag-resize": "2.0.3",
|
||||||
"vue-flatpickr-component": "9.0.6",
|
"vue-flatpickr-component": "9.0.8",
|
||||||
"vue-i18n": "9.2.0-beta.40",
|
"vue-i18n": "9.2.2",
|
||||||
"vue-router": "4.1.2",
|
"vue-router": "4.1.5",
|
||||||
"vuex": "4.0.2",
|
|
||||||
"workbox-precaching": "6.5.4",
|
"workbox-precaching": "6.5.4",
|
||||||
"zhyswan-vuedraggable": "4.1.3"
|
"zhyswan-vuedraggable": "4.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@4tw/cypress-drag-drop": "2.2.1",
|
"@4tw/cypress-drag-drop": "2.2.1",
|
||||||
"@cypress/vite-dev-server": "3.0.0",
|
"@cypress/vite-dev-server": "3.3.1",
|
||||||
"@cypress/vue": "4.0.0",
|
"@cypress/vue": "4.2.0",
|
||||||
"@faker-js/faker": "7.3.0",
|
"@faker-js/faker": "7.5.0",
|
||||||
"@fortawesome/fontawesome-svg-core": "6.1.2",
|
"@rushstack/eslint-patch": "1.2.0",
|
||||||
"@fortawesome/free-regular-svg-icons": "6.1.2",
|
"@types/dompurify": "2.3.4",
|
||||||
"@fortawesome/free-solid-svg-icons": "6.1.2",
|
|
||||||
"@fortawesome/vue-fontawesome": "3.0.1",
|
|
||||||
"@types/flexsearch": "0.7.3",
|
"@types/flexsearch": "0.7.3",
|
||||||
"@typescript-eslint/eslint-plugin": "5.30.7",
|
"@types/lodash.debounce": "4.0.7",
|
||||||
"@typescript-eslint/parser": "5.30.7",
|
"@types/marked": "4.0.7",
|
||||||
"@vitejs/plugin-legacy": "2.0.0",
|
"@types/node": "16.11.65",
|
||||||
"@vitejs/plugin-vue": "3.0.1",
|
"@typescript-eslint/eslint-plugin": "5.40.0",
|
||||||
"@vue/eslint-config-typescript": "11.0.0",
|
"@typescript-eslint/parser": "5.40.0",
|
||||||
"@vue/test-utils": "2.0.2",
|
"@vitejs/plugin-legacy": "2.2.0",
|
||||||
|
"@vitejs/plugin-vue": "3.1.2",
|
||||||
|
"@vue/eslint-config-typescript": "11.0.2",
|
||||||
|
"@vue/test-utils": "2.1.0",
|
||||||
"@vue/tsconfig": "0.1.3",
|
"@vue/tsconfig": "0.1.3",
|
||||||
"autoprefixer": "10.4.7",
|
"autoprefixer": "10.4.12",
|
||||||
"axios": "0.27.2",
|
"browserslist": "4.21.4",
|
||||||
"browserslist": "4.21.3",
|
"caniuse-lite": "1.0.30001418",
|
||||||
"caniuse-lite": "1.0.30001373",
|
"cypress": "10.10.0",
|
||||||
"cypress": "10.3.1",
|
"esbuild": "0.15.10",
|
||||||
"esbuild": "0.14.51",
|
"eslint": "8.25.0",
|
||||||
"eslint": "8.20.0",
|
"eslint-plugin-vue": "9.6.0",
|
||||||
"eslint-plugin-vue": "9.3.0",
|
"express": "4.18.2",
|
||||||
"express": "4.18.1",
|
"happy-dom": "7.4.0",
|
||||||
"happy-dom": "6.0.4",
|
"netlify-cli": "12.0.7",
|
||||||
"netlify-cli": "10.13.0",
|
"postcss": "8.4.17",
|
||||||
"postcss": "8.4.14",
|
"postcss-preset-env": "7.8.2",
|
||||||
"postcss-preset-env": "7.7.2",
|
"rollup": "3.0.0",
|
||||||
"rollup": "2.77.0",
|
"rollup-plugin-visualizer": "5.8.2",
|
||||||
"rollup-plugin-visualizer": "5.7.1",
|
"sass": "1.55.0",
|
||||||
"sass": "1.54.0",
|
"typescript": "4.8.4",
|
||||||
"typescript": "4.7.4",
|
"vite": "3.1.7",
|
||||||
"vite": "3.0.4",
|
"vite-plugin-pwa": "0.13.1",
|
||||||
"vite-plugin-pwa": "0.12.3",
|
"vite-svg-loader": "3.6.0",
|
||||||
"vite-svg-loader": "3.4.0",
|
"vitest": "0.24.1",
|
||||||
"vitest": "0.20.2",
|
"vue-tsc": "1.0.5",
|
||||||
"vue-tsc": "0.38.9",
|
|
||||||
"wait-on": "6.0.1",
|
"wait-on": "6.0.1",
|
||||||
"workbox-cli": "6.5.4"
|
"workbox-cli": "6.5.4"
|
||||||
},
|
},
|
||||||
|
@ -102,5 +110,5 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"packageManager": "yarn@1.22.19"
|
"packageManager": "pnpm@7.13.4"
|
||||||
}
|
}
|
||||||
|
|
13245
pnpm-lock.yaml
Normal file
13245
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
||||||
],
|
],
|
||||||
"packageRules": [
|
"packageRules": [
|
||||||
{
|
{
|
||||||
"matchPackageNames": ["netlify-cli"],
|
"matchPackageNames": ["netlify-cli", "happy-dom"],
|
||||||
"extends": ["schedule:weekly"]
|
"extends": ["schedule:weekly"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,12 @@
|
||||||
"matchPackagePrefixes": [
|
"matchPackagePrefixes": [
|
||||||
"@vueuse/"
|
"@vueuse/"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matchDepTypes": ["devDependencies"],
|
||||||
|
"automerge": true,
|
||||||
|
"automergeStrategy": "squash",
|
||||||
|
"automergeType": "pr"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
16
src/App.vue
16
src/App.vue
|
@ -15,10 +15,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, watch, Ref} from 'vue'
|
import {computed, watch, type Ref} from 'vue'
|
||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import {useRouteQuery} from '@vueuse/router'
|
import {useRouteQuery} from '@vueuse/router'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import isTouchDevice from 'is-touch-device'
|
import isTouchDevice from 'is-touch-device'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
@ -34,17 +33,20 @@ import Ready from '@/components/misc/ready.vue'
|
||||||
import {setLanguage} from './i18n'
|
import {setLanguage} from './i18n'
|
||||||
import AccountDeleteService from '@/services/accountDelete'
|
import AccountDeleteService from '@/services/accountDelete'
|
||||||
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
import {useColorScheme} from '@/composables/useColorScheme'
|
import {useColorScheme} from '@/composables/useColorScheme'
|
||||||
import {useBodyClass} from '@/composables/useBodyClass'
|
import {useBodyClass} from '@/composables/useBodyClass'
|
||||||
|
import {useAuthStore} from './stores/auth'
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
|
const authStore = useAuthStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useBodyClass('is-touch', isTouchDevice())
|
useBodyClass('is-touch', isTouchDevice())
|
||||||
const keyboardShortcutsActive = computed(() => store.state.keyboardShortcutsActive)
|
const keyboardShortcutsActive = computed(() => baseStore.keyboardShortcutsActive)
|
||||||
|
|
||||||
const authUser = computed(() => store.getters['auth/authUser'])
|
const authUser = computed(() => authStore.authUser)
|
||||||
const authLinkShare = computed(() => store.getters['auth/authLinkShare'])
|
const authLinkShare = computed(() => authStore.authLinkShare)
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ watch(accountDeletionConfirm, async (accountDeletionConfirm) => {
|
||||||
const accountDeletionService = new AccountDeleteService()
|
const accountDeletionService = new AccountDeleteService()
|
||||||
await accountDeletionService.confirm(accountDeletionConfirm)
|
await accountDeletionService.confirm(accountDeletionConfirm)
|
||||||
success({message: t('user.deletion.confirmSuccess')})
|
success({message: t('user.deletion.confirmSuccess')})
|
||||||
store.dispatch('auth/refreshUserInfo')
|
authStore.refreshUserInfo()
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
// setup password reset redirect
|
// setup password reset redirect
|
||||||
|
|
|
@ -12,12 +12,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
export default { inheritAttrs: false }
|
||||||
|
|
||||||
// see https://v3.vuejs.org/api/sfc-script-setup.html#usage-alongside-normal-script
|
|
||||||
export default defineComponent({
|
|
||||||
inheritAttrs: false,
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -30,7 +25,7 @@ export default defineComponent({
|
||||||
|
|
||||||
// NOTE: Do NOT use buttons with @click to push routes. => Use router-links instead!
|
// NOTE: Do NOT use buttons with @click to push routes. => Use router-links instead!
|
||||||
|
|
||||||
import { ref, watchEffect, computed, useAttrs, PropType } from 'vue'
|
import { ref, watchEffect, computed, useAttrs, type PropType } from 'vue'
|
||||||
|
|
||||||
const BASE_BUTTON_TYPES_MAP = Object.freeze({
|
const BASE_BUTTON_TYPES_MAP = Object.freeze({
|
||||||
button: 'button',
|
button: 'button',
|
||||||
|
@ -52,6 +47,7 @@ const props = defineProps({
|
||||||
|
|
||||||
|
|
||||||
const componentNodeName = ref<Node['nodeName']>('button')
|
const componentNodeName = ref<Node['nodeName']>('button')
|
||||||
|
|
||||||
interface ElementBindings {
|
interface ElementBindings {
|
||||||
type?: string;
|
type?: string;
|
||||||
rel?: string;
|
rel?: string;
|
||||||
|
@ -92,6 +88,7 @@ watchEffect(() => {
|
||||||
const isButton = computed(() => componentNodeName.value === 'button')
|
const isButton = computed(() => componentNodeName.value === 'button')
|
||||||
|
|
||||||
const button = ref()
|
const button = ref()
|
||||||
|
|
||||||
function focus() {
|
function focus() {
|
||||||
button.value.focus()
|
button.value.focus()
|
||||||
}
|
}
|
||||||
|
@ -123,7 +120,7 @@ defineExpose({
|
||||||
user-select: none;
|
user-select: none;
|
||||||
pointer-events: auto; // disable possible resets
|
pointer-events: auto; // disable possible resets
|
||||||
|
|
||||||
&:focus {
|
&:focus, &.is-focused {
|
||||||
outline: transparent;
|
outline: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
{{ $t('input.datemathHelp.intro') }}
|
{{ $t('input.datemathHelp.intro') }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<i18n-t keypath="input.datemathHelp.expression">
|
<i18n-t keypath="input.datemathHelp.expression" scope="global">
|
||||||
<code>now</code>
|
<code>now</code>
|
||||||
<code>||</code>
|
<code>||</code>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<i18n-t keypath="input.datemathHelp.similar">
|
<i18n-t keypath="input.datemathHelp.similar" scope="global">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
href="https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/"
|
href="https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/"
|
||||||
target="_blank">
|
target="_blank">
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>{{ exampleDate }}||+1M/d</code></td>
|
<td><code>{{ exampleDate }}||+1M/d</code></td>
|
||||||
<td>
|
<td>
|
||||||
<i18n-t keypath="input.datemathHelp.examples.datePlusMonth">
|
<i18n-t keypath="input.datemathHelp.examples.datePlusMonth" scope="global">
|
||||||
<code>{{ exampleDate }}</code>
|
<code>{{ exampleDate }}</code>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</td>
|
</td>
|
||||||
|
@ -110,10 +110,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {format} from 'date-fns'
|
import { formatDate } from '@/helpers/time/formatDate'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
const exampleDate = format(new Date(), 'yyyy-MM-dd')
|
const exampleDate = formatDate(new Date(), 'yyyy-MM-dd')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -71,7 +71,6 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, ref, watch} from 'vue'
|
import {computed, ref, watch} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import flatPickr from 'vue-flatpickr-component'
|
import flatPickr from 'vue-flatpickr-component'
|
||||||
|
@ -81,11 +80,12 @@ import Popup from '@/components/misc/popup.vue'
|
||||||
import {DATE_RANGES} from '@/components/date/dateRanges'
|
import {DATE_RANGES} from '@/components/date/dateRanges'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import DatemathHelp from '@/components/date/datemathHelp.vue'
|
import DatemathHelp from '@/components/date/datemathHelp.vue'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
const store = useStore()
|
const authStore = useAuthStore()
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const emit = defineEmits(['dateChanged', 'update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -93,7 +93,7 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
|
|
||||||
// FIXME: This seems to always contain the default value - that breaks the picker
|
// FIXME: This seems to always contain the default value - that breaks the picker
|
||||||
const weekStart = computed<number>(() => store.state.auth.settings.weekStart ?? 0)
|
const weekStart = computed(() => authStore.settings.weekStart ?? 0)
|
||||||
const flatPickerConfig = computed(() => ({
|
const flatPickerConfig = computed(() => ({
|
||||||
altFormat: t('date.altFormatLong'),
|
altFormat: t('date.altFormatLong'),
|
||||||
altInput: true,
|
altInput: true,
|
||||||
|
@ -118,7 +118,13 @@ watch(
|
||||||
newValue => {
|
newValue => {
|
||||||
from.value = newValue.dateFrom
|
from.value = newValue.dateFrom
|
||||||
to.value = newValue.dateTo
|
to.value = newValue.dateTo
|
||||||
|
// Only set the date back to flatpickr when it's an actual date.
|
||||||
|
// Otherwise flatpickr runs in an endless loop and slows down the browser.
|
||||||
|
const dateFrom = new Date(from.value)
|
||||||
|
const dateTo = new Date(to.value)
|
||||||
|
if (dateTo.getTime() === dateTo.getTime() && dateFrom.getTime() === dateFrom.getTime()) {
|
||||||
flatpickrRange.value = `${from.value} to ${to.value}`
|
flatpickrRange.value = `${from.value} to ${to.value}`
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -127,7 +133,6 @@ function emitChanged() {
|
||||||
dateFrom: from.value === '' ? null : from.value,
|
dateFrom: from.value === '' ? null : from.value,
|
||||||
dateTo: to.value === '' ? null : to.value,
|
dateTo: to.value === '' ? null : to.value,
|
||||||
}
|
}
|
||||||
emit('dateChanged', args)
|
|
||||||
emit('update:modelValue', args)
|
emit('update:modelValue', args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
class="menu-show-button"
|
class="menu-show-button"
|
||||||
@click="$store.commit('toggleMenu')"
|
@click="baseStore.toggleMenu()"
|
||||||
@shortkey="() => $store.commit('toggleMenu')"
|
@shortkey="() => baseStore.toggleMenu()"
|
||||||
v-shortcut="'Control+e'"
|
v-shortcut="'Control+e'"
|
||||||
:title="$t('keyboardShortcuts.toggleMenu')"
|
:title="$t('keyboardShortcuts.toggleMenu')"
|
||||||
:aria-label="menuActive ? $t('misc.hideMenu') : $t('misc.showMenu')"
|
:aria-label="menuActive ? $t('misc.hideMenu') : $t('misc.showMenu')"
|
||||||
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
const menuActive = computed(() => store.state.menuActive)
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
{{ currentList.title === '' ? $t('misc.loading') : getListTitle(currentList) }}
|
{{ currentList.title === '' ? $t('misc.loading') : getListTitle(currentList) }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
<BaseButton :to="{name: 'list.info', params: {listId: currentList.id}}" class="info-button">
|
||||||
|
<icon icon="circle-info"/>
|
||||||
|
</BaseButton>
|
||||||
|
|
||||||
<list-settings-dropdown v-if="canWriteCurrentList && currentList.id !== -1" :list="currentList"/>
|
<list-settings-dropdown v-if="canWriteCurrentList && currentList.id !== -1" :list="currentList"/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,7 +70,7 @@
|
||||||
{{ $t('navigation.privacy') }}
|
{{ $t('navigation.privacy') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
@click="$store.commit('keyboardShortcutsActive', true)"
|
@click="baseStore.setKeyboardShortcutsActive(true)"
|
||||||
>
|
>
|
||||||
{{ $t('keyboardShortcuts.title') }}
|
{{ $t('keyboardShortcuts.title') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
|
@ -88,11 +92,8 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, computed, onMounted, nextTick} from 'vue'
|
import {ref, computed, onMounted, nextTick} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useRouter} from 'vue-router'
|
|
||||||
|
|
||||||
import {QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
|
import {RIGHTS as Rights} from '@/constants/rights'
|
||||||
import Rights from '@/models/constants/rights.json'
|
|
||||||
|
|
||||||
import Update from '@/components/home/update.vue'
|
import Update from '@/components/home/update.vue'
|
||||||
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
|
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
|
||||||
|
@ -103,16 +104,25 @@ import Logo from '@/components/home/Logo.vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import MenuButton from '@/components/home/MenuButton.vue'
|
import MenuButton from '@/components/home/MenuButton.vue'
|
||||||
|
|
||||||
const store = useStore()
|
import {getListTitle} from '@/helpers/getListTitle'
|
||||||
|
|
||||||
const userInfo = computed(() => store.state.auth.info)
|
import {useBaseStore} from '@/stores/base'
|
||||||
const userAvatar = computed(() => store.state.auth.avatarUrl)
|
import {useConfigStore} from '@/stores/config'
|
||||||
const currentList = computed(() => store.state.currentList)
|
import {useAuthStore} from '@/stores/auth'
|
||||||
const background = computed(() => store.state.background)
|
|
||||||
const imprintUrl = computed(() => store.state.config.legal.imprintUrl)
|
const baseStore = useBaseStore()
|
||||||
const privacyPolicyUrl = computed(() => store.state.config.legal.privacyPolicyUrl)
|
const currentList = computed(() => baseStore.currentList)
|
||||||
const canWriteCurrentList = computed(() => store.state.currentList.maxRight > Rights.READ)
|
const background = computed(() => baseStore.background)
|
||||||
const menuActive = computed(() => store.state.menuActive)
|
const canWriteCurrentList = computed(() => baseStore.currentList.maxRight > Rights.READ)
|
||||||
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const userInfo = computed(() => authStore.info)
|
||||||
|
const userAvatar = computed(() => authStore.avatarUrl)
|
||||||
|
|
||||||
|
const configStore = useConfigStore()
|
||||||
|
const imprintUrl = computed(() => configStore.legal.imprintUrl)
|
||||||
|
const privacyPolicyUrl = computed(() => configStore.legal.privacyPolicyUrl)
|
||||||
|
|
||||||
const usernameDropdown = ref()
|
const usernameDropdown = ref()
|
||||||
const listTitle = ref()
|
const listTitle = ref()
|
||||||
|
@ -126,15 +136,12 @@ onMounted(async () => {
|
||||||
listTitle.value.style.setProperty('--nav-username-width', `${usernameWidth}px`)
|
listTitle.value.style.setProperty('--nav-username-width', `${usernameWidth}px`)
|
||||||
})
|
})
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
store.dispatch('auth/logout')
|
authStore.logout()
|
||||||
router.push({name: 'user.login'})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openQuickActions() {
|
function openQuickActions() {
|
||||||
store.commit(QUICK_ACTIONS_ACTIVE, true)
|
baseStore.setQuickActionsActive(true)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -282,10 +289,21 @@ $hamburger-menu-icon-width: 28px;
|
||||||
|
|
||||||
:deep(.dropdown-trigger) {
|
:deep(.dropdown-trigger) {
|
||||||
color: var(--grey-400);
|
color: var(--grey-400);
|
||||||
margin-left: 1rem;
|
margin-left: .5rem;
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-button {
|
||||||
|
text-align: center;
|
||||||
|
height: 1.25rem;
|
||||||
|
line-height: 1.25rem;
|
||||||
|
width: 2rem;
|
||||||
|
margin-top: .25rem;
|
||||||
|
padding: 0 .5rem;
|
||||||
|
color: var(--grey-400);
|
||||||
|
margin-left: .5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="content-auth">
|
<div class="content-auth">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="menuActive"
|
v-if="menuActive"
|
||||||
@click="$store.commit('menuActive', false)"
|
@click="baseStore.setMenuActive(false)"
|
||||||
class="menu-hide-button d-print-none"
|
class="menu-hide-button d-print-none"
|
||||||
>
|
>
|
||||||
<icon icon="times"/>
|
<icon icon="times"/>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
>
|
>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="menuActive"
|
v-if="menuActive"
|
||||||
@click="$store.commit('menuActive', false)"
|
@click="baseStore.setMenuActive(false)"
|
||||||
class="mobile-overlay d-print-none"
|
class="mobile-overlay d-print-none"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -60,81 +60,34 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {watch, computed, shallowRef, watchEffect, VNode, h} from 'vue'
|
import {watch, computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useRoute} from 'vue-router'
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
|
||||||
import {useEventListener} from '@vueuse/core'
|
|
||||||
|
|
||||||
import {CURRENT_LIST, KEYBOARD_SHORTCUTS_ACTIVE, MENU_ACTIVE} from '@/store/mutation-types'
|
|
||||||
import Navigation from '@/components/home/navigation.vue'
|
import Navigation from '@/components/home/navigation.vue'
|
||||||
import QuickActions from '@/components/quick-actions/quick-actions.vue'
|
import QuickActions from '@/components/quick-actions/quick-actions.vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
function useRouteWithModal() {
|
import {useBaseStore} from '@/stores/base'
|
||||||
const router = useRouter()
|
import {useLabelStore} from '@/stores/labels'
|
||||||
const route = useRoute()
|
|
||||||
const backdropView = computed(() => route.fullPath && window.history.state.backdropView)
|
|
||||||
|
|
||||||
const routeWithModal = computed(() => {
|
import {useRouteWithModal} from '@/composables/useRouteWithModal'
|
||||||
return backdropView.value
|
import {useRenewTokenOnFocus} from '@/composables/useRenewTokenOnFocus'
|
||||||
? router.resolve(backdropView.value)
|
|
||||||
: route
|
|
||||||
})
|
|
||||||
|
|
||||||
const currentModal = shallowRef<VNode>()
|
|
||||||
watchEffect(() => {
|
|
||||||
if (!backdropView.value) {
|
|
||||||
currentModal.value = undefined
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// logic from vue-router
|
|
||||||
// https://github.com/vuejs/vue-router-next/blob/798cab0d1e21f9b4d45a2bd12b840d2c7415f38a/src/RouterView.ts#L125
|
|
||||||
const routePropsOption = route.matched[0]?.props.default
|
|
||||||
const routeProps = routePropsOption
|
|
||||||
? routePropsOption === true
|
|
||||||
? route.params
|
|
||||||
: typeof routePropsOption === 'function'
|
|
||||||
? routePropsOption(route)
|
|
||||||
: routePropsOption
|
|
||||||
: null
|
|
||||||
|
|
||||||
currentModal.value = h(
|
|
||||||
route.matched[0]?.components.default,
|
|
||||||
routeProps,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
function closeModal() {
|
|
||||||
const historyState = computed(() => route.fullPath && window.history.state)
|
|
||||||
|
|
||||||
if (historyState.value) {
|
|
||||||
router.back()
|
|
||||||
} else {
|
|
||||||
const backdropRoute = historyState.value?.backdropView && router.resolve(historyState.value.backdropView)
|
|
||||||
router.push(backdropRoute)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {routeWithModal, currentModal, closeModal}
|
|
||||||
}
|
|
||||||
|
|
||||||
const {routeWithModal, currentModal, closeModal} = useRouteWithModal()
|
const {routeWithModal, currentModal, closeModal} = useRouteWithModal()
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
|
const background = computed(() => baseStore.background)
|
||||||
const background = computed(() => store.state.background)
|
const blurHash = computed(() => baseStore.blurHash)
|
||||||
const blurHash = computed(() => store.state.blurHash)
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
const menuActive = computed(() => store.state.menuActive)
|
|
||||||
|
|
||||||
function showKeyboardShortcuts() {
|
function showKeyboardShortcuts() {
|
||||||
store.commit(KEYBOARD_SHORTCUTS_ACTIVE, true)
|
baseStore.setKeyboardShortcutsActive(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
// hide menu on mobile
|
// hide menu on mobile
|
||||||
watch(() => route.fullPath, () => window.innerWidth < 769 && store.commit(MENU_ACTIVE, false))
|
watch(() => route.fullPath, () => window.innerWidth < 769 && baseStore.setMenuActive(false))
|
||||||
|
|
||||||
// FIXME: this is really error prone
|
// FIXME: this is really error prone
|
||||||
// Reset the current list highlight in menu if the current route is not list related.
|
// Reset the current list highlight in menu if the current route is not list related.
|
||||||
|
@ -156,48 +109,16 @@ watch(() => route.name as string, (routeName) => {
|
||||||
routeName.startsWith('user.settings')
|
routeName.startsWith('user.settings')
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
store.dispatch(CURRENT_LIST, {list: null})
|
baseStore.handleSetCurrentList({list: null})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Reset the title if the page component does not set one itself
|
// TODO: Reset the title if the page component does not set one itself
|
||||||
|
|
||||||
function useRenewTokenOnFocus() {
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const userInfo = computed(() => store.state.auth.info)
|
|
||||||
const authenticated = computed(() => store.state.auth.authenticated)
|
|
||||||
|
|
||||||
// Try renewing the token every time vikunja is loaded initially
|
|
||||||
// (When opening the browser the focus event is not fired)
|
|
||||||
store.dispatch('auth/renewToken')
|
|
||||||
|
|
||||||
// Check if the token is still valid if the window gets focus again to maybe renew it
|
|
||||||
useEventListener('focus', () => {
|
|
||||||
if (!authenticated.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const expiresIn = (userInfo.value !== null ? userInfo.value.exp : 0) - +new Date() / 1000
|
|
||||||
|
|
||||||
// If the token expiry is negative, it is already expired and we have no choice but to redirect
|
|
||||||
// the user to the login page
|
|
||||||
if (expiresIn < 0) {
|
|
||||||
store.dispatch('auth/checkAuth')
|
|
||||||
router.push({name: 'user.login'})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the token is valid for less than 60 hours and renew if thats the case
|
|
||||||
if (expiresIn < 60 * 3600) {
|
|
||||||
store.dispatch('auth/renewToken')
|
|
||||||
console.debug('renewed token')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
useRenewTokenOnFocus()
|
useRenewTokenOnFocus()
|
||||||
store.dispatch('labels/loadAllLabels')
|
|
||||||
|
const labelStore = useLabelStore()
|
||||||
|
labelStore.loadAllLabels()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
>
|
>
|
||||||
<div class="container has-text-centered link-share-view">
|
<div class="container has-text-centered link-share-view">
|
||||||
<div class="column is-10 is-offset-1">
|
<div class="column is-10 is-offset-1">
|
||||||
<Logo class="logo"/>
|
<Logo class="logo" v-if="logoVisible"/>
|
||||||
<h1
|
<h1
|
||||||
|
:class="{'m-0': !logoVisible}"
|
||||||
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
|
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
|
||||||
class="title">
|
class="title">
|
||||||
{{ currentList.title === '' ? $t('misc.loading') : currentList.title }}
|
{{ currentList.title === '' ? $t('misc.loading') : currentList.title }}
|
||||||
|
@ -23,14 +24,16 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
|
||||||
import Logo from '@/components/home/Logo.vue'
|
import Logo from '@/components/home/Logo.vue'
|
||||||
import PoweredByLink from './PoweredByLink.vue'
|
import PoweredByLink from './PoweredByLink.vue'
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
const currentList = computed(() => store.state.currentList)
|
const currentList = computed(() => baseStore.currentList)
|
||||||
const background = computed(() => store.state.background)
|
const background = computed(() => baseStore.background)
|
||||||
|
const logoVisible = computed(() => baseStore.logoVisible)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -56,10 +56,10 @@
|
||||||
class="menu-label"
|
class="menu-label"
|
||||||
v-tooltip="namespaceTitles[nk]"
|
v-tooltip="namespaceTitles[nk]"
|
||||||
>
|
>
|
||||||
<span
|
<ColorBubble
|
||||||
v-if="n.hexColor !== ''"
|
v-if="n.hexColor !== ''"
|
||||||
:style="{ backgroundColor: n.hexColor }"
|
:color="n.hexColor"
|
||||||
class="color-bubble"
|
class="mr-1"
|
||||||
/>
|
/>
|
||||||
<span class="name">{{ namespaceTitles[nk] }}</span>
|
<span class="name">{{ namespaceTitles[nk] }}</span>
|
||||||
<div
|
<div
|
||||||
|
@ -114,17 +114,17 @@
|
||||||
<span class="icon handle">
|
<span class="icon handle">
|
||||||
<icon icon="grip-lines"/>
|
<icon icon="grip-lines"/>
|
||||||
</span>
|
</span>
|
||||||
<span
|
<ColorBubble
|
||||||
:style="{ backgroundColor: l.hexColor }"
|
v-if="l.hexColor !== ''"
|
||||||
class="color-bubble"
|
:color="l.hexColor"
|
||||||
v-if="l.hexColor !== ''">
|
class="mr-1"
|
||||||
</span>
|
/>
|
||||||
<span class="list-menu-title">{{ getListTitle(l) }}</span>
|
<span class="list-menu-title">{{ getListTitle(l) }}</span>
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
class="favorite"
|
class="favorite"
|
||||||
:class="{'is-favorite': l.isFavorite}"
|
:class="{'is-favorite': l.isFavorite}"
|
||||||
@click="toggleFavoriteList(l)"
|
@click="listStore.toggleListFavorite(l)"
|
||||||
>
|
>
|
||||||
<icon :icon="l.isFavorite ? 'star' : ['far', 'star']"/>
|
<icon :icon="l.isFavorite ? 'star' : ['far', 'star']"/>
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
|
@ -141,9 +141,8 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, computed, onMounted, onBeforeMount} from 'vue'
|
import {ref, computed, onMounted, onBeforeMount} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import draggable from 'zhyswan-vuedraggable'
|
import draggable from 'zhyswan-vuedraggable'
|
||||||
import {SortableEvent} from 'sortablejs'
|
import type {SortableEvent} from 'sortablejs'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
|
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
|
||||||
|
@ -151,12 +150,17 @@ import NamespaceSettingsDropdown from '@/components/namespace/namespace-settings
|
||||||
import PoweredByLink from '@/components/home/PoweredByLink.vue'
|
import PoweredByLink from '@/components/home/PoweredByLink.vue'
|
||||||
import Logo from '@/components/home/Logo.vue'
|
import Logo from '@/components/home/Logo.vue'
|
||||||
|
|
||||||
import {MENU_ACTIVE} from '@/store/mutation-types'
|
|
||||||
import {calculateItemPosition} from '@/helpers/calculateItemPosition'
|
import {calculateItemPosition} from '@/helpers/calculateItemPosition'
|
||||||
import {getNamespaceTitle} from '@/helpers/getNamespaceTitle'
|
import {getNamespaceTitle} from '@/helpers/getNamespaceTitle'
|
||||||
|
import {getListTitle} from '@/helpers/getListTitle'
|
||||||
import {useEventListener} from '@vueuse/core'
|
import {useEventListener} from '@vueuse/core'
|
||||||
import NamespaceModel from '@/models/namespace'
|
import type {IList} from '@/modelTypes/IList'
|
||||||
import ListModel from '@/models/list'
|
import type {INamespace} from '@/modelTypes/INamespace'
|
||||||
|
import ColorBubble from '@/components/misc/colorBubble.vue'
|
||||||
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
const drag = ref(false)
|
const drag = ref(false)
|
||||||
const dragOptions = {
|
const dragOptions = {
|
||||||
|
@ -164,14 +168,15 @@ const dragOptions = {
|
||||||
ghostClass: 'ghost',
|
ghostClass: 'ghost',
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
const currentList = computed(() => store.state.currentList)
|
const namespaceStore = useNamespaceStore()
|
||||||
const menuActive = computed(() => store.state.menuActive)
|
const currentList = computed(() => baseStore.currentList)
|
||||||
const loading = computed(() => store.state.loading && store.state.loadingModule === 'namespaces')
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
|
const loading = computed(() => namespaceStore.isLoading)
|
||||||
|
|
||||||
|
|
||||||
const namespaces = computed(() => {
|
const namespaces = computed(() => {
|
||||||
return (store.state.namespaces.namespaces as NamespaceModel[]).filter(n => !n.isArchived)
|
return namespaceStore.namespaces.filter(n => !n.isArchived)
|
||||||
})
|
})
|
||||||
const activeLists = computed(() => {
|
const activeLists = computed(() => {
|
||||||
return namespaces.value.map(({lists}) => {
|
return namespaces.value.map(({lists}) => {
|
||||||
|
@ -193,29 +198,21 @@ const namespaceListsCount = computed(() => {
|
||||||
useEventListener('resize', resize)
|
useEventListener('resize', resize)
|
||||||
onMounted(() => resize())
|
onMounted(() => resize())
|
||||||
|
|
||||||
|
const listStore = useListStore()
|
||||||
function toggleFavoriteList(list: ListModel) {
|
|
||||||
// The favorites pseudo list is always favorite
|
|
||||||
// Archived lists cannot be marked favorite
|
|
||||||
if (list.id === -1 || list.isArchived) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
store.dispatch('lists/toggleListFavorite', list)
|
|
||||||
}
|
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
// Hide the menu by default on mobile
|
// Hide the menu by default on mobile
|
||||||
store.commit(MENU_ACTIVE, window.innerWidth >= 770)
|
baseStore.setMenuActive(window.innerWidth >= 770)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleLists(namespaceId: number) {
|
function toggleLists(namespaceId: INamespace['id']) {
|
||||||
listsVisible.value[namespaceId] = !listsVisible.value[namespaceId]
|
listsVisible.value[namespaceId] = !listsVisible.value[namespaceId]
|
||||||
}
|
}
|
||||||
|
|
||||||
const listsVisible = ref<{ [id: NamespaceModel['id']]: boolean }>({})
|
const listsVisible = ref<{ [id: INamespace['id']]: boolean }>({})
|
||||||
// FIXME: async action will be unfinished when component mounts
|
// FIXME: async action will be unfinished when component mounts
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
const namespaces = await store.dispatch('namespaces/loadNamespaces') as NamespaceModel[]
|
const namespaces = await namespaceStore.loadNamespaces()
|
||||||
namespaces.forEach(n => {
|
namespaces.forEach(n => {
|
||||||
if (typeof listsVisible.value[n.id] === 'undefined') {
|
if (typeof listsVisible.value[n.id] === 'undefined') {
|
||||||
listsVisible.value[n.id] = true
|
listsVisible.value[n.id] = true
|
||||||
|
@ -223,7 +220,7 @@ onBeforeMount(async () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function updateActiveLists(namespace: NamespaceModel, activeLists: ListModel[]) {
|
function updateActiveLists(namespace: INamespace, activeLists: IList[]) {
|
||||||
// This is a bit hacky: since we do have to filter out the archived items from the list
|
// This is a bit hacky: since we do have to filter out the archived items from the list
|
||||||
// for vue draggable updating it is not as simple as replacing it.
|
// for vue draggable updating it is not as simple as replacing it.
|
||||||
// To work around this, we merge the active lists with the archived ones. Doing so breaks the order
|
// To work around this, we merge the active lists with the archived ones. Doing so breaks the order
|
||||||
|
@ -234,24 +231,29 @@ function updateActiveLists(namespace: NamespaceModel, activeLists: ListModel[])
|
||||||
...namespace.lists.filter(l => l.isArchived),
|
...namespace.lists.filter(l => l.isArchived),
|
||||||
]
|
]
|
||||||
|
|
||||||
store.commit('namespaces/setNamespaceById', {
|
namespaceStore.setNamespaceById({
|
||||||
...namespace,
|
...namespace,
|
||||||
lists,
|
lists,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const listUpdating = ref<{ [id: NamespaceModel['id']]: boolean }>({})
|
const listUpdating = ref<{ [id: INamespace['id']]: boolean }>({})
|
||||||
|
|
||||||
async function saveListPosition(e: SortableEvent) {
|
async function saveListPosition(e: SortableEvent) {
|
||||||
if (!e.newIndex) return
|
if (!e.newIndex && e.newIndex !== 0) return
|
||||||
|
|
||||||
const namespaceId = parseInt(e.to.dataset.namespaceId as string)
|
const namespaceId = parseInt(e.to.dataset.namespaceId as string)
|
||||||
const newNamespaceIndex = parseInt(e.to.dataset.namespaceIndex as string)
|
const newNamespaceIndex = parseInt(e.to.dataset.namespaceIndex as string)
|
||||||
|
|
||||||
const listsActive = activeLists.value[newNamespaceIndex]
|
const listsActive = activeLists.value[newNamespaceIndex]
|
||||||
const list = listsActive[e.newIndex]
|
// If the list was dragged to the last position, Safari will report e.newIndex as the size of the listsActive
|
||||||
const listBefore = listsActive[e.newIndex - 1] ?? null
|
// array instead of using the position. Because the index is wrong in that case, dragging the list will fail.
|
||||||
const listAfter = listsActive[e.newIndex + 1] ?? null
|
// To work around that we're explicitly checking that case here and decrease the index.
|
||||||
|
const newIndex = e.newIndex === listsActive.length ? e.newIndex - 1 : e.newIndex
|
||||||
|
|
||||||
|
const list = listsActive[newIndex]
|
||||||
|
const listBefore = listsActive[newIndex - 1] ?? null
|
||||||
|
const listAfter = listsActive[newIndex + 1] ?? null
|
||||||
listUpdating.value[list.id] = true
|
listUpdating.value[list.id] = true
|
||||||
|
|
||||||
const position = calculateItemPosition(
|
const position = calculateItemPosition(
|
||||||
|
@ -260,8 +262,8 @@ async function saveListPosition(e: SortableEvent) {
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// create a copy of the list in order to not violate vuex mutations
|
// create a copy of the list in order to not violate pinia manipulation
|
||||||
await store.dispatch('lists/updateList', {
|
await listStore.updateList({
|
||||||
...list,
|
...list,
|
||||||
position,
|
position,
|
||||||
namespaceId,
|
namespaceId,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="update-notification" v-if="updateAvailable">
|
<div class="update-notification" v-if="updateAvailable">
|
||||||
<p>{{ $t('update.available') }}</p>
|
<p>{{ $t('update.available') }}</p>
|
||||||
<x-button @click="refreshApp()" :shadow="false">
|
<x-button @click="refreshApp()" :shadow="false" class="has-no-text-wrap">
|
||||||
{{ $t('update.do') }}
|
{{ $t('update.do') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,24 +43,19 @@ function refreshApp() {
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.update-notification {
|
.update-notification {
|
||||||
margin: .5rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: $warning;
|
background: $warning;
|
||||||
padding: 0 .25rem;
|
padding: .5rem;
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
color: var(--grey-900);
|
color: var(--grey-900);
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
@media screen and (max-width: $desktop) {
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 1rem;
|
bottom: 1rem;
|
||||||
margin: 0;
|
|
||||||
width: 450px;
|
width: 450px;
|
||||||
left: calc(50vw - 225px);
|
left: calc(50vw - 225px);
|
||||||
padding: .5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: $tablet) {
|
@media screen and (max-width: $tablet) {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
|
@ -9,24 +9,27 @@
|
||||||
}
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<icon :icon="icon" v-if="showIconOnly"/>
|
<icon
|
||||||
|
v-if="showIconOnly"
|
||||||
|
:icon="icon"
|
||||||
|
:style="{'color': iconColor !== '' ? iconColor : false}"
|
||||||
|
/>
|
||||||
<span class="icon is-small" v-else-if="icon !== ''">
|
<span class="icon is-small" v-else-if="icon !== ''">
|
||||||
<icon :icon="icon"/>
|
<icon
|
||||||
|
:icon="icon"
|
||||||
|
:style="{'color': iconColor !== '' ? iconColor : false}"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
<slot />
|
<slot />
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
export default { name: 'x-button' }
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'x-button',
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, useSlots, PropType} from 'vue'
|
import {computed, useSlots, type PropType} from 'vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
const BUTTON_TYPES_MAP = Object.freeze({
|
const BUTTON_TYPES_MAP = Object.freeze({
|
||||||
|
@ -46,6 +49,10 @@ const props = defineProps({
|
||||||
type: [String, Array],
|
type: [String, Array],
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
iconColor: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -69,9 +76,11 @@ const showIconOnly = computed(() => props.icon !== '' && typeof slots.default ==
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
height: auto;
|
||||||
min-height: $button-height;
|
min-height: $button-height;
|
||||||
box-shadow: var(--shadow-sm);
|
box-shadow: var(--shadow-sm);
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
white-space: break-spaces;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
|
|
|
@ -34,9 +34,8 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {computed, ref, toRef, watch} from 'vue'
|
||||||
|
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
|
||||||
const DEFAULT_COLORS = [
|
const DEFAULT_COLORS = [
|
||||||
|
@ -48,17 +47,12 @@ const DEFAULT_COLORS = [
|
||||||
'#00db60',
|
'#00db60',
|
||||||
]
|
]
|
||||||
|
|
||||||
export default defineComponent({
|
const color = ref('')
|
||||||
name: 'colorPicker',
|
const lastChangeTimeout = ref<ReturnType<typeof setTimeout> | null>(null)
|
||||||
data() {
|
const defaultColors = ref(DEFAULT_COLORS)
|
||||||
return {
|
const colorListID = ref(createRandomID())
|
||||||
color: '',
|
|
||||||
lastChangeTimeout: null,
|
const props = defineProps({
|
||||||
defaultColors: DEFAULT_COLORS,
|
|
||||||
colorListID: createRandomID(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -67,48 +61,43 @@ export default defineComponent({
|
||||||
type: String,
|
type: String,
|
||||||
default: 'top',
|
default: 'top',
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
emits: ['update:modelValue', 'change'],
|
|
||||||
watch: {
|
|
||||||
modelValue: {
|
|
||||||
handler(modelValue) {
|
|
||||||
this.color = modelValue
|
|
||||||
},
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
color() {
|
|
||||||
this.update()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isEmpty() {
|
|
||||||
return this.color === '#000000' || this.color === ''
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
update(force = false) {
|
|
||||||
|
|
||||||
if(this.isEmpty && !force) {
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
|
const modelValue = toRef(props, 'modelValue')
|
||||||
|
watch(
|
||||||
|
modelValue,
|
||||||
|
(newValue) => {
|
||||||
|
color.value = newValue
|
||||||
|
},
|
||||||
|
{immediate: true},
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(color, () => update())
|
||||||
|
|
||||||
|
const isEmpty = computed(() => color.value === '#000000' || color.value === '')
|
||||||
|
|
||||||
|
function update(force = false) {
|
||||||
|
if(isEmpty.value && !force) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lastChangeTimeout !== null) {
|
if (lastChangeTimeout.value !== null) {
|
||||||
clearTimeout(this.lastChangeTimeout)
|
clearTimeout(lastChangeTimeout.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastChangeTimeout = setTimeout(() => {
|
lastChangeTimeout.value = setTimeout(() => {
|
||||||
this.$emit('update:modelValue', this.color)
|
emit('update:modelValue', color.value)
|
||||||
this.$emit('change')
|
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
}
|
||||||
reset() {
|
|
||||||
|
function reset() {
|
||||||
// FIXME: I havn't found a way to make it clear to the user the color war reset.
|
// FIXME: I havn't found a way to make it clear to the user the color war reset.
|
||||||
// Not sure if verte is capable of this - it does not show the change when setting this.color = ''
|
// Not sure if verte is capable of this - it does not show the change when setting this.color = ''
|
||||||
this.color = ''
|
color.value = ''
|
||||||
this.update(true)
|
update(true)
|
||||||
},
|
}
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -88,155 +88,152 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {ref, onMounted, onBeforeUnmount, toRef, watch, computed, type PropType} from 'vue'
|
||||||
|
|
||||||
import flatPickr from 'vue-flatpickr-component'
|
import flatPickr from 'vue-flatpickr-component'
|
||||||
import 'flatpickr/dist/flatpickr.css'
|
import 'flatpickr/dist/flatpickr.css'
|
||||||
import {i18n} from '@/i18n'
|
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
import {format} from 'date-fns'
|
import {formatDate, formatDateShort} from '@/helpers/time/formatDate'
|
||||||
import {calculateDayInterval} from '@/helpers/time/calculateDayInterval'
|
import {calculateDayInterval} from '@/helpers/time/calculateDayInterval'
|
||||||
import {calculateNearestHours} from '@/helpers/time/calculateNearestHours'
|
import {calculateNearestHours} from '@/helpers/time/calculateNearestHours'
|
||||||
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
||||||
import {createDateFromString} from '@/helpers/time/createDateFromString'
|
import {createDateFromString} from '@/helpers/time/createDateFromString'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'datepicker',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
date: null,
|
|
||||||
show: false,
|
|
||||||
changed: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
flatPickr,
|
|
||||||
BaseButton,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
type: [Date, null, String] as PropType<Date | null | string>,
|
||||||
validator: prop => prop instanceof Date || prop === null || typeof prop === 'string',
|
validator: prop => prop instanceof Date || prop === null || typeof prop === 'string',
|
||||||
|
default: null,
|
||||||
},
|
},
|
||||||
chooseDateLabel: {
|
chooseDateLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default() {
|
||||||
return i18n.global.t('input.datepicker.chooseDate')
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
return t('input.datepicker.chooseDate')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
emits: ['update:modelValue', 'change', 'close', 'close-on-change'],
|
|
||||||
mounted() {
|
const emit = defineEmits(['update:modelValue', 'close', 'close-on-change'])
|
||||||
document.addEventListener('click', this.hideDatePopup)
|
|
||||||
},
|
const {t} = useI18n({useScope: 'global'})
|
||||||
beforeUnmount() {
|
|
||||||
document.removeEventListener('click', this.hideDatePopup)
|
const date = ref<Date | null>()
|
||||||
},
|
const show = ref(false)
|
||||||
watch: {
|
const changed = ref(false)
|
||||||
modelValue: {
|
|
||||||
handler: 'setDateValue',
|
onMounted(() => document.addEventListener('click', hideDatePopup))
|
||||||
immediate: true,
|
onBeforeUnmount(() =>document.removeEventListener('click', hideDatePopup))
|
||||||
},
|
|
||||||
},
|
const modelValue = toRef(props, 'modelValue')
|
||||||
computed: {
|
watch(
|
||||||
flatPickerConfig() {
|
modelValue,
|
||||||
return {
|
setDateValue,
|
||||||
altFormat: this.$t('date.altFormatLong'),
|
{immediate: true},
|
||||||
|
)
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const weekStart = computed(() => authStore.settings.weekStart)
|
||||||
|
const flatPickerConfig = computed(() => ({
|
||||||
|
altFormat: t('date.altFormatLong'),
|
||||||
altInput: true,
|
altInput: true,
|
||||||
dateFormat: 'Y-m-d H:i',
|
dateFormat: 'Y-m-d H:i',
|
||||||
enableTime: true,
|
enableTime: true,
|
||||||
time_24hr: true,
|
time_24hr: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: this.$store.state.auth.settings.weekStart,
|
firstDayOfWeek: weekStart.value,
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
// Since flatpickr dates are strings, we need to convert them to native date objects.
|
// Since flatpickr dates are strings, we need to convert them to native date objects.
|
||||||
// To make that work, we need a separate variable since flatpickr does not have a change event.
|
// To make that work, we need a separate variable since flatpickr does not have a change event.
|
||||||
flatPickrDate: {
|
const flatPickrDate = computed({
|
||||||
set(newValue) {
|
set(newValue: string | Date) {
|
||||||
this.date = createDateFromString(newValue)
|
date.value = createDateFromString(newValue)
|
||||||
this.updateData()
|
updateData()
|
||||||
},
|
},
|
||||||
get() {
|
get() {
|
||||||
if (!this.date) {
|
if (!date.value) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return format(this.date, 'yyy-LL-dd H:mm')
|
return formatDate(date.value, 'yyy-LL-dd H:mm')
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
setDateValue(newVal) {
|
function setDateValue(dateString: string | Date | null) {
|
||||||
if (newVal === null) {
|
if (dateString === null) {
|
||||||
this.date = null
|
date.value = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.date = createDateFromString(newVal)
|
date.value = createDateFromString(dateString)
|
||||||
},
|
}
|
||||||
updateData() {
|
|
||||||
this.changed = true
|
function updateData() {
|
||||||
this.$emit('update:modelValue', this.date)
|
changed.value = true
|
||||||
this.$emit('change', this.date)
|
emit('update:modelValue', date.value)
|
||||||
},
|
}
|
||||||
toggleDatePopup() {
|
|
||||||
if (this.disabled) {
|
function toggleDatePopup() {
|
||||||
|
if (props.disabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.show = !this.show
|
show.value = !show.value
|
||||||
},
|
|
||||||
hideDatePopup(e) {
|
|
||||||
if (this.show) {
|
|
||||||
closeWhenClickedOutside(e, this.$refs.datepickerPopup, this.close)
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
close() {
|
const datepickerPopup = ref<HTMLElement | null>(null)
|
||||||
|
function hideDatePopup(e) {
|
||||||
|
if (show.value) {
|
||||||
|
closeWhenClickedOutside(e, datepickerPopup.value, close)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
// Kind of dirty, but the timeout allows us to enter a time and click on "confirm" without
|
// Kind of dirty, but the timeout allows us to enter a time and click on "confirm" without
|
||||||
// having to click on another input field before it is actually used.
|
// having to click on another input field before it is actually used.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.show = false
|
show.value = false
|
||||||
this.$emit('close', this.changed)
|
emit('close', changed.value)
|
||||||
if (this.changed) {
|
if (changed.value) {
|
||||||
this.changed = false
|
changed.value = false
|
||||||
this.$emit('close-on-change', this.changed)
|
emit('close-on-change', changed.value)
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
},
|
|
||||||
setDate(date) {
|
|
||||||
if (this.date === null) {
|
|
||||||
this.date = new Date()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const interval = calculateDayInterval(date)
|
function setDate(dateString: string) {
|
||||||
|
if (date.value === null) {
|
||||||
|
date.value = new Date()
|
||||||
|
}
|
||||||
|
|
||||||
|
const interval = calculateDayInterval(dateString)
|
||||||
const newDate = new Date()
|
const newDate = new Date()
|
||||||
newDate.setDate(newDate.getDate() + interval)
|
newDate.setDate(newDate.getDate() + interval)
|
||||||
newDate.setHours(calculateNearestHours(newDate))
|
newDate.setHours(calculateNearestHours(newDate))
|
||||||
newDate.setMinutes(0)
|
newDate.setMinutes(0)
|
||||||
newDate.setSeconds(0)
|
newDate.setSeconds(0)
|
||||||
this.date = newDate
|
date.value = newDate
|
||||||
this.flatPickrDate = newDate
|
flatPickrDate.value = newDate
|
||||||
this.updateData()
|
updateData()
|
||||||
},
|
}
|
||||||
getDayIntervalFromString(date) {
|
|
||||||
return calculateDayInterval(date)
|
function getWeekdayFromStringInterval(dateString: string) {
|
||||||
},
|
const interval = calculateDayInterval(dateString)
|
||||||
getWeekdayFromStringInterval(date) {
|
|
||||||
const interval = calculateDayInterval(date)
|
|
||||||
const newDate = new Date()
|
const newDate = new Date()
|
||||||
newDate.setDate(newDate.getDate() + interval)
|
newDate.setDate(newDate.getDate() + interval)
|
||||||
return format(newDate, 'E')
|
return formatDate(newDate, 'E')
|
||||||
},
|
}
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<vue-easymde
|
<vue-easymde
|
||||||
:configs="config"
|
:configs="config"
|
||||||
@change="bubble"
|
@change="() => bubble()"
|
||||||
@update:modelValue="handleInput"
|
@update:modelValue="handleInput"
|
||||||
class="content"
|
class="content"
|
||||||
v-if="isEditActive"
|
v-if="isEditActive"
|
||||||
|
@ -16,14 +16,29 @@
|
||||||
<p class="has-text-centered has-text-grey is-italic my-5" v-if="showPreviewText">
|
<p class="has-text-centered has-text-grey is-italic my-5" v-if="showPreviewText">
|
||||||
{{ emptyText }}
|
{{ emptyText }}
|
||||||
<template v-if="isEditEnabled">
|
<template v-if="isEditEnabled">
|
||||||
<ButtonLink @click="toggleEdit" class="d-print-none">{{ $t('input.editor.edit') }}</ButtonLink>.
|
<ButtonLink
|
||||||
|
@click="toggleEdit"
|
||||||
|
v-shortcut="editShortcut"
|
||||||
|
class="d-print-none">
|
||||||
|
{{ $t('input.editor.edit') }}
|
||||||
|
</ButtonLink>.
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul class="actions d-print-none" v-if="bottomActions.length > 0">
|
<ul class="actions d-print-none" v-if="bottomActions.length > 0">
|
||||||
<li v-if="isEditEnabled && !showPreviewText && showSave">
|
<li v-if="isEditEnabled && !showPreviewText && showSave">
|
||||||
<BaseButton v-if="showEditButton" @click="toggleEdit">{{ $t('input.editor.edit') }}</BaseButton>
|
<BaseButton
|
||||||
<BaseButton v-else-if="isEditActive" @click="toggleEdit" class="done-edit">{{ $t('misc.save') }}</BaseButton>
|
v-if="showEditButton"
|
||||||
|
@click="toggleEdit"
|
||||||
|
v-shortcut="editShortcut">
|
||||||
|
{{ $t('input.editor.edit') }}
|
||||||
|
</BaseButton>
|
||||||
|
<BaseButton
|
||||||
|
v-else-if="isEditActive"
|
||||||
|
@click="toggleEdit"
|
||||||
|
class="done-edit">
|
||||||
|
{{ $t('misc.save') }}
|
||||||
|
</BaseButton>
|
||||||
</li>
|
</li>
|
||||||
<li v-for="(action, k) in bottomActions" :key="k">
|
<li v-for="(action, k) in bottomActions" :key="k">
|
||||||
<BaseButton @click="action.action">{{ action.title }}</BaseButton>
|
<BaseButton @click="action.action">{{ action.title }}</BaseButton>
|
||||||
|
@ -32,7 +47,11 @@
|
||||||
<template v-else-if="isEditEnabled && showSave">
|
<template v-else-if="isEditEnabled && showSave">
|
||||||
<ul v-if="showEditButton" class="actions d-print-none">
|
<ul v-if="showEditButton" class="actions d-print-none">
|
||||||
<li>
|
<li>
|
||||||
<BaseButton @click="toggleEdit">{{ $t('input.editor.edit') }}</BaseButton>
|
<BaseButton
|
||||||
|
@click="toggleEdit"
|
||||||
|
v-shortcut="editShortcut">
|
||||||
|
{{ $t('input.editor.edit') }}
|
||||||
|
</BaseButton>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<x-button
|
<x-button
|
||||||
|
@ -47,32 +66,28 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {computed, nextTick, onMounted, ref, toRefs, watch} from 'vue'
|
||||||
|
|
||||||
import VueEasymde from './vue-easymde.vue'
|
import VueEasymde from './vue-easymde.vue'
|
||||||
import {marked} from 'marked'
|
import {marked} from 'marked'
|
||||||
import DOMPurify from 'dompurify'
|
import DOMPurify from 'dompurify'
|
||||||
import hljs from 'highlight.js/lib/common'
|
|
||||||
|
|
||||||
import {createEasyMDEConfig} from './editorConfig'
|
import {createEasyMDEConfig} from './editorConfig'
|
||||||
|
|
||||||
import AttachmentModel from '../../models/attachment'
|
import AttachmentModel from '@/models/attachment'
|
||||||
import AttachmentService from '../../services/attachment'
|
import AttachmentService from '@/services/attachment'
|
||||||
import {findCheckboxesInText} from '../../helpers/checklistFromText'
|
|
||||||
|
import {setupMarkdownRenderer} from '@/helpers/markdownRenderer'
|
||||||
|
import {findCheckboxesInText} from '@/helpers/checklistFromText'
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import ButtonLink from '@/components/misc/ButtonLink.vue'
|
import ButtonLink from '@/components/misc/ButtonLink.vue'
|
||||||
|
import type { IAttachment } from '@/modelTypes/IAttachment'
|
||||||
|
import type { ITask } from '@/modelTypes/ITask'
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'editor',
|
|
||||||
components: {
|
|
||||||
VueEasymde,
|
|
||||||
BaseButton,
|
|
||||||
ButtonLink,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -110,133 +125,114 @@ export default defineComponent({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
// If a key is passed the editor will go in "edit" mode when the key is pressed.
|
||||||
|
// Disabled if an empty string is passed.
|
||||||
|
editShortcut: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue', 'change'],
|
})
|
||||||
computed: {
|
|
||||||
showPreviewText() {
|
|
||||||
return this.isPreviewActive && this.text === '' && this.emptyText !== ''
|
|
||||||
},
|
|
||||||
showEditButton() {
|
|
||||||
return !this.isEditActive && this.text !== ''
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
text: '',
|
|
||||||
changeTimeout: null,
|
|
||||||
isEditActive: false,
|
|
||||||
isPreviewActive: true,
|
|
||||||
|
|
||||||
preview: '',
|
const emit = defineEmits(['update:modelValue'])
|
||||||
attachmentService: null,
|
|
||||||
loadedAttachments: {},
|
const text = ref('')
|
||||||
config: createEasyMDEConfig({
|
const changeTimeout = ref<ReturnType<typeof setTimeout> | null>(null)
|
||||||
placeholder: this.placeholder,
|
const isEditActive = ref(false)
|
||||||
uploadImage: this.uploadEnabled,
|
const isPreviewActive = ref(true)
|
||||||
imageUploadFunction: this.uploadCallback,
|
|
||||||
}),
|
const showPreviewText = computed(() => isPreviewActive.value && text.value === '' && props.emptyText !== '')
|
||||||
checkboxId: createRandomID(),
|
const showEditButton = computed(() => !isEditActive.value && text.value !== '')
|
||||||
}
|
|
||||||
|
const preview = ref('')
|
||||||
|
const attachmentService = new AttachmentService()
|
||||||
|
|
||||||
|
type CacheKey = `${ITask['id']}-${IAttachment['id']}`
|
||||||
|
const loadedAttachments = ref<{[key: CacheKey]: string}>({})
|
||||||
|
const config = ref(createEasyMDEConfig({
|
||||||
|
placeholder: props.placeholder,
|
||||||
|
uploadImage: props.uploadEnabled,
|
||||||
|
imageUploadFunction: props.uploadCallback,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const checkboxId = ref(createRandomID())
|
||||||
|
|
||||||
|
const {modelValue} = toRefs(props)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
modelValue,
|
||||||
|
async (value) => {
|
||||||
|
text.value = value
|
||||||
|
await nextTick()
|
||||||
|
renderPreview()
|
||||||
},
|
},
|
||||||
watch: {
|
)
|
||||||
modelValue(modelValue) {
|
|
||||||
this.text = modelValue
|
watch(
|
||||||
this.$nextTick(this.renderPreview)
|
text,
|
||||||
},
|
(newVal, oldVal) => {
|
||||||
text(newVal, oldVal) {
|
|
||||||
// Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside.
|
// Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside.
|
||||||
if (oldVal === '' && this.text === this.modelValue) {
|
if (oldVal === '' && text.value === modelValue.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.bubble()
|
bubble()
|
||||||
},
|
},
|
||||||
},
|
)
|
||||||
mounted() {
|
|
||||||
if (this.modelValue !== '') {
|
|
||||||
this.text = this.modelValue
|
onMounted(() => {
|
||||||
|
if (modelValue.value !== '') {
|
||||||
|
text.value = modelValue.value
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.previewIsDefault && this.hasPreview) {
|
if (props.previewIsDefault && props.hasPreview) {
|
||||||
this.$nextTick(this.renderPreview)
|
nextTick(() => renderPreview())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isPreviewActive = false
|
isPreviewActive.value = false
|
||||||
this.isEditActive = true
|
isEditActive.value = true
|
||||||
},
|
})
|
||||||
methods: {
|
|
||||||
|
|
||||||
// This gets triggered when only pasting content into the editor.
|
// This gets triggered when only pasting content into the editor.
|
||||||
// A change event would not get generated by that, an input event does.
|
// A change event would not get generated by that, an input event does.
|
||||||
// Therefore, we're using this handler to catch paste events.
|
// Therefore, we're using this handler to catch paste events.
|
||||||
// But because this also gets triggered when typing into the editor, we give
|
// But because this also gets triggered when typing into the editor, we give
|
||||||
// it a higher timeout to make the timouts cancel each other in that case so
|
// it a higher timeout to make the timouts cancel each other in that case so
|
||||||
// that in the end, only one change event is triggered to the outside per change.
|
// that in the end, only one change event is triggered to the outside per change.
|
||||||
handleInput(val) {
|
function handleInput(val: string) {
|
||||||
// Don't bubble if the text is up to date
|
// Don't bubble if the text is up to date
|
||||||
if (val === this.text) {
|
if (val === text.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.text = val
|
text.value = val
|
||||||
this.bubble(1000)
|
bubble(1000)
|
||||||
},
|
|
||||||
bubble(timeout = 500) {
|
|
||||||
if (this.changeTimeout !== null) {
|
|
||||||
clearTimeout(this.changeTimeout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changeTimeout = setTimeout(() => {
|
function bubble(timeout = 500) {
|
||||||
this.$emit('update:modelValue', this.text)
|
if (changeTimeout.value !== null) {
|
||||||
this.$emit('change', this.text)
|
clearTimeout(changeTimeout.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTimeout.value = setTimeout(() => {
|
||||||
|
emit('update:modelValue', text.value)
|
||||||
}, timeout)
|
}, timeout)
|
||||||
},
|
}
|
||||||
replaceAt(str, index, replacement) {
|
|
||||||
return str.substr(0, index) + replacement + str.substr(index + replacement.length)
|
function replaceAt(str: string, index: number, replacement: string) {
|
||||||
},
|
return str.slice(0, index) + replacement + str.slice(index + replacement.length)
|
||||||
findNthIndex(str, n) {
|
}
|
||||||
|
|
||||||
|
function findNthIndex(str: string, n: number) {
|
||||||
const checkboxes = findCheckboxesInText(str)
|
const checkboxes = findCheckboxesInText(str)
|
||||||
return checkboxes[n]
|
return checkboxes[n]
|
||||||
},
|
|
||||||
renderPreview() {
|
|
||||||
const renderer = new marked.Renderer()
|
|
||||||
const linkRenderer = renderer.link
|
|
||||||
|
|
||||||
let checkboxNum = -1
|
|
||||||
marked.use({
|
|
||||||
renderer: {
|
|
||||||
image: (src, title, text) => {
|
|
||||||
|
|
||||||
title = title ? ` title="${title}` : ''
|
|
||||||
|
|
||||||
// If the url starts with the api url, the image is likely an attachment and
|
|
||||||
// we'll need to download and parse it properly.
|
|
||||||
if (src.substr(0, window.API_URL.length + 7) === `${window.API_URL}/tasks/`) {
|
|
||||||
return `<img data-src="${src}" alt="${text}" ${title} class="attachment-image"/>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<img src="${src}" alt="${text}" ${title}/>`
|
function renderPreview() {
|
||||||
},
|
setupMarkdownRenderer(checkboxId.value)
|
||||||
checkbox: (checked) => {
|
|
||||||
if (checked) {
|
|
||||||
checked = ' checked="checked"'
|
|
||||||
}
|
|
||||||
|
|
||||||
checkboxNum++
|
preview.value = DOMPurify.sanitize(marked(text.value), {ADD_ATTR: ['target']})
|
||||||
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this.checkboxId}"/>`
|
|
||||||
},
|
|
||||||
link: (href, title, text) => {
|
|
||||||
const isLocal = href.startsWith(`${location.protocol}//${location.hostname}`)
|
|
||||||
const html = linkRenderer.call(renderer, href, title, text)
|
|
||||||
return isLocal ? html : html.replace(/^<a /, '<a target="_blank" rel="noreferrer noopener nofollow" ')
|
|
||||||
},
|
|
||||||
},
|
|
||||||
highlight: function (code, language) {
|
|
||||||
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext'
|
|
||||||
return hljs.highlight(code, {language: validLanguage}).value
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
this.preview = DOMPurify.sanitize(marked(this.text), {ADD_ATTR: ['target']})
|
|
||||||
|
|
||||||
// Since the render function is synchronous, we can't do async http requests in it.
|
// Since the render function is synchronous, we can't do async http requests in it.
|
||||||
// Therefore, we can't resolve the blob url at (markdown) compile time.
|
// Therefore, we can't resolve the blob url at (markdown) compile time.
|
||||||
|
@ -245,78 +241,70 @@ export default defineComponent({
|
||||||
// dom tree. If we're calling this right after setting this.preview it could be the images were
|
// dom tree. If we're calling this right after setting this.preview it could be the images were
|
||||||
// not already made available.
|
// not already made available.
|
||||||
// Some docs at https://stackoverflow.com/q/62865160/10924593
|
// Some docs at https://stackoverflow.com/q/62865160/10924593
|
||||||
this.$nextTick(async () => {
|
nextTick().then(async () => {
|
||||||
const attachmentImage = document.getElementsByClassName('attachment-image')
|
const attachmentImage = document.querySelectorAll<HTMLImageElement>('.attachment-image')
|
||||||
if (attachmentImage) {
|
if (attachmentImage) {
|
||||||
for (const img of attachmentImage) {
|
Array.from(attachmentImage).forEach(async (img) => {
|
||||||
// The url is something like /tasks/<id>/attachments/<id>
|
// The url is something like /tasks/<id>/attachments/<id>
|
||||||
const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/')
|
const parts = img.dataset.src?.slice(window.API_URL.length + 1).split('/')
|
||||||
const taskId = parseInt(parts[1])
|
const taskId = Number(parts[1])
|
||||||
const attachmentId = parseInt(parts[3])
|
const attachmentId = Number(parts[3])
|
||||||
const cacheKey = `${taskId}-${attachmentId}`
|
const cacheKey: CacheKey = `${taskId}-${attachmentId}`
|
||||||
|
|
||||||
if (typeof this.loadedAttachments[cacheKey] !== 'undefined') {
|
if (typeof loadedAttachments.value[cacheKey] !== 'undefined') {
|
||||||
img.src = this.loadedAttachments[cacheKey]
|
img.src = loadedAttachments.value[cacheKey]
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const attachment = new AttachmentModel({taskId: taskId, id: attachmentId})
|
const attachment = new AttachmentModel({taskId: taskId, id: attachmentId})
|
||||||
|
|
||||||
if (this.attachmentService === null) {
|
const url = await attachmentService.getBlobUrl(attachment)
|
||||||
this.attachmentService = new AttachmentService()
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = await this.attachmentService.getBlobUrl(attachment)
|
|
||||||
img.src = url
|
img.src = url
|
||||||
this.loadedAttachments[cacheKey] = url
|
loadedAttachments.value[cacheKey] = url
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const textCheckbox = document.getElementsByClassName(`text-checkbox-${this.checkboxId}`)
|
const textCheckbox = document.querySelectorAll<HTMLInputElement>(`.text-checkbox-${checkboxId.value}`)
|
||||||
if (textCheckbox) {
|
if (textCheckbox) {
|
||||||
for (const check of textCheckbox) {
|
Array.from(textCheckbox).forEach(check => {
|
||||||
check.removeEventListener('change', this.handleCheckboxClick)
|
check.removeEventListener('change', handleCheckboxClick)
|
||||||
check.addEventListener('change', this.handleCheckboxClick)
|
check.addEventListener('change', handleCheckboxClick)
|
||||||
check.parentElement.classList.add('has-checkbox')
|
check.parentElement?.classList.add('has-checkbox')
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
handleCheckboxClick(e) {
|
|
||||||
// Find the original markdown checkbox this is targeting
|
|
||||||
const checked = e.target.checked
|
|
||||||
const numMarkdownCheck = parseInt(e.target.dataset.checkboxNum)
|
|
||||||
|
|
||||||
const index = this.findNthIndex(this.text, numMarkdownCheck)
|
function handleCheckboxClick(e: Event) {
|
||||||
|
// Find the original markdown checkbox this is targeting
|
||||||
|
const checked = (e.target as HTMLInputElement).checked
|
||||||
|
const numMarkdownCheck = Number((e.target as HTMLInputElement).dataset.checkboxNum)
|
||||||
|
|
||||||
|
const index = findNthIndex(text.value, numMarkdownCheck)
|
||||||
if (index < 0 || typeof index === 'undefined') {
|
if (index < 0 || typeof index === 'undefined') {
|
||||||
console.debug('no index found')
|
console.debug('no index found')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.debug(index, this.text.substr(index, 9))
|
console.debug(index, text.value.slice(index, 9))
|
||||||
|
|
||||||
const listPrefix = this.text.substr(index, 1)
|
const listPrefix = text.value.slice(index, 1)
|
||||||
|
|
||||||
if (checked) {
|
text.value = replaceAt(text.value, index, `${listPrefix} ${checked ? '[x]' : '[ ]'} `)
|
||||||
this.text = this.replaceAt(this.text, index, `${listPrefix} [x] `)
|
bubble()
|
||||||
} else {
|
renderPreview()
|
||||||
this.text = this.replaceAt(this.text, index, `${listPrefix} [ ] `)
|
|
||||||
}
|
}
|
||||||
this.bubble()
|
|
||||||
this.renderPreview()
|
function toggleEdit() {
|
||||||
},
|
if (isEditActive.value) {
|
||||||
toggleEdit() {
|
isPreviewActive.value = true
|
||||||
if (this.isEditActive) {
|
isEditActive.value = false
|
||||||
this.isPreviewActive = true
|
renderPreview()
|
||||||
this.isEditActive = false
|
bubble(0) // save instantly
|
||||||
this.renderPreview()
|
|
||||||
this.bubble(0) // save instantly
|
|
||||||
} else {
|
} else {
|
||||||
this.isPreviewActive = false
|
isPreviewActive.value = false
|
||||||
this.isEditActive = true
|
isEditActive.value = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
:checked="checked"
|
:checked="checked"
|
||||||
:disabled="disabled || undefined"
|
:disabled="disabled || undefined"
|
||||||
:id="checkBoxId"
|
:id="checkBoxId"
|
||||||
@change="(event) => updateData(event.target.checked)"
|
@change="(event: Event) => updateData((event.target as HTMLInputElement).checked)"
|
||||||
type="checkbox"/>
|
type="checkbox"
|
||||||
|
/>
|
||||||
<label :for="checkBoxId" class="check">
|
<label :for="checkBoxId" class="check">
|
||||||
<svg height="18px" viewBox="0 0 18 18" width="18px">
|
<svg height="18px" viewBox="0 0 18 18" width="18px">
|
||||||
<path
|
<path
|
||||||
|
@ -19,21 +20,17 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {ref, toRef, watch} from 'vue'
|
||||||
|
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
|
||||||
export default defineComponent({
|
const checked = ref(false)
|
||||||
name: 'fancycheckbox',
|
const checkBoxId = `fancycheckbox_${createRandomID()}`
|
||||||
data() {
|
|
||||||
return {
|
const props = defineProps({
|
||||||
checked: false,
|
|
||||||
checkBoxId: `fancycheckbox_${createRandomID()}`,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
|
@ -41,25 +38,24 @@ export default defineComponent({
|
||||||
required: false,
|
required: false,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
emits: ['update:modelValue', 'change'],
|
|
||||||
watch: {
|
|
||||||
modelValue: {
|
|
||||||
handler(modelValue) {
|
|
||||||
this.checked = modelValue
|
|
||||||
|
|
||||||
},
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
updateData(checked) {
|
|
||||||
this.checked = checked
|
|
||||||
this.$emit('update:modelValue', checked)
|
|
||||||
this.$emit('change', checked)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
const emit = defineEmits(['update:modelValue', 'change'])
|
||||||
|
|
||||||
|
const modelValue = toRef(props, 'modelValue')
|
||||||
|
|
||||||
|
watch(
|
||||||
|
modelValue,
|
||||||
|
newValue => {
|
||||||
|
checked.value = newValue
|
||||||
|
},
|
||||||
|
{immediate: true},
|
||||||
|
)
|
||||||
|
|
||||||
|
function updateData(newChecked: boolean) {
|
||||||
|
checked.value = newChecked
|
||||||
|
emit('update:modelValue', newChecked)
|
||||||
|
emit('change', newChecked)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@
|
||||||
<div class="search-results" :class="{'search-results-inline': inline}" v-if="searchResultsVisible">
|
<div class="search-results" :class="{'search-results-inline': inline}" v-if="searchResultsVisible">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
class="is-fullwidth"
|
class="is-fullwidth"
|
||||||
v-for="(data, key) in filteredSearchResults"
|
v-for="(data, index) in filteredSearchResults"
|
||||||
:key="key"
|
:key="index"
|
||||||
:ref="`result-${key}`"
|
:ref="(el) => setResult(el, index)"
|
||||||
@keydown.up.prevent="() => preSelect(key - 1)"
|
@keydown.up.prevent="() => preSelect(index - 1)"
|
||||||
@keydown.down.prevent="() => preSelect(key + 1)"
|
@keydown.down.prevent="() => preSelect(index + 1)"
|
||||||
@click.prevent.stop="() => select(data)"
|
@click.prevent.stop="() => select(data)"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="creatableAvailable"
|
v-if="creatableAvailable"
|
||||||
class="is-fullwidth"
|
class="is-fullwidth"
|
||||||
:ref="`result-${filteredSearchResults.length}`"
|
:ref="(el) => setResult(el, filteredSearchResults.length)"
|
||||||
@keydown.up.prevent="() => preSelect(filteredSearchResults.length - 1)"
|
@keydown.up.prevent="() => preSelect(filteredSearchResults.length - 1)"
|
||||||
@keydown.down.prevent="() => preSelect(filteredSearchResults.length + 1)"
|
@keydown.down.prevent="() => preSelect(filteredSearchResults.length + 1)"
|
||||||
@keyup.enter.prevent="create"
|
@keyup.enter.prevent="create"
|
||||||
|
@ -82,9 +82,10 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {computed, onBeforeUnmount, onMounted, ref, toRefs, watch, type ComponentPublicInstance, type PropType} from 'vue'
|
||||||
import {i18n} from '@/i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
@ -98,55 +99,31 @@ function elementInResults(elem: string | any, label: string, query: string): boo
|
||||||
return elem === query
|
return elem === query
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'multiselect',
|
|
||||||
components: {
|
|
||||||
BaseButton,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
query: '',
|
|
||||||
searchTimeout: null,
|
|
||||||
localLoading: false,
|
|
||||||
showSearchResults: false,
|
|
||||||
internalValue: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
// When true, shows a loading spinner
|
// When true, shows a loading spinner
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default() {
|
default: false,
|
||||||
return false
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// The placeholder of the search input
|
// The placeholder of the search input
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default: '',
|
||||||
return ''
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// The search results where the @search listener needs to put the results into
|
// The search results where the @search listener needs to put the results into
|
||||||
searchResults: {
|
searchResults: {
|
||||||
type: Array,
|
type: Array as PropType<{[id: string]: any}>,
|
||||||
default() {
|
default: () => [],
|
||||||
return []
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// The name of the property of the searched object to show the user.
|
// The name of the property of the searched object to show the user.
|
||||||
// If empty the component will show all raw data of an entry.
|
// If empty the component will show all raw data of an entry.
|
||||||
label: {
|
label: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default: '',
|
||||||
return ''
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// The object with the value, updated every time an entry is selected.
|
// The object with the value, updated every time an entry is selected.
|
||||||
modelValue: {
|
modelValue: {
|
||||||
default() {
|
default: null,
|
||||||
return null
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// If true, will provide an "add this as a new value" entry which fires an @create event when clicking on it.
|
// If true, will provide an "add this as a new value" entry which fires an @create event when clicking on it.
|
||||||
creatable: {
|
creatable: {
|
||||||
|
@ -157,14 +134,16 @@ export default defineComponent({
|
||||||
createPlaceholder: {
|
createPlaceholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default() {
|
||||||
return i18n.global.t('input.multiselect.createPlaceholder')
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
return t('input.multiselect.createPlaceholder')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// The text shown next to an option.
|
// The text shown next to an option.
|
||||||
selectPlaceholder: {
|
selectPlaceholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default() {
|
||||||
return i18n.global.t('input.multiselect.selectPlaceholder')
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
return t('input.multiselect.selectPlaceholder')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// If true, allows for selecting multiple items. v-model will be an array with all selected values in that case.
|
// If true, allows for selecting multiple items. v-model will be an array with all selected values in that case.
|
||||||
|
@ -185,136 +164,151 @@ export default defineComponent({
|
||||||
// The delay in ms after which the search event will be fired. Used to avoid hitting the network on every keystroke.
|
// The delay in ms after which the search event will be fired. Used to avoid hitting the network on every keystroke.
|
||||||
searchDelay: {
|
searchDelay: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default() {
|
default: 200,
|
||||||
return 200
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
closeAfterSelect: {
|
closeAfterSelect: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
|
|
||||||
/**
|
const emit = defineEmits<{
|
||||||
* Available events:
|
(e: 'update:modelValue', value: null): void
|
||||||
* @search: Triggered every time the search query input changes
|
// @search: Triggered every time the search query input changes
|
||||||
* @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
|
(e: 'search', query: string): void
|
||||||
* @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
|
// @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
|
||||||
* @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
|
(e: 'select', value: null): void
|
||||||
*/
|
// @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
|
||||||
emits: ['update:modelValue', 'search', 'select', 'create', 'remove'],
|
(e: 'create', query: string): void
|
||||||
|
// @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
|
||||||
|
(e: 'remove', value: null): void
|
||||||
|
}>()
|
||||||
|
|
||||||
mounted() {
|
const query = ref('')
|
||||||
document.addEventListener('click', this.hideSearchResultsHandler)
|
const searchTimeout = ref<ReturnType<typeof setTimeout> | null>(null)
|
||||||
},
|
const localLoading = ref(false)
|
||||||
beforeUnmount() {
|
const showSearchResults = ref(false)
|
||||||
document.removeEventListener('click', this.hideSearchResultsHandler)
|
const internalValue = ref<string | {[key: string]: any} | any[] | null>(null)
|
||||||
},
|
|
||||||
watch: {
|
onMounted(() => document.addEventListener('click', hideSearchResultsHandler))
|
||||||
modelValue: {
|
onBeforeUnmount(() => document.removeEventListener('click', hideSearchResultsHandler))
|
||||||
handler(value) {
|
|
||||||
this.setSelectedObject(value)
|
const {modelValue, searchResults} = toRefs(props)
|
||||||
},
|
|
||||||
|
watch(
|
||||||
|
modelValue,
|
||||||
|
(value) => setSelectedObject(value),
|
||||||
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
},
|
)
|
||||||
computed: {
|
|
||||||
searchResultsVisible() {
|
const searchResultsVisible = computed(() => {
|
||||||
if (this.query === '' && !this.showEmpty) {
|
if (query.value === '' && !props.showEmpty) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.showSearchResults && (
|
return showSearchResults.value && (
|
||||||
(this.filteredSearchResults.length > 0) ||
|
(filteredSearchResults.value.length > 0) ||
|
||||||
(this.creatable && this.query !== '')
|
(props.creatable && query.value !== '')
|
||||||
)
|
)
|
||||||
},
|
})
|
||||||
creatableAvailable() {
|
|
||||||
const hasResult = this.filteredSearchResults.some(elem => elementInResults(elem, this.label, this.query))
|
|
||||||
const hasQueryAlreadyAdded = Array.isArray(this.internalValue) && this.internalValue.some(elem => elementInResults(elem, this.label, this.query))
|
|
||||||
|
|
||||||
return this.creatable
|
const creatableAvailable = computed(() => {
|
||||||
&& this.query !== ''
|
const hasResult = filteredSearchResults.value.some((elem: any) => elementInResults(elem, props.label, query.value))
|
||||||
|
const hasQueryAlreadyAdded = Array.isArray(internalValue.value) && internalValue.value.some(elem => elementInResults(elem, props.label, query.value))
|
||||||
|
|
||||||
|
return props.creatable
|
||||||
|
&& query.value !== ''
|
||||||
&& !(hasResult || hasQueryAlreadyAdded)
|
&& !(hasResult || hasQueryAlreadyAdded)
|
||||||
},
|
})
|
||||||
filteredSearchResults() {
|
|
||||||
if (this.multiple && this.internalValue !== null && Array.isArray(this.internalValue)) {
|
const filteredSearchResults = computed(() => {
|
||||||
return this.searchResults.filter(item => !this.internalValue.some(e => e === item))
|
const currentInternal = internalValue.value
|
||||||
|
if (props.multiple && currentInternal !== null && Array.isArray(currentInternal)) {
|
||||||
|
return searchResults.value.filter((item: any) => !currentInternal.some(e => e === item))
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.searchResults
|
return searchResults.value
|
||||||
},
|
})
|
||||||
hasMultiple() {
|
|
||||||
return this.multiple && Array.isArray(this.internalValue) && this.internalValue.length > 0
|
const hasMultiple = computed(() => {
|
||||||
},
|
return props.multiple && Array.isArray(internalValue.value) && internalValue.value.length > 0
|
||||||
},
|
})
|
||||||
methods: {
|
|
||||||
|
const searchInput = ref<HTMLInputElement | null>(null)
|
||||||
// Searching will be triggered with a 200ms delay to avoid searching on every keyup event.
|
// Searching will be triggered with a 200ms delay to avoid searching on every keyup event.
|
||||||
search() {
|
function search() {
|
||||||
|
|
||||||
// Updating the query with a binding does not work on mobile for some reason,
|
// Updating the query with a binding does not work on mobile for some reason,
|
||||||
// getting the value manual does.
|
// getting the value manual does.
|
||||||
this.query = this.$refs.searchInput.value
|
query.value = searchInput.value?.value || ''
|
||||||
|
|
||||||
if (this.searchTimeout !== null) {
|
if (searchTimeout.value !== null) {
|
||||||
clearTimeout(this.searchTimeout)
|
clearTimeout(searchTimeout.value)
|
||||||
this.searchTimeout = null
|
searchTimeout.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
this.localLoading = true
|
localLoading.value = true
|
||||||
|
|
||||||
this.searchTimeout = setTimeout(() => {
|
searchTimeout.value = setTimeout(() => {
|
||||||
this.$emit('search', this.query)
|
emit('search', query.value)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.localLoading = false
|
localLoading.value = false
|
||||||
}, 100) // The duration of the loading timeout of the services
|
}, 100) // The duration of the loading timeout of the services
|
||||||
this.showSearchResults = true
|
showSearchResults.value = true
|
||||||
}, this.searchDelay)
|
}, props.searchDelay)
|
||||||
},
|
}
|
||||||
hideSearchResultsHandler(e) {
|
|
||||||
closeWhenClickedOutside(e, this.$refs.multiselectRoot, this.closeSearchResults)
|
const multiselectRoot = ref<HTMLElement | null>(null)
|
||||||
},
|
function hideSearchResultsHandler(e: MouseEvent) {
|
||||||
closeSearchResults() {
|
closeWhenClickedOutside(e, multiselectRoot.value, closeSearchResults)
|
||||||
this.showSearchResults = false
|
}
|
||||||
},
|
|
||||||
handleFocus() {
|
function closeSearchResults() {
|
||||||
|
showSearchResults.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFocus() {
|
||||||
// We need the timeout to avoid the hideSearchResultsHandler hiding the search results right after the input
|
// We need the timeout to avoid the hideSearchResultsHandler hiding the search results right after the input
|
||||||
// is focused. That would lead to flickering pre-loaded search results and hiding them right after showing.
|
// is focused. That would lead to flickering pre-loaded search results and hiding them right after showing.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.showSearchResults = true
|
showSearchResults.value = true
|
||||||
}, 10)
|
}, 10)
|
||||||
},
|
|
||||||
select(object) {
|
|
||||||
if (this.multiple) {
|
|
||||||
if (this.internalValue === null) {
|
|
||||||
this.internalValue = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.internalValue.push(object)
|
function select(object: {[key: string]: any}) {
|
||||||
|
if (props.multiple) {
|
||||||
|
if (internalValue.value === null) {
|
||||||
|
internalValue.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
(internalValue.value as any[]).push(object)
|
||||||
} else {
|
} else {
|
||||||
this.internalValue = object
|
internalValue.value = object
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.internalValue)
|
emit('update:modelValue', internalValue.value)
|
||||||
this.$emit('select', object)
|
emit('select', object)
|
||||||
this.setSelectedObject(object)
|
setSelectedObject(object)
|
||||||
if (this.closeAfterSelect && this.filteredSearchResults.length > 0 && !this.creatableAvailable) {
|
if (props.closeAfterSelect && filteredSearchResults.value.length > 0 && !creatableAvailable.value) {
|
||||||
this.closeSearchResults()
|
closeSearchResults()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
setSelectedObject(object, resetOnly = false) {
|
|
||||||
this.internalValue = object
|
function setSelectedObject(object: string | {[id: string]: any} | null, resetOnly = false) {
|
||||||
|
internalValue.value = object
|
||||||
|
|
||||||
// We assume we're getting an array when multiple is enabled and can therefore leave the query
|
// We assume we're getting an array when multiple is enabled and can therefore leave the query
|
||||||
// value etc as it is
|
// value etc as it is
|
||||||
if (this.multiple) {
|
if (props.multiple) {
|
||||||
this.query = ''
|
query.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object === null) {
|
if (object === null) {
|
||||||
this.query = ''
|
query.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,15 +316,25 @@ export default defineComponent({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.query = this.label !== '' ? object[this.label] : object
|
query.value = props.label !== '' ? object[props.label] : object
|
||||||
},
|
}
|
||||||
preSelect(index) {
|
|
||||||
|
const results = ref<(Element | ComponentPublicInstance)[]>([])
|
||||||
|
function setResult(el: Element | ComponentPublicInstance | null, index: number) {
|
||||||
|
if (el === null) {
|
||||||
|
delete results.value[index]
|
||||||
|
} else {
|
||||||
|
results.value[index] = el
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function preSelect(index: number) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
this.$refs.searchInput.focus()
|
searchInput.value?.focus()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const elems = this.$refs[`result-${index}`]
|
const elems = results.value[index]
|
||||||
if (typeof elems === 'undefined' || elems.length === 0) {
|
if (typeof elems === 'undefined' || elems.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -341,51 +345,52 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
elems.focus()
|
elems.focus()
|
||||||
},
|
}
|
||||||
create() {
|
|
||||||
if (this.query === '') {
|
function create() {
|
||||||
|
if (query.value === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('create', this.query)
|
emit('create', query.value)
|
||||||
this.setSelectedObject(this.query, true)
|
setSelectedObject(query.value, true)
|
||||||
this.closeSearchResults()
|
closeSearchResults()
|
||||||
},
|
}
|
||||||
createOrSelectOnEnter() {
|
|
||||||
|
|
||||||
if (!this.creatableAvailable && this.searchResults.length === 1) {
|
function createOrSelectOnEnter() {
|
||||||
this.select(this.searchResults[0])
|
if (!creatableAvailable.value && searchResults.value.length === 1) {
|
||||||
|
select(searchResults.value[0])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.creatableAvailable) {
|
if (!creatableAvailable.value) {
|
||||||
// Check if there's an exact match for our search term
|
// Check if there's an exact match for our search term
|
||||||
const exactMatch = this.filteredSearchResults.find(elem => elementInResults(elem, this.label, this.query))
|
const exactMatch = filteredSearchResults.value.find((elem: any) => elementInResults(elem, props.label, query.value))
|
||||||
if(exactMatch) {
|
if(exactMatch) {
|
||||||
this.select(exactMatch)
|
select(exactMatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.create()
|
create()
|
||||||
},
|
}
|
||||||
remove(item) {
|
|
||||||
for (const ind in this.internalValue) {
|
function remove(item: any) {
|
||||||
if (this.internalValue[ind] === item) {
|
for (const ind in internalValue.value) {
|
||||||
this.internalValue.splice(ind, 1)
|
if (internalValue.value[ind] === item) {
|
||||||
|
internalValue.value.splice(ind, 1)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.internalValue)
|
emit('update:modelValue', internalValue.value)
|
||||||
this.$emit('remove', item)
|
emit('remove', item)
|
||||||
},
|
}
|
||||||
focus() {
|
|
||||||
this.$refs.searchInput.focus()
|
function focus() {
|
||||||
},
|
searchInput.value?.focus()
|
||||||
},
|
}
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<dropdown>
|
<dropdown>
|
||||||
<template v-if="isSavedFilter">
|
<template v-if="isSavedFilter(list)">
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
:to="{ name: 'filter.settings.edit', params: { listId: list.id } }"
|
:to="{ name: 'filter.settings.edit', params: { listId: list.id } }"
|
||||||
icon="pen"
|
icon="pen"
|
||||||
|
@ -55,13 +55,13 @@
|
||||||
>
|
>
|
||||||
{{ $t('menu.archive') }}
|
{{ $t('menu.archive') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<task-subscription
|
<Subscription
|
||||||
class="has-no-shadow"
|
class="has-no-shadow"
|
||||||
:is-button="false"
|
:is-button="false"
|
||||||
entity="list"
|
entity="list"
|
||||||
:entity-id="list.id"
|
:entity-id="list.id"
|
||||||
:subscription="list.subscription"
|
:model-value="list.subscription"
|
||||||
@change="sub => subscription = sub"
|
@update:model-value="setSubscriptionInStore"
|
||||||
type="dropdown"
|
type="dropdown"
|
||||||
/>
|
/>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
|
@ -76,29 +76,42 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, computed, watchEffect} from 'vue'
|
import {ref, computed, watchEffect, type PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
|
|
||||||
import {getSavedFilterIdFromListId} from '@/helpers/savedFilter'
|
import {isSavedFilter} from '@/helpers/savedFilter'
|
||||||
import Dropdown from '@/components/misc/dropdown.vue'
|
import Dropdown from '@/components/misc/dropdown.vue'
|
||||||
import DropdownItem from '@/components/misc/dropdown-item.vue'
|
import DropdownItem from '@/components/misc/dropdown-item.vue'
|
||||||
import TaskSubscription from '@/components/misc/subscription.vue'
|
import Subscription from '@/components/misc/subscription.vue'
|
||||||
import ListModel from '@/models/list'
|
import type {IList} from '@/modelTypes/IList'
|
||||||
import SubscriptionModel from '@/models/subscription'
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
||||||
|
import {useConfigStore} from '@/stores/config'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
type: ListModel,
|
type: Object as PropType<IList>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const subscription = ref<SubscriptionModel | null>(null)
|
const listStore = useListStore()
|
||||||
|
const namespaceStore = useNamespaceStore()
|
||||||
|
const subscription = ref<ISubscription | null>(null)
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
subscription.value = props.list.subscription ?? null
|
subscription.value = props.list.subscription ?? null
|
||||||
})
|
})
|
||||||
|
|
||||||
const store = useStore()
|
const configStore = useConfigStore()
|
||||||
const backgroundsEnabled = computed(() => store.state.config.enabledBackgroundProviders?.length > 0)
|
const backgroundsEnabled = computed(() => configStore.enabledBackgroundProviders?.length > 0)
|
||||||
const isSavedFilter = computed(() => getSavedFilterIdFromListId(props.list.id) > 0)
|
|
||||||
|
function setSubscriptionInStore(sub: ISubscription) {
|
||||||
|
subscription.value = sub
|
||||||
|
const updatedList = {
|
||||||
|
...props.list,
|
||||||
|
subscription: sub,
|
||||||
|
}
|
||||||
|
listStore.setList(updatedList)
|
||||||
|
namespaceStore.setListInNamespaceById(updatedList)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -29,37 +29,41 @@
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent, ref} from 'vue'
|
import {computed, ref, watch} from 'vue'
|
||||||
|
|
||||||
import Filters from '@/components/list/partials/filters.vue'
|
import Filters from '@/components/list/partials/filters.vue'
|
||||||
|
|
||||||
import {getDefaultParams} from '@/composables/taskList'
|
import {getDefaultParams} from '@/composables/taskList'
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'filter-popup',
|
|
||||||
components: {
|
|
||||||
Filters,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
modelValue: {
|
modelValue: {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
emits: ['update:modelValue'],
|
const emit = defineEmits(['update:modelValue'])
|
||||||
computed: {
|
|
||||||
value: {
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return this.modelValue
|
return props.modelValue
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(modelValue) => {
|
||||||
|
value.value = modelValue
|
||||||
},
|
},
|
||||||
hasFilters() {
|
{immediate: true},
|
||||||
|
)
|
||||||
|
|
||||||
|
const hasFilters = computed(() => {
|
||||||
// this.value also contains the page parameter which we don't want to include in filters
|
// this.value also contains the page parameter which we don't want to include in filters
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const {filter_by, filter_value, filter_comparator, filter_concat, s} = this.value
|
const {filter_by, filter_value, filter_comparator, filter_concat, s} = value.value
|
||||||
const def = {...getDefaultParams()}
|
const def = {...getDefaultParams()}
|
||||||
|
|
||||||
const params = {filter_by, filter_value, filter_comparator, filter_concat, s}
|
const params = {filter_by, filter_value, filter_comparator, filter_concat, s}
|
||||||
|
@ -72,29 +76,13 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(params) !== JSON.stringify(defaultParams)
|
return JSON.stringify(params) !== JSON.stringify(defaultParams)
|
||||||
},
|
})
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
modelValue: {
|
|
||||||
handler(value) {
|
|
||||||
this.value = value
|
|
||||||
},
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const modalOpen = ref(false)
|
const modalOpen = ref(false)
|
||||||
|
|
||||||
return {
|
function clearFilters() {
|
||||||
modalOpen,
|
value.value = {...getDefaultParams()}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
clearFilters() {
|
|
||||||
this.value = {...getDefaultParams()}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<card class="filters has-overflow" :title="hasTitle ? $t('filters.title') : ''">
|
<card class="filters has-overflow" :title="hasTitle ? $t('filters.title') : ''">
|
||||||
<div class="field">
|
<div class="field is-flex is-flex-direction-column">
|
||||||
<fancycheckbox v-model="params.filter_include_nulls">
|
<fancycheckbox
|
||||||
|
v-model="params.filter_include_nulls"
|
||||||
|
@update:model-value="change()"
|
||||||
|
>
|
||||||
{{ $t('filters.attributes.includeNulls') }}
|
{{ $t('filters.attributes.includeNulls') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
<fancycheckbox
|
<fancycheckbox
|
||||||
v-model="filters.requireAllFilters"
|
v-model="filters.requireAllFilters"
|
||||||
@change="setFilterConcat()"
|
@update:model-value="setFilterConcat()"
|
||||||
>
|
>
|
||||||
{{ $t('filters.attributes.requireAll') }}
|
{{ $t('filters.attributes.requireAll') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
<fancycheckbox @change="setDoneFilter" v-model="filters.done">
|
<fancycheckbox v-model="filters.done" @update:model-value="setDoneFilter">
|
||||||
{{ $t('filters.attributes.showDoneTasks') }}
|
{{ $t('filters.attributes.showDoneTasks') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
<fancycheckbox
|
<fancycheckbox
|
||||||
v-if="!$route.name.includes('list.kanban') || !$route.name.includes('list.table')"
|
v-if="!$route.name.includes('list.kanban') || !$route.name.includes('list.table')"
|
||||||
v-model="sortAlphabetically"
|
v-model="sortAlphabetically"
|
||||||
|
@update:model-value="change()"
|
||||||
>
|
>
|
||||||
{{ $t('filters.attributes.sortAlphabetically') }}
|
{{ $t('filters.attributes.sortAlphabetically') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
|
@ -38,11 +42,11 @@
|
||||||
<priority-select
|
<priority-select
|
||||||
:disabled="!filters.usePriority || undefined"
|
:disabled="!filters.usePriority || undefined"
|
||||||
v-model.number="filters.priority"
|
v-model.number="filters.priority"
|
||||||
@change="setPriority"
|
@update:model-value="setPriority"
|
||||||
/>
|
/>
|
||||||
<fancycheckbox
|
<fancycheckbox
|
||||||
v-model="filters.usePriority"
|
v-model="filters.usePriority"
|
||||||
@change="setPriority"
|
@update:model-value="setPriority"
|
||||||
>
|
>
|
||||||
{{ $t('filters.attributes.enablePriority') }}
|
{{ $t('filters.attributes.enablePriority') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
|
@ -53,12 +57,12 @@
|
||||||
<div class="control single-value-control">
|
<div class="control single-value-control">
|
||||||
<percent-done-select
|
<percent-done-select
|
||||||
v-model.number="filters.percentDone"
|
v-model.number="filters.percentDone"
|
||||||
@change="setPercentDoneFilter"
|
@update:model-value="setPercentDoneFilter"
|
||||||
:disabled="!filters.usePercentDone || undefined"
|
:disabled="!filters.usePercentDone || undefined"
|
||||||
/>
|
/>
|
||||||
<fancycheckbox
|
<fancycheckbox
|
||||||
v-model="filters.usePercentDone"
|
v-model="filters.usePercentDone"
|
||||||
@change="setPercentDoneFilter"
|
@update:model-value="setPercentDoneFilter"
|
||||||
>
|
>
|
||||||
{{ $t('filters.attributes.enablePercentDone') }}
|
{{ $t('filters.attributes.enablePercentDone') }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
|
@ -68,8 +72,9 @@
|
||||||
<label class="label">{{ $t('task.attributes.dueDate') }}</label>
|
<label class="label">{{ $t('task.attributes.dueDate') }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<datepicker-with-range
|
<datepicker-with-range
|
||||||
@dateChanged="values => setDateFilter('due_date', values)"
|
v-model="filters.dueDate"
|
||||||
v-model="filters.dueDate">
|
@update:model-value="values => setDateFilter('due_date', values)"
|
||||||
|
>
|
||||||
<template #trigger="{toggle, buttonText}">
|
<template #trigger="{toggle, buttonText}">
|
||||||
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
|
@ -82,8 +87,9 @@
|
||||||
<label class="label">{{ $t('task.attributes.startDate') }}</label>
|
<label class="label">{{ $t('task.attributes.startDate') }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<datepicker-with-range
|
<datepicker-with-range
|
||||||
@dateChanged="values => setDateFilter('start_date', values)"
|
v-model="filters.startDate"
|
||||||
v-model="filters.startDate">
|
@update:model-value="values => setDateFilter('start_date', values)"
|
||||||
|
>
|
||||||
<template #trigger="{toggle, buttonText}">
|
<template #trigger="{toggle, buttonText}">
|
||||||
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
|
@ -96,8 +102,9 @@
|
||||||
<label class="label">{{ $t('task.attributes.endDate') }}</label>
|
<label class="label">{{ $t('task.attributes.endDate') }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<datepicker-with-range
|
<datepicker-with-range
|
||||||
@dateChanged="values => setDateFilter('end_date', values)"
|
v-model="filters.endDate"
|
||||||
v-model="filters.endDate">
|
@update:model-value="values => setDateFilter('end_date', values)"
|
||||||
|
>
|
||||||
<template #trigger="{toggle, buttonText}">
|
<template #trigger="{toggle, buttonText}">
|
||||||
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
|
@ -110,8 +117,9 @@
|
||||||
<label class="label">{{ $t('task.attributes.reminders') }}</label>
|
<label class="label">{{ $t('task.attributes.reminders') }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<datepicker-with-range
|
<datepicker-with-range
|
||||||
@dateChanged="values => setDateFilter('reminders', values)"
|
v-model="filters.reminders"
|
||||||
v-model="filters.reminders">
|
@update:model-value="values => setDateFilter('reminders', values)"
|
||||||
|
>
|
||||||
<template #trigger="{toggle, buttonText}">
|
<template #trigger="{toggle, buttonText}">
|
||||||
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
|
@ -141,7 +149,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">{{ $t('task.attributes.labels') }}</label>
|
<label class="label">{{ $t('task.attributes.labels') }}</label>
|
||||||
<div class="control labels-list">
|
<div class="control labels-list">
|
||||||
<edit-labels v-model="labels" @change="changeLabelFilter"/>
|
<edit-labels v-model="labels" @update:model-value="changeLabelFilter"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -186,8 +194,10 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {defineComponent} from 'vue'
|
||||||
|
|
||||||
import DatepickerWithRange from '@/components/date/datepickerWithRange'
|
import {useLabelStore} from '@/stores/labels'
|
||||||
import Fancycheckbox from '../../input/fancycheckbox'
|
|
||||||
|
import DatepickerWithRange from '@/components/date/datepickerWithRange.vue'
|
||||||
|
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
|
||||||
|
|
||||||
import {includesById} from '@/helpers/utils'
|
import {includesById} from '@/helpers/utils'
|
||||||
import PrioritySelect from '@/components/tasks/partials/prioritySelect.vue'
|
import PrioritySelect from '@/components/tasks/partials/prioritySelect.vue'
|
||||||
|
@ -200,6 +210,7 @@ import ListService from '@/services/list'
|
||||||
import NamespaceService from '@/services/namespace'
|
import NamespaceService from '@/services/namespace'
|
||||||
import EditLabels from '@/components/tasks/partials/editLabels.vue'
|
import EditLabels from '@/components/tasks/partials/editLabels.vue'
|
||||||
|
|
||||||
|
import {dateIsValid, formatISO} from '@/helpers/time/formatDate'
|
||||||
import {objectToSnakeCase} from '@/helpers/case'
|
import {objectToSnakeCase} from '@/helpers/case'
|
||||||
import {getDefaultParams} from '@/composables/taskList'
|
import {getDefaultParams} from '@/composables/taskList'
|
||||||
import {camelCase} from 'camel-case'
|
import {camelCase} from 'camel-case'
|
||||||
|
@ -278,7 +289,7 @@ export default defineComponent({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue', 'change'],
|
emits: ['update:modelValue'],
|
||||||
watch: {
|
watch: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
handler(value) {
|
handler(value) {
|
||||||
|
@ -303,8 +314,10 @@ export default defineComponent({
|
||||||
this.change()
|
this.change()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
foundLabels() {
|
foundLabels() {
|
||||||
return this.$store.getters['labels/filterLabelsByQuery'](this.labels, this.query)
|
const labelStore = useLabelStore()
|
||||||
|
return labelStore.filterLabelsByQuery(this.labels, this.labelQuery)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -312,7 +325,6 @@ export default defineComponent({
|
||||||
const params = {...this.params}
|
const params = {...this.params}
|
||||||
params.filter_value = params.filter_value.map(v => v instanceof Date ? v.toISOString() : v)
|
params.filter_value = params.filter_value.map(v => v instanceof Date ? v.toISOString() : v)
|
||||||
this.$emit('update:modelValue', params)
|
this.$emit('update:modelValue', params)
|
||||||
this.$emit('change', params)
|
|
||||||
},
|
},
|
||||||
prepareFilters() {
|
prepareFilters() {
|
||||||
this.prepareDone()
|
this.prepareDone()
|
||||||
|
@ -333,7 +345,8 @@ export default defineComponent({
|
||||||
: ''
|
: ''
|
||||||
const labelIds = labels.split(',').map(i => parseInt(i))
|
const labelIds = labels.split(',').map(i => parseInt(i))
|
||||||
|
|
||||||
this.labels = this.$store.getters['labels/getLabelsByIds'](labelIds)
|
const labelStore = useLabelStore()
|
||||||
|
this.labels = labelStore.getLabelsByIds(labelIds)
|
||||||
},
|
},
|
||||||
removePropertyFromFilter(propertyName) {
|
removePropertyFromFilter(propertyName) {
|
||||||
// Because of the way arrays work, we can only ever remove one element at once.
|
// Because of the way arrays work, we can only ever remove one element at once.
|
||||||
|
@ -379,7 +392,14 @@ export default defineComponent({
|
||||||
this.params.filter_value.push(dateTo)
|
this.params.filter_value.push(dateTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filters[camelCase(filterName)] = {dateFrom, dateTo}
|
this.filters[camelCase(filterName)] = {
|
||||||
|
// Passing the dates as string values avoids an endless loop between values changing
|
||||||
|
// in the datepicker (bubbling up to here) and changing here and bubbling down to the
|
||||||
|
// datepicker (because there's a new date instance every time this function gets called).
|
||||||
|
// See https://kolaente.dev/vikunja/frontend/issues/2384
|
||||||
|
dateFrom: dateIsValid(dateFrom) ? formatISO(dateFrom) : dateFrom,
|
||||||
|
dateTo: dateIsValid(dateTo) ? formatISO(dateTo) : dateTo,
|
||||||
|
}
|
||||||
this.change()
|
this.change()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -500,6 +520,14 @@ export default defineComponent({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't load things if we already have something loaded.
|
||||||
|
// This is not the most ideal solution because it prevents a re-population when filters are changed
|
||||||
|
// from the outside. It is still fine because we're not changing them from the outside, other than
|
||||||
|
// loading them initially.
|
||||||
|
if (this[kind].length > 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this[kind] = await this[`${servicePrefix}Service`].getAll({}, {s: this.filters[filterName]})
|
this[kind] = await this[`${servicePrefix}Service`].getAll({}, {s: this.filters[filterName]})
|
||||||
},
|
},
|
||||||
setDoneFilter() {
|
setDoneFilter() {
|
||||||
|
@ -518,6 +546,7 @@ export default defineComponent({
|
||||||
} else {
|
} else {
|
||||||
this.params.filter_concat = 'or'
|
this.params.filter_concat = 'or'
|
||||||
}
|
}
|
||||||
|
this.change()
|
||||||
},
|
},
|
||||||
setPriority() {
|
setPriority() {
|
||||||
this.setSingleValueFilter('priority', 'priority', 'usePriority')
|
this.setSingleValueFilter('priority', 'priority', 'usePriority')
|
||||||
|
@ -532,6 +561,7 @@ export default defineComponent({
|
||||||
|
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
this.clear(kind)
|
this.clear(kind)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this[`${kind}Service`].getAll({}, {s: query})
|
const response = await this[`${kind}Service`].getAll({}, {s: query})
|
||||||
|
@ -556,9 +586,9 @@ export default defineComponent({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let ids = []
|
const ids = []
|
||||||
this[kind].forEach(u => {
|
this[kind].forEach(u => {
|
||||||
ids.push(u.id)
|
ids.push(kind === 'users' ? u.username : u.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.filters[filterName] = ids.join(',')
|
this.filters[filterName] = ids.join(',')
|
||||||
|
@ -591,7 +621,7 @@ export default defineComponent({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let labelIDs = []
|
const labelIDs = []
|
||||||
this.labels.forEach(u => {
|
this.labels.forEach(u => {
|
||||||
labelIDs.push(u.id)
|
labelIDs.push(u.id)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<router-link
|
<router-link
|
||||||
:class="{
|
:class="{
|
||||||
'has-light-text': !colorIsDark(list.hexColor),
|
'has-light-text': !colorIsDark(list.hexColor) || background !== null,
|
||||||
'has-background': blurHashUrl !== ''
|
'has-background': blurHashUrl !== '' || background !== null,
|
||||||
}"
|
}"
|
||||||
:style="{
|
:style="{
|
||||||
'background-color': list.hexColor,
|
'background-color': list.hexColor,
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-else
|
v-else
|
||||||
:class="{'is-favorite': list.isFavorite}"
|
:class="{'is-favorite': list.isFavorite}"
|
||||||
@click.stop="toggleFavoriteList(list)"
|
@click.stop="listStore.toggleListFavorite(list)"
|
||||||
class="favorite"
|
class="favorite"
|
||||||
>
|
>
|
||||||
<icon :icon="list.isFavorite ? 'star' : ['far', 'star']"/>
|
<icon :icon="list.isFavorite ? 'star' : ['far', 'star']"/>
|
||||||
|
@ -36,16 +36,16 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {PropType, ref, watch} from 'vue'
|
import {type PropType, ref, watch} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
|
|
||||||
import ListService from '@/services/list'
|
import ListService from '@/services/list'
|
||||||
import {getBlobFromBlurHash} from '@/helpers/getBlobFromBlurHash'
|
import {getBlobFromBlurHash} from '@/helpers/getBlobFromBlurHash'
|
||||||
|
|
||||||
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
||||||
import ListModel from '@/models/list'
|
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
import type {IList} from '@/modelTypes/IList'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
|
||||||
const background = ref<string | null>(null)
|
const background = ref<string | null>(null)
|
||||||
const backgroundLoading = ref(false)
|
const backgroundLoading = ref(false)
|
||||||
|
@ -53,7 +53,7 @@ const blurHashUrl = ref('')
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
type: Object as PropType<ListModel>,
|
type: Object as PropType<IList>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
showArchived: {
|
showArchived: {
|
||||||
|
@ -84,16 +84,7 @@ async function loadBackground() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = useStore()
|
const listStore = useListStore()
|
||||||
|
|
||||||
function toggleFavoriteList(list: ListModel) {
|
|
||||||
// The favorites pseudo list is always favorite
|
|
||||||
// Archived lists cannot be marked favorite
|
|
||||||
if (list.id === -1 || list.isArchived) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
store.dispatch('lists/toggleListFavorite', list)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -110,7 +101,7 @@ function toggleFavoriteList(list: ListModel) {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&.has-light-text .title {
|
&.has-light-text .title {
|
||||||
color: var(--grey-100);
|
color: var(--grey-100) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.has-background,
|
&.has-background,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {PropType} from 'vue'
|
import type {PropType} from 'vue'
|
||||||
type Variants = 'default' | 'small'
|
type Variants = 'default' | 'small'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|
|
@ -11,16 +11,17 @@ import {
|
||||||
faCheckDouble,
|
faCheckDouble,
|
||||||
faChessKnight,
|
faChessKnight,
|
||||||
faChevronDown,
|
faChevronDown,
|
||||||
|
faCircleInfo,
|
||||||
faCloudDownloadAlt,
|
faCloudDownloadAlt,
|
||||||
faCloudUploadAlt,
|
faCloudUploadAlt,
|
||||||
faCocktail,
|
faCocktail,
|
||||||
faCoffee,
|
faCoffee,
|
||||||
faCog,
|
faCog,
|
||||||
faEye,
|
|
||||||
faEyeSlash,
|
|
||||||
faEllipsisH,
|
faEllipsisH,
|
||||||
faEllipsisV,
|
faEllipsisV,
|
||||||
faExclamation,
|
faExclamation,
|
||||||
|
faEye,
|
||||||
|
faEyeSlash,
|
||||||
faFillDrip,
|
faFillDrip,
|
||||||
faFilter,
|
faFilter,
|
||||||
faForward,
|
faForward,
|
||||||
|
@ -82,6 +83,7 @@ library.add(faCheck)
|
||||||
library.add(faCheckDouble)
|
library.add(faCheckDouble)
|
||||||
library.add(faChessKnight)
|
library.add(faChessKnight)
|
||||||
library.add(faChevronDown)
|
library.add(faChevronDown)
|
||||||
|
library.add(faCircleInfo)
|
||||||
library.add(faClock)
|
library.add(faClock)
|
||||||
library.add(faCloudDownloadAlt)
|
library.add(faCloudDownloadAlt)
|
||||||
library.add(faCloudUploadAlt)
|
library.add(faCloudUploadAlt)
|
||||||
|
@ -89,11 +91,11 @@ library.add(faCocktail)
|
||||||
library.add(faCoffee)
|
library.add(faCoffee)
|
||||||
library.add(faCog)
|
library.add(faCog)
|
||||||
library.add(faComments)
|
library.add(faComments)
|
||||||
library.add(faEye)
|
|
||||||
library.add(faEyeSlash)
|
|
||||||
library.add(faEllipsisH)
|
library.add(faEllipsisH)
|
||||||
library.add(faEllipsisV)
|
library.add(faEllipsisV)
|
||||||
library.add(faExclamation)
|
library.add(faExclamation)
|
||||||
|
library.add(faEye)
|
||||||
|
library.add(faEyeSlash)
|
||||||
library.add(faFillDrip)
|
library.add(faFillDrip)
|
||||||
library.add(faFilter)
|
library.add(faFilter)
|
||||||
library.add(faForward)
|
library.add(faForward)
|
|
@ -23,17 +23,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="api-url-info" v-else>
|
<div class="api-url-info" v-else>
|
||||||
<i18n-t keypath="apiConfig.use">
|
<i18n-t keypath="apiConfig.use" scope="global">
|
||||||
<span class="url" v-tooltip="apiUrl"> {{ apiDomain }} </span>
|
<span class="url" v-tooltip="apiUrl"> {{ apiDomain }} </span>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
<br/>
|
<br/>
|
||||||
<ButtonLink class="api-config__change-button" @click="() => (configureApi = true)">{{ $t('apiConfig.change') }}</ButtonLink>
|
<ButtonLink class="api-config__change-button" @click="() => (configureApi = true)">{{ $t('apiConfig.change') }}</ButtonLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<message variant="success" v-if="successMsg !== '' && errorMsg === ''" class="mt-2">
|
<message variant="danger" v-if="errorMsg !== ''" class="mt-2">
|
||||||
{{ successMsg }}
|
|
||||||
</message>
|
|
||||||
<message variant="danger" v-if="errorMsg !== '' && successMsg === ''" class="mt-2">
|
|
||||||
{{ errorMsg }}
|
{{ errorMsg }}
|
||||||
</message>
|
</message>
|
||||||
</div>
|
</div>
|
||||||
|
@ -74,7 +71,6 @@ watch(() => props.configureOpen, (value) => {
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const errorMsg = ref('')
|
const errorMsg = ref('')
|
||||||
const successMsg = ref('')
|
|
||||||
|
|
||||||
async function setApiUrl() {
|
async function setApiUrl() {
|
||||||
if (apiUrl.value === '') {
|
if (apiUrl.value === '') {
|
||||||
|
@ -99,7 +95,6 @@ async function setApiUrl() {
|
||||||
emit('foundApi', apiUrl.value)
|
emit('foundApi', apiUrl.value)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Still not found, url is still invalid
|
// Still not found, url is still invalid
|
||||||
successMsg.value = ''
|
|
||||||
errorMsg.value = t('apiConfig.error', {domain: apiDomain.value})
|
errorMsg.value = t('apiConfig.error', {domain: apiDomain.value})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,21 @@
|
||||||
</span>
|
</span>
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</header>
|
</header>
|
||||||
<div class="card-content loader-container" :class="{'p-0': !padding, 'is-loading': loading}">
|
<div
|
||||||
|
class="card-content loader-container"
|
||||||
|
:class="{
|
||||||
|
'p-0': !padding,
|
||||||
|
'is-loading': loading
|
||||||
|
}"
|
||||||
|
>
|
||||||
<div :class="{'content': hasContent}">
|
<div :class="{'content': hasContent}">
|
||||||
<slot></slot>
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<footer v-if="$slots.footer" class="card-footer">
|
||||||
|
<slot name="footer" />
|
||||||
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -76,9 +86,11 @@ defineEmits(['close'])
|
||||||
border-radius: $radius $radius 0 0;
|
border-radius: $radius $radius 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: should maybe be merged somehow with modal
|
.card-footer {
|
||||||
:deep(.modal-card-foot) {
|
|
||||||
background-color: var(--grey-50);
|
background-color: var(--grey-50);
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
|
padding: var(--modal-card-head-padding);
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
24
src/components/misc/colorBubble.vue
Normal file
24
src/components/misc/colorBubble.vue
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<template>
|
||||||
|
<span
|
||||||
|
:style="{backgroundColor: color }"
|
||||||
|
class="color-bubble"
|
||||||
|
></span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { Color } from 'csstype'
|
||||||
|
|
||||||
|
defineProps< {
|
||||||
|
color: Color,
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.color-bubble {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 100%;
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -4,15 +4,17 @@
|
||||||
:title="title"
|
:title="title"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
:padding="false"
|
:padding="false"
|
||||||
class="has-text-left has-overflow"
|
class="has-text-left"
|
||||||
:has-close="true"
|
:has-close="true"
|
||||||
@close="$router.back()"
|
@close="$router.back()"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
>
|
>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<slot></slot>
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
<footer class="modal-card-foot is-flex is-justify-content-flex-end">
|
|
||||||
|
<template #footer>
|
||||||
|
<slot name="footer">
|
||||||
<x-button
|
<x-button
|
||||||
v-if="tertiary !== ''"
|
v-if="tertiary !== ''"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
|
@ -31,11 +33,12 @@
|
||||||
variant="primary"
|
variant="primary"
|
||||||
@click.prevent.stop="primary()"
|
@click.prevent.stop="primary()"
|
||||||
:icon="primaryIcon"
|
:icon="primaryIcon"
|
||||||
:disabled="primaryDisabled"
|
:disabled="primaryDisabled || loading"
|
||||||
>
|
>
|
||||||
{{ primaryLabel || $t('misc.create') }}
|
{{ primaryLabel || $t('misc.create') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
</footer>
|
</slot>
|
||||||
|
</template>
|
||||||
</card>
|
</card>
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<message variant="danger">
|
<message variant="danger">
|
||||||
<i18n-t keypath="loadingError.failed">
|
<i18n-t keypath="loadingError.failed" scope="global">
|
||||||
<ButtonLink @click="reload">{{ $t('loadingError.tryAgain') }}</ButtonLink>
|
<ButtonLink @click="reload">{{ $t('loadingError.tryAgain') }}</ButtonLink>
|
||||||
<ButtonLink href="https://vikunja.io/contact/">{{ $t('loadingError.contact') }}</ButtonLink>
|
<ButtonLink href="https://vikunja.io/contact/">{{ $t('loadingError.contact') }}</ButtonLink>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
|
|
|
@ -33,18 +33,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {useStore} from 'vuex'
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
|
||||||
import Shortcut from '@/components/misc/shortcut.vue'
|
import Shortcut from '@/components/misc/shortcut.vue'
|
||||||
import Message from '@/components/misc/message.vue'
|
import Message from '@/components/misc/message.vue'
|
||||||
|
|
||||||
import {KEYBOARD_SHORTCUTS_ACTIVE} from '@/store/mutation-types'
|
|
||||||
import {KEYBOARD_SHORTCUTS as shortcuts} from './shortcuts'
|
import {KEYBOARD_SHORTCUTS as shortcuts} from './shortcuts'
|
||||||
|
|
||||||
const store = useStore()
|
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
store.commit(KEYBOARD_SHORTCUTS_ACTIVE, false)
|
useBaseStore().setKeyboardShortcutsActive(false)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,10 @@ export const KEYBOARD_SHORTCUTS : ShortcutGroup[] = [
|
||||||
title: 'keyboardShortcuts.task.reminder',
|
title: 'keyboardShortcuts.task.reminder',
|
||||||
keys: ['alt', 'r'],
|
keys: ['alt', 'r'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'keyboardShortcuts.task.description',
|
||||||
|
keys: ['e'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,14 +8,13 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
import {useConfigStore} from '@/stores/config'
|
||||||
|
|
||||||
const store = useStore()
|
const configStore = useConfigStore()
|
||||||
|
|
||||||
const imprintUrl = computed(() => store.state.config.legal.imprintUrl)
|
const imprintUrl = computed(() => configStore.legal.imprintUrl)
|
||||||
const privacyPolicyUrl = computed(() => store.state.config.legal.privacyPolicyUrl)
|
const privacyPolicyUrl = computed(() => configStore.legal.privacyPolicyUrl)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, PropType} from 'vue'
|
import {computed, type PropType} from 'vue'
|
||||||
|
|
||||||
const TEXT_ALIGN_MAP = Object.freeze({
|
const TEXT_ALIGN_MAP = Object.freeze({
|
||||||
left: '',
|
left: '',
|
||||||
|
|
|
@ -71,10 +71,9 @@ export default {
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import {onUnmounted, ref, useAttrs, watch} from 'vue'
|
import {ref, useAttrs, watchEffect} from 'vue'
|
||||||
import {useScrollLock} from '@vueuse/core'
|
import {useScrollLock} from '@vueuse/core'
|
||||||
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
enabled?: boolean,
|
enabled?: boolean,
|
||||||
overflow?: boolean,
|
overflow?: boolean,
|
||||||
|
@ -94,14 +93,9 @@ const attrs = useAttrs()
|
||||||
const modal = ref<HTMLElement | null>(null)
|
const modal = ref<HTMLElement | null>(null)
|
||||||
const scrollLock = useScrollLock(modal)
|
const scrollLock = useScrollLock(modal)
|
||||||
|
|
||||||
watch(
|
watchEffect(() => {
|
||||||
() => props.enabled,
|
scrollLock.value = props.enabled
|
||||||
enabled => {
|
})
|
||||||
scrollLock.value = enabled
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
onUnmounted(() => scrollLock.value = false)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -26,22 +26,23 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import {computed} from 'vue'
|
||||||
|
import {useRoute} from 'vue-router'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import Logo from '@/components/home/Logo.vue'
|
import Logo from '@/components/home/Logo.vue'
|
||||||
import Message from '@/components/misc/message.vue'
|
import Message from '@/components/misc/message.vue'
|
||||||
import Legal from '@/components/misc/legal.vue'
|
import Legal from '@/components/misc/legal.vue'
|
||||||
import ApiConfig from '@/components/misc/api-config.vue'
|
import ApiConfig from '@/components/misc/api-config.vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {computed} from 'vue'
|
|
||||||
import {useRoute} from 'vue-router'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
|
||||||
import {useTitle} from '@/composables/useTitle'
|
import {useTitle} from '@/composables/useTitle'
|
||||||
|
import {useConfigStore} from '@/stores/config'
|
||||||
|
|
||||||
|
const configStore = useConfigStore()
|
||||||
|
const motd = computed(() => configStore.motd)
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const store = useStore()
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const motd = computed(() => store.state.config.motd)
|
|
||||||
|
|
||||||
const title = computed(() => t(route.meta?.title as string || ''))
|
const title = computed(() => t(route.meta?.title as string || ''))
|
||||||
useTitle(() => title.value)
|
useTitle(() => title.value)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, computed} from 'vue'
|
import {ref, computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useRouter, useRoute} from 'vue-router'
|
||||||
|
|
||||||
import Logo from '@/assets/logo.svg?component'
|
import Logo from '@/assets/logo.svg?component'
|
||||||
import ApiConfig from '@/components/misc/api-config.vue'
|
import ApiConfig from '@/components/misc/api-config.vue'
|
||||||
|
@ -52,13 +52,14 @@ import NoAuthWrapper from '@/components/misc/no-auth-wrapper.vue'
|
||||||
import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
||||||
import {useOnline} from '@/composables/useOnline'
|
import {useOnline} from '@/composables/useOnline'
|
||||||
|
|
||||||
import {useRouter, useRoute} from 'vue-router'
|
|
||||||
import {getAuthForRoute} from '@/router'
|
import {getAuthForRoute} from '@/router'
|
||||||
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const store = useStore()
|
const baseStore = useBaseStore()
|
||||||
|
|
||||||
const ready = ref(false)
|
const ready = ref(false)
|
||||||
const online = useOnline()
|
const online = useOnline()
|
||||||
|
@ -68,14 +69,14 @@ const showLoading = computed(() => !ready.value && error.value === '')
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
try {
|
try {
|
||||||
await store.dispatch('loadApp')
|
await baseStore.loadApp()
|
||||||
const redirectTo = getAuthForRoute(route)
|
const redirectTo = getAuthForRoute(route)
|
||||||
if (typeof redirectTo !== 'undefined') {
|
if (typeof redirectTo !== 'undefined') {
|
||||||
await router.push(redirectTo)
|
await router.push(redirectTo)
|
||||||
}
|
}
|
||||||
ready.value = true
|
ready.value = true
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
error.value = e
|
error.value = String(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
:icon="iconName"
|
:icon="iconName"
|
||||||
v-tooltip="tooltipText"
|
v-tooltip="tooltipText"
|
||||||
@click="changeSubscription"
|
@click="changeSubscription"
|
||||||
:disabled="disabled || undefined"
|
:disabled="disabled"
|
||||||
>
|
>
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
</x-button>
|
</x-button>
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
v-tooltip="tooltipText"
|
v-tooltip="tooltipText"
|
||||||
@click="changeSubscription"
|
@click="changeSubscription"
|
||||||
:class="{'is-disabled': disabled}"
|
:class="{'is-disabled': disabled}"
|
||||||
|
:disabled="disabled"
|
||||||
>
|
>
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<icon :icon="iconName"/>
|
<icon :icon="iconName"/>
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, shallowRef} from 'vue'
|
import {computed, shallowRef, type PropType} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
@ -40,57 +41,78 @@ import DropdownItem from '@/components/misc/dropdown-item.vue'
|
||||||
|
|
||||||
import SubscriptionService from '@/services/subscription'
|
import SubscriptionService from '@/services/subscription'
|
||||||
import SubscriptionModel from '@/models/subscription'
|
import SubscriptionModel from '@/models/subscription'
|
||||||
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
||||||
|
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
|
||||||
interface Props {
|
const props = defineProps({
|
||||||
entity: string
|
entity: String,
|
||||||
entityId: number
|
entityId: Number,
|
||||||
subscription: SubscriptionModel | null
|
isButton: {
|
||||||
type?: 'button' | 'dropdown' | null
|
type: Boolean,
|
||||||
}
|
default: true,
|
||||||
|
},
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
modelValue: {
|
||||||
subscription: null,
|
type: Object as PropType<ISubscription>,
|
||||||
type: 'button',
|
default: null,
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String as PropType<'button' | 'dropdown' | 'null'>,
|
||||||
|
default: 'button',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const subscriptionEntity = computed<string | null>(() => props.subscription?.entity ?? null)
|
const subscriptionEntity = computed<string | null>(() => props.modelValue?.entity ?? null)
|
||||||
|
|
||||||
const emit = defineEmits(['change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const subscriptionService = shallowRef(new SubscriptionService())
|
const subscriptionService = shallowRef(new SubscriptionService())
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const tooltipText = computed(() => {
|
const tooltipText = computed(() => {
|
||||||
if (disabled.value) {
|
if (disabled.value) {
|
||||||
return t('task.subscription.subscribedThroughParent', {
|
if (props.entity === 'list' && subscriptionEntity.value === 'namespace') {
|
||||||
entity: props.entity,
|
return t('task.subscription.subscribedListThroughParentNamespace')
|
||||||
parent: subscriptionEntity.value,
|
}
|
||||||
})
|
if (props.entity === 'task' && subscriptionEntity.value === 'namespace') {
|
||||||
|
return t('task.subscription.subscribedTaskThroughParentNamespace')
|
||||||
|
}
|
||||||
|
if (props.entity === 'task' && subscriptionEntity.value === 'list') {
|
||||||
|
return t('task.subscription.subscribedTaskThroughParentList')
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.subscription !== null ?
|
return ''
|
||||||
t('task.subscription.subscribed', {entity: props.entity}) :
|
|
||||||
t('task.subscription.notSubscribed', {entity: props.entity})
|
|
||||||
})
|
|
||||||
|
|
||||||
const buttonText = computed(() => props.subscription !== null ? t('task.subscription.unsubscribe') : t('task.subscription.subscribe'))
|
|
||||||
const iconName = computed(() => props.subscription !== null ? ['far', 'bell-slash'] : 'bell')
|
|
||||||
const disabled = computed(() => {
|
|
||||||
if (props.subscription === null) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return subscriptionEntity.value !== props.entity
|
switch (props.entity) {
|
||||||
|
case 'namespace':
|
||||||
|
return props.modelValue !== null ?
|
||||||
|
t('task.subscription.subscribedNamespace') :
|
||||||
|
t('task.subscription.notSubscribedNamespace')
|
||||||
|
case 'list':
|
||||||
|
return props.modelValue !== null ?
|
||||||
|
t('task.subscription.subscribedList') :
|
||||||
|
t('task.subscription.notSubscribedList')
|
||||||
|
case 'task':
|
||||||
|
return props.modelValue !== null ?
|
||||||
|
t('task.subscription.subscribedTask') :
|
||||||
|
t('task.subscription.notSubscribedTask')
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const buttonText = computed(() => props.modelValue ? t('task.subscription.unsubscribe') : t('task.subscription.subscribe'))
|
||||||
|
const iconName = computed(() => props.modelValue ? ['far', 'bell-slash'] : 'bell')
|
||||||
|
const disabled = computed(() => props.modelValue && subscriptionEntity.value !== props.entity)
|
||||||
|
|
||||||
function changeSubscription() {
|
function changeSubscription() {
|
||||||
if (disabled.value) {
|
if (disabled.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.subscription === null) {
|
if (props.modelValue === null) {
|
||||||
subscribe()
|
subscribe()
|
||||||
} else {
|
} else {
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
@ -103,8 +125,21 @@ async function subscribe() {
|
||||||
entityId: props.entityId,
|
entityId: props.entityId,
|
||||||
})
|
})
|
||||||
await subscriptionService.value.create(subscription)
|
await subscriptionService.value.create(subscription)
|
||||||
emit('change', subscription)
|
emit('update:modelValue', subscription)
|
||||||
success({message: t('task.subscription.subscribeSuccess', {entity: props.entity})})
|
|
||||||
|
let message = ''
|
||||||
|
switch (props.entity) {
|
||||||
|
case 'namespace':
|
||||||
|
message = t('task.subscription.subscribeSuccessNamespace')
|
||||||
|
break
|
||||||
|
case 'list':
|
||||||
|
message = t('task.subscription.subscribeSuccessList')
|
||||||
|
break
|
||||||
|
case 'task':
|
||||||
|
message = t('task.subscription.subscribeSuccessTask')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
success({message})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unsubscribe() {
|
async function unsubscribe() {
|
||||||
|
@ -113,7 +148,20 @@ async function unsubscribe() {
|
||||||
entityId: props.entityId,
|
entityId: props.entityId,
|
||||||
})
|
})
|
||||||
await subscriptionService.value.delete(subscription)
|
await subscriptionService.value.delete(subscription)
|
||||||
emit('change', null)
|
emit('update:modelValue', null)
|
||||||
success({message: t('task.subscription.unsubscribeSuccess', {entity: props.entity})})
|
|
||||||
|
let message = ''
|
||||||
|
switch (props.entity) {
|
||||||
|
case 'namespace':
|
||||||
|
message = t('task.subscription.unsubscribeSuccessNamespace')
|
||||||
|
break
|
||||||
|
case 'list':
|
||||||
|
message = t('task.subscription.unsubscribeSuccessList')
|
||||||
|
break
|
||||||
|
case 'task':
|
||||||
|
message = t('task.subscription.unsubscribeSuccessTask')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
success({message})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2,34 +2,39 @@
|
||||||
<div :class="{'is-inline': isInline}" class="user">
|
<div :class="{'is-inline': isInline}" class="user">
|
||||||
<img
|
<img
|
||||||
:height="avatarSize"
|
:height="avatarSize"
|
||||||
:src="user.getAvatarUrl(avatarSize)"
|
:src="getAvatarUrl(user, avatarSize)"
|
||||||
:width="avatarSize"
|
:width="avatarSize"
|
||||||
alt=""
|
alt=""
|
||||||
class="avatar"
|
class="avatar"
|
||||||
v-tooltip="user.getDisplayName()"/>
|
v-tooltip="getDisplayName(user)"/>
|
||||||
<span class="username" v-if="showUsername">{{ user.getDisplayName() }}</span>
|
<span class="username" v-if="showUsername">{{ getDisplayName(user) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type {PropType} from 'vue'
|
||||||
|
|
||||||
|
import {getAvatarUrl, getDisplayName} from '@/models/user'
|
||||||
|
import type {IUser} from '@/modelTypes/IUser'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
user: {
|
user: {
|
||||||
|
type: Object as PropType<IUser>,
|
||||||
required: true,
|
required: true,
|
||||||
type: Object,
|
|
||||||
},
|
},
|
||||||
showUsername: {
|
showUsername: {
|
||||||
required: false,
|
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
avatarSize: {
|
avatarSize: {
|
||||||
required: false,
|
|
||||||
type: Number,
|
type: Number,
|
||||||
|
required: false,
|
||||||
default: 50,
|
default: 50,
|
||||||
},
|
},
|
||||||
isInline: {
|
isInline: {
|
||||||
required: false,
|
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
>
|
>
|
||||||
{{ $t('menu.archive') }}
|
{{ $t('menu.archive') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<task-subscription
|
<Subscription
|
||||||
class="has-no-shadow"
|
class="has-no-shadow"
|
||||||
:is-button="false"
|
:is-button="false"
|
||||||
entity="namespace"
|
entity="namespace"
|
||||||
:entity-id="namespace.id"
|
:entity-id="namespace.id"
|
||||||
:subscription="subscription"
|
:model-value="subscription"
|
||||||
@change="sub => subscription = sub"
|
@update:model-value="setSubscriptionInStore"
|
||||||
type="dropdown"
|
type="dropdown"
|
||||||
/>
|
/>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
|
@ -54,21 +54,36 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, onMounted} from 'vue'
|
import {ref, onMounted, type PropType} from 'vue'
|
||||||
|
|
||||||
import Dropdown from '@/components/misc/dropdown.vue'
|
import Dropdown from '@/components/misc/dropdown.vue'
|
||||||
import DropdownItem from '@/components/misc/dropdown-item.vue'
|
import DropdownItem from '@/components/misc/dropdown-item.vue'
|
||||||
import TaskSubscription from '@/components/misc/subscription.vue'
|
import Subscription from '@/components/misc/subscription.vue'
|
||||||
|
import type {INamespace} from '@/modelTypes/INamespace'
|
||||||
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
namespace: {
|
namespace: {
|
||||||
type: Object, // NamespaceModel
|
type: Object as PropType<INamespace>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const subscription = ref(null)
|
const namespaceStore = useNamespaceStore()
|
||||||
|
|
||||||
|
const subscription = ref<ISubscription | null>(null)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
subscription.value = props.namespace.subscription
|
subscription.value = props.namespace.subscription
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function setSubscriptionInStore(sub: ISubscription) {
|
||||||
|
subscription.value = sub
|
||||||
|
namespaceStore.setNamespaces([
|
||||||
|
{
|
||||||
|
...props.namespace,
|
||||||
|
subscription: sub,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<div>
|
<div>
|
||||||
<span class="has-text-weight-bold mr-1" v-if="n.notification.doer">
|
<span class="has-text-weight-bold mr-1" v-if="n.notification.doer">
|
||||||
{{ n.notification.doer.getDisplayName() }}
|
{{ getDisplayName(n.notification.doer) }}
|
||||||
</span>
|
</span>
|
||||||
<BaseButton @click="() => to(n, index)()">
|
<BaseButton @click="() => to(n, index)()">
|
||||||
{{ n.toText(userInfo) }}
|
{{ n.toText(userInfo) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
<span class="created" v-tooltip="formatDate(n.created)">
|
<span class="created" v-tooltip="formatDateLong(n.created)">
|
||||||
{{ formatDateSince(n.created) }}
|
{{ formatDateSince(n.created) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,21 +48,23 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, onMounted, onUnmounted, ref} from 'vue'
|
import {computed, onMounted, onUnmounted, ref} from 'vue'
|
||||||
|
import {useRouter} from 'vue-router'
|
||||||
|
|
||||||
import NotificationService from '@/services/notification'
|
import NotificationService from '@/services/notification'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import User from '@/components/misc/user.vue'
|
import User from '@/components/misc/user.vue'
|
||||||
import names from '@/models/constants/notificationNames.json'
|
import { NOTIFICATION_NAMES as names, type INotification} from '@/modelTypes/INotification'
|
||||||
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
||||||
import {useStore} from 'vuex'
|
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||||
import {useRouter} from 'vue-router'
|
import {getDisplayName} from '@/models/user'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
const LOAD_NOTIFICATIONS_INTERVAL = 10000
|
const LOAD_NOTIFICATIONS_INTERVAL = 10000
|
||||||
|
|
||||||
const store = useStore()
|
const authStore = useAuthStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const allNotifications = ref([])
|
const allNotifications = ref<INotification[]>([])
|
||||||
const showNotifications = ref(false)
|
const showNotifications = ref(false)
|
||||||
const popup = ref(null)
|
const popup = ref(null)
|
||||||
|
|
||||||
|
@ -72,7 +74,7 @@ const unreadNotifications = computed(() => {
|
||||||
const notifications = computed(() => {
|
const notifications = computed(() => {
|
||||||
return allNotifications.value ? allNotifications.value.filter(n => n.name !== '') : []
|
return allNotifications.value ? allNotifications.value.filter(n => n.name !== '') : []
|
||||||
})
|
})
|
||||||
const userInfo = computed(() => store.state.auth.info)
|
const userInfo = computed(() => authStore.info)
|
||||||
|
|
||||||
let interval: number
|
let interval: number
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,6 @@ import TeamService from '@/services/team'
|
||||||
import NamespaceModel from '@/models/namespace'
|
import NamespaceModel from '@/models/namespace'
|
||||||
import TeamModel from '@/models/team'
|
import TeamModel from '@/models/team'
|
||||||
|
|
||||||
import {CURRENT_LIST, LOADING, LOADING_MODULE, QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
|
|
||||||
import ListModel from '@/models/list'
|
import ListModel from '@/models/list'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
@ -71,6 +70,12 @@ import {parseTaskText, PrefixMode} from '@/modules/parseTaskText'
|
||||||
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
||||||
import {PREFIXES} from '@/modules/parseTaskText'
|
import {PREFIXES} from '@/modules/parseTaskText'
|
||||||
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
import {useLabelStore} from '@/stores/labels'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
const TYPE_LIST = 'list'
|
const TYPE_LIST = 'list'
|
||||||
const TYPE_TASK = 'task'
|
const TYPE_TASK = 'task'
|
||||||
const TYPE_CMD = 'cmd'
|
const TYPE_CMD = 'cmd'
|
||||||
|
@ -108,14 +113,18 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
active() {
|
active() {
|
||||||
const active = this.$store.state[QUICK_ACTIONS_ACTIVE]
|
const active = useBaseStore().quickActionsActive
|
||||||
if (!active) {
|
if (!active) {
|
||||||
|
// FIXME: computeds shouldn't have side effects.
|
||||||
|
// create a watcher instead
|
||||||
this.reset()
|
this.reset()
|
||||||
}
|
}
|
||||||
return active
|
return active
|
||||||
},
|
},
|
||||||
results() {
|
results() {
|
||||||
let lists = []
|
let lists = []
|
||||||
|
const listStore = useListStore()
|
||||||
|
|
||||||
if (this.searchMode === SEARCH_MODE_ALL || this.searchMode === SEARCH_MODE_LISTS) {
|
if (this.searchMode === SEARCH_MODE_ALL || this.searchMode === SEARCH_MODE_LISTS) {
|
||||||
const {list} = this.parsedQuery
|
const {list} = this.parsedQuery
|
||||||
|
|
||||||
|
@ -126,10 +135,8 @@ export default defineComponent({
|
||||||
const history = getHistory()
|
const history = getHistory()
|
||||||
// Puts recently visited lists at the top
|
// Puts recently visited lists at the top
|
||||||
const allLists = [...new Set([
|
const allLists = [...new Set([
|
||||||
...history.map(l => {
|
...history.map(l => listStore.getListById(l.id)),
|
||||||
return this.$store.getters['lists/getListById'](l.id)
|
...listStore.searchList(list),
|
||||||
}),
|
|
||||||
...this.$store.getters['lists/searchList'](list),
|
|
||||||
])]
|
])]
|
||||||
|
|
||||||
lists = allLists.filter(l => {
|
lists = allLists.filter(l => {
|
||||||
|
@ -138,7 +145,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof ncache[l.namespaceId] === 'undefined') {
|
if (typeof ncache[l.namespaceId] === 'undefined') {
|
||||||
ncache[l.namespaceId] = this.$store.getters['namespaces/getNamespaceById'](l.namespaceId)
|
ncache[l.namespaceId] = useNamespaceStore().getNamespaceById(l.namespaceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
return !ncache[l.namespaceId].isArchived
|
return !ncache[l.namespaceId].isArchived
|
||||||
|
@ -177,8 +184,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
loading() {
|
loading() {
|
||||||
return this.taskService.loading ||
|
return this.taskService.loading ||
|
||||||
(this.$store.state[LOADING] && this.$store.state[LOADING_MODULE] === 'namespaces') ||
|
useNamespaceStore().isLoading || useListStore().isLoading ||
|
||||||
(this.$store.state[LOADING] && this.$store.state[LOADING_MODULE] === 'lists') ||
|
|
||||||
this.teamService.loading
|
this.teamService.loading
|
||||||
},
|
},
|
||||||
placeholder() {
|
placeholder() {
|
||||||
|
@ -205,7 +211,7 @@ export default defineComponent({
|
||||||
case CMD_NEW_TASK:
|
case CMD_NEW_TASK:
|
||||||
return this.$t('quickActions.createTask', {title: this.currentList.title})
|
return this.$t('quickActions.createTask', {title: this.currentList.title})
|
||||||
case CMD_NEW_LIST:
|
case CMD_NEW_LIST:
|
||||||
namespace = this.$store.getters['namespaces/getNamespaceById'](this.currentList.namespaceId)
|
namespace = useNamespaceStore().getNamespaceById(this.currentList.namespaceId)
|
||||||
return this.$t('quickActions.createList', {title: namespace.title})
|
return this.$t('quickActions.createList', {title: namespace.title})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +221,8 @@ export default defineComponent({
|
||||||
return this.$t('quickActions.hint', prefixes)
|
return this.$t('quickActions.hint', prefixes)
|
||||||
},
|
},
|
||||||
currentList() {
|
currentList() {
|
||||||
return Object.keys(this.$store.state[CURRENT_LIST]).length === 0 ? null : this.$store.state[CURRENT_LIST]
|
const currentList = useBaseStore().currentList
|
||||||
|
return Object.keys(currentList).length === 0 ? null : currentList
|
||||||
},
|
},
|
||||||
availableCmds() {
|
availableCmds() {
|
||||||
const cmds = []
|
const cmds = []
|
||||||
|
@ -296,8 +303,10 @@ export default defineComponent({
|
||||||
filter_comparator: [],
|
filter_comparator: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const listStore = useListStore()
|
||||||
|
|
||||||
if (list !== null) {
|
if (list !== null) {
|
||||||
const l = this.$store.getters['lists/findListByExactname'](list)
|
const l = listStore.findListByExactname(list)
|
||||||
if (l !== null) {
|
if (l !== null) {
|
||||||
params.filter_by.push('list_id')
|
params.filter_by.push('list_id')
|
||||||
params.filter_value.push(l.id)
|
params.filter_value.push(l.id)
|
||||||
|
@ -306,7 +315,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (labels.length > 0) {
|
if (labels.length > 0) {
|
||||||
const labelIds = this.$store.getters['labels/getLabelsByExactTitles'](labels).map(l => l.id)
|
const labelIds = useLabelStore().getLabelsByExactTitles(labels).map(l => l.id)
|
||||||
if (labelIds.length > 0) {
|
if (labelIds.length > 0) {
|
||||||
params.filter_by.push('labels')
|
params.filter_by.push('labels')
|
||||||
params.filter_value.push(labelIds.join())
|
params.filter_value.push(labelIds.join())
|
||||||
|
@ -318,7 +327,7 @@ export default defineComponent({
|
||||||
const r = await this.taskService.getAll({}, params)
|
const r = await this.taskService.getAll({}, params)
|
||||||
this.foundTasks = r.map(t => {
|
this.foundTasks = r.map(t => {
|
||||||
t.type = TYPE_TASK
|
t.type = TYPE_TASK
|
||||||
const list = this.$store.getters['lists/getListById'](t.listId)
|
const list = listStore.getListById(t.listId)
|
||||||
if (list !== null) {
|
if (list !== null) {
|
||||||
t.title = `${t.title} (${list.title})`
|
t.title = `${t.title} (${list.title})`
|
||||||
}
|
}
|
||||||
|
@ -354,7 +363,7 @@ export default defineComponent({
|
||||||
}, 150)
|
}, 150)
|
||||||
},
|
},
|
||||||
closeQuickActions() {
|
closeQuickActions() {
|
||||||
this.$store.commit(QUICK_ACTIONS_ACTIVE, false)
|
useBaseStore().setQuickActionsActive(false)
|
||||||
},
|
},
|
||||||
doAction(type, item) {
|
doAction(type, item) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -407,7 +416,8 @@ export default defineComponent({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const task = await this.$store.dispatch('tasks/createNewTask', {
|
const taskStore = useTaskStore()
|
||||||
|
const task = await taskStore.createNewTask({
|
||||||
title: this.query,
|
title: this.query,
|
||||||
listId: this.currentList.id,
|
listId: this.currentList.id,
|
||||||
})
|
})
|
||||||
|
@ -424,7 +434,8 @@ export default defineComponent({
|
||||||
title: this.query,
|
title: this.query,
|
||||||
namespaceId: this.currentList.namespaceId,
|
namespaceId: this.currentList.namespaceId,
|
||||||
})
|
})
|
||||||
const list = await this.$store.dispatch('lists/createList', newList)
|
const listStore = useListStore()
|
||||||
|
const list = await listStore.createList(newList)
|
||||||
this.$message.success({message: this.$t('list.create.createdSuccess')})
|
this.$message.success({message: this.$t('list.create.createdSuccess')})
|
||||||
this.$router.push({name: 'list.index', params: {listId: list.id}})
|
this.$router.push({name: 'list.index', params: {listId: list.id}})
|
||||||
this.closeQuickActions()
|
this.closeQuickActions()
|
||||||
|
@ -432,7 +443,7 @@ export default defineComponent({
|
||||||
async newNamespace() {
|
async newNamespace() {
|
||||||
const newNamespace = new NamespaceModel({title: this.query})
|
const newNamespace = new NamespaceModel({title: this.query})
|
||||||
|
|
||||||
await this.$store.dispatch('namespaces/createNamespace', newNamespace)
|
await useNamespaceStore().createNamespace(newNamespace)
|
||||||
this.$message.success({message: this.$t('namespace.create.success')})
|
this.$message.success({message: this.$t('namespace.create.success')})
|
||||||
this.closeQuickActions()
|
this.closeQuickActions()
|
||||||
},
|
},
|
||||||
|
|
|
@ -79,48 +79,25 @@
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ $t('list.share.attributes.link') }}</th>
|
<th></th>
|
||||||
<th>{{ $t('list.share.attributes.name') }}</th>
|
<th>{{ $t('list.share.links.view') }}</th>
|
||||||
<th>{{ $t('list.share.attributes.sharedBy') }}</th>
|
|
||||||
<th>{{ $t('list.share.attributes.right') }}</th>
|
|
||||||
<th>{{ $t('list.share.attributes.delete') }}</th>
|
<th>{{ $t('list.share.attributes.delete') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr :key="s.id" v-for="s in linkShares">
|
<tr :key="s.id" v-for="s in linkShares">
|
||||||
<td>
|
<td>
|
||||||
<div class="field has-addons no-input-mobile">
|
<p class="mb-2 is-italic" v-if="s.name !== ''">
|
||||||
<div class="control">
|
|
||||||
<input
|
|
||||||
:value="getShareLink(s.hash)"
|
|
||||||
class="input"
|
|
||||||
readonly
|
|
||||||
type="text"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
|
||||||
<x-button
|
|
||||||
@click="copy(getShareLink(s.hash))"
|
|
||||||
:shadow="false"
|
|
||||||
v-tooltip="$t('misc.copy')"
|
|
||||||
>
|
|
||||||
<span class="icon">
|
|
||||||
<icon icon="paste"/>
|
|
||||||
</span>
|
|
||||||
</x-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<template v-if="s.name !== ''">
|
|
||||||
{{ s.name }}
|
{{ s.name }}
|
||||||
</template>
|
</p>
|
||||||
<i v-else>{{ $t('list.share.links.noName') }}</i>
|
|
||||||
</td>
|
<p class="mb-2">
|
||||||
<td>
|
<i18n-t keypath="list.share.links.sharedBy" scope="global">
|
||||||
{{ s.sharedBy.getDisplayName() }}
|
<strong>{{ getDisplayName(s.sharedBy) }}</strong>
|
||||||
</td>
|
</i18n-t>
|
||||||
<td class="type">
|
</p>
|
||||||
|
|
||||||
|
<p class="mb-2">
|
||||||
<template v-if="s.right === RIGHTS.ADMIN">
|
<template v-if="s.right === RIGHTS.ADMIN">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<icon icon="lock"/>
|
<icon icon="lock"/>
|
||||||
|
@ -139,6 +116,41 @@
|
||||||
</span>
|
</span>
|
||||||
{{ $t('list.share.right.read') }}
|
{{ $t('list.share.right.read') }}
|
||||||
</template>
|
</template>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="field has-addons no-input-mobile">
|
||||||
|
<div class="control">
|
||||||
|
<input
|
||||||
|
:value="getShareLink(s.hash, selectedView[s.id])"
|
||||||
|
class="input"
|
||||||
|
readonly
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<x-button
|
||||||
|
@click="copy(getShareLink(s.hash, selectedView[s.id]))"
|
||||||
|
:shadow="false"
|
||||||
|
v-tooltip="$t('misc.copy')"
|
||||||
|
>
|
||||||
|
<span class="icon">
|
||||||
|
<icon icon="paste"/>
|
||||||
|
</span>
|
||||||
|
</x-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="select">
|
||||||
|
<select v-model="selectedView[s.id]">
|
||||||
|
<option
|
||||||
|
v-for="(title, key) in availableViews"
|
||||||
|
:value="key"
|
||||||
|
:key="key">
|
||||||
|
{{ title }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<x-button
|
<x-button
|
||||||
|
@ -177,16 +189,22 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watch, computed, shallowReactive} from 'vue'
|
import {ref, watch, computed, shallowReactive} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import RIGHTS from '@/models/constants/rights.json'
|
import {RIGHTS} from '@/constants/rights'
|
||||||
import LinkShareModel from '@/models/linkShare'
|
import LinkShareModel from '@/models/linkShare'
|
||||||
|
|
||||||
|
import type {ILinkShare} from '@/modelTypes/ILinkShare'
|
||||||
|
import type {IList} from '@/modelTypes/IList'
|
||||||
|
|
||||||
import LinkShareService from '@/services/linkShare'
|
import LinkShareService from '@/services/linkShare'
|
||||||
|
|
||||||
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
|
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
import {getDisplayName} from '@/models/user'
|
||||||
|
import type {ListView} from '@/types/ListView'
|
||||||
|
import {LIST_VIEWS} from '@/types/ListView'
|
||||||
|
import {useConfigStore} from '@/stores/config'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
listId: {
|
listId: {
|
||||||
|
@ -197,7 +215,7 @@ const props = defineProps({
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const linkShares = ref([])
|
const linkShares = ref<ILinkShare[]>([])
|
||||||
const linkShareService = shallowReactive(new LinkShareService())
|
const linkShareService = shallowReactive(new LinkShareService())
|
||||||
const selectedRight = ref(RIGHTS.READ)
|
const selectedRight = ref(RIGHTS.READ)
|
||||||
const name = ref('')
|
const name = ref('')
|
||||||
|
@ -206,6 +224,17 @@ const showDeleteModal = ref(false)
|
||||||
const linkIdToDelete = ref(0)
|
const linkIdToDelete = ref(0)
|
||||||
const showNewForm = ref(false)
|
const showNewForm = ref(false)
|
||||||
|
|
||||||
|
type SelectedViewMapper = Record<IList['id'], ListView>
|
||||||
|
|
||||||
|
const selectedView = ref<SelectedViewMapper>({})
|
||||||
|
|
||||||
|
const availableViews = computed<Record<ListView, string>>(() => ({
|
||||||
|
list: t('list.list.title'),
|
||||||
|
gantt: t('list.gantt.title'),
|
||||||
|
table: t('list.table.title'),
|
||||||
|
kanban: t('list.kanban.title'),
|
||||||
|
}))
|
||||||
|
|
||||||
const copy = useCopyToClipboard()
|
const copy = useCopyToClipboard()
|
||||||
watch(
|
watch(
|
||||||
() => props.listId,
|
() => props.listId,
|
||||||
|
@ -213,19 +242,23 @@ watch(
|
||||||
{immediate: true},
|
{immediate: true},
|
||||||
)
|
)
|
||||||
|
|
||||||
const store = useStore()
|
const configStore = useConfigStore()
|
||||||
const frontendUrl = computed(() => store.state.config.frontendUrl)
|
const frontendUrl = computed(() => configStore.frontendUrl)
|
||||||
|
|
||||||
async function load(listId) {
|
async function load(listId: IList['id']) {
|
||||||
// If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here
|
// If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here
|
||||||
if (listId === 0) {
|
if (listId === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
linkShares.value = await linkShareService.getAll({listId})
|
const links = await linkShareService.getAll({listId})
|
||||||
|
links.forEach((l: ILinkShare) => {
|
||||||
|
selectedView.value[l.id] = 'list'
|
||||||
|
})
|
||||||
|
linkShares.value = links
|
||||||
}
|
}
|
||||||
|
|
||||||
async function add(listId) {
|
async function add(listId: IList['id']) {
|
||||||
const newLinkShare = new LinkShareModel({
|
const newLinkShare = new LinkShareModel({
|
||||||
right: selectedRight.value,
|
right: selectedRight.value,
|
||||||
listId,
|
listId,
|
||||||
|
@ -241,7 +274,7 @@ async function add(listId) {
|
||||||
await load(listId)
|
await load(listId)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(listId) {
|
async function remove(listId: IList['id']) {
|
||||||
try {
|
try {
|
||||||
await linkShareService.delete(new LinkShareModel({
|
await linkShareService.delete(new LinkShareModel({
|
||||||
id: linkIdToDelete.value,
|
id: linkIdToDelete.value,
|
||||||
|
@ -254,8 +287,8 @@ async function remove(listId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShareLink(hash: string) {
|
function getShareLink(hash: string, view: ListView = LIST_VIEWS.LIST) {
|
||||||
return frontendUrl.value + 'share/' + hash + '/auth'
|
return frontendUrl.value + 'share/' + hash + '/auth?view=' + view
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr :key="s.id" v-for="s in sharables">
|
<tr :key="s.id" v-for="s in sharables">
|
||||||
<template v-if="shareType === 'user'">
|
<template v-if="shareType === 'user'">
|
||||||
<td>{{ s.getDisplayName() }}</td>
|
<td>{{ getDisplayName(s) }}</td>
|
||||||
<td>
|
<td>
|
||||||
<template v-if="s.id === userInfo.id">
|
<template v-if="s.id === userInfo.id">
|
||||||
<b class="is-success">{{ $t('list.share.userTeam.you') }}</b>
|
<b class="is-success">{{ $t('list.share.userTeam.you') }}</b>
|
||||||
|
@ -133,35 +133,44 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
export default {name: 'userTeamShare'}
|
||||||
|
|
||||||
export default defineComponent({name: 'userTeamShare'})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, reactive, computed, shallowReactive, ShallowReactive, Ref} from 'vue'
|
import {ref, reactive, computed, shallowReactive, type Ref} from 'vue'
|
||||||
import type {PropType} from 'vue'
|
import type {PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import UserNamespaceService from '@/services/userNamespace'
|
import UserNamespaceService from '@/services/userNamespace'
|
||||||
import UserNamespaceModel from '@/models/userNamespace'
|
import UserNamespaceModel from '@/models/userNamespace'
|
||||||
import UserListModel from '@/models/userList'
|
import type {IUserNamespace} from '@/modelTypes/IUserNamespace'
|
||||||
|
|
||||||
import UserListService from '@/services/userList'
|
import UserListService from '@/services/userList'
|
||||||
|
import UserListModel from '@/models/userList'
|
||||||
|
import type {IUserList} from '@/modelTypes/IUserList'
|
||||||
|
|
||||||
import UserService from '@/services/user'
|
import UserService from '@/services/user'
|
||||||
import UserModel from '@/models/user'
|
import UserModel, { getDisplayName } from '@/models/user'
|
||||||
|
import type {IUser} from '@/modelTypes/IUser'
|
||||||
|
|
||||||
import TeamNamespaceService from '@/services/teamNamespace'
|
import TeamNamespaceService from '@/services/teamNamespace'
|
||||||
import TeamNamespaceModel from '@/models/teamNamespace'
|
import TeamNamespaceModel from '@/models/teamNamespace'
|
||||||
import TeamListModel from '@/models/teamList'
|
import type { ITeamNamespace } from '@/modelTypes/ITeamNamespace'
|
||||||
|
|
||||||
import TeamListService from '@/services/teamList'
|
import TeamListService from '@/services/teamList'
|
||||||
|
import TeamListModel from '@/models/teamList'
|
||||||
|
import type { ITeamList } from '@/modelTypes/ITeamList'
|
||||||
|
|
||||||
import TeamService from '@/services/team'
|
import TeamService from '@/services/team'
|
||||||
import TeamModel from '@/models/team'
|
import TeamModel from '@/models/team'
|
||||||
|
import type {ITeam} from '@/modelTypes/ITeam'
|
||||||
|
|
||||||
import RIGHTS from '@/models/constants/rights.json'
|
|
||||||
|
import {RIGHTS} from '@/constants/rights'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
import Nothing from '@/components/misc/nothing.vue'
|
import Nothing from '@/components/misc/nothing.vue'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
|
@ -185,10 +194,10 @@ const props = defineProps({
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
// This user service is either a userNamespaceService or a userListService, depending on the type we are using
|
// This user service is either a userNamespaceService or a userListService, depending on the type we are using
|
||||||
let stuffService: ShallowReactive<UserNamespaceService | UserListService | TeamListService | TeamNamespaceService>
|
let stuffService: UserNamespaceService | UserListService | TeamListService | TeamNamespaceService
|
||||||
let stuffModel: UserNamespaceModel | UserListModel | TeamListModel | TeamNamespaceModel
|
let stuffModel: IUserNamespace | IUserList | ITeamList | ITeamNamespace
|
||||||
let searchService: ShallowReactive<UserService | TeamService>
|
let searchService: UserService | TeamService
|
||||||
let sharable: Ref<UserModel | TeamModel>
|
let sharable: Ref<IUser | ITeam>
|
||||||
|
|
||||||
const searchLabel = ref('')
|
const searchLabel = ref('')
|
||||||
const selectedRight = ref({})
|
const selectedRight = ref({})
|
||||||
|
@ -199,8 +208,8 @@ const sharables = ref([])
|
||||||
const showDeleteModal = ref(false)
|
const showDeleteModal = ref(false)
|
||||||
|
|
||||||
|
|
||||||
const store = useStore()
|
const authStore = useAuthStore()
|
||||||
const userInfo = computed(() => store.state.auth.info)
|
const userInfo = computed(() => authStore.info)
|
||||||
|
|
||||||
function createShareTypeNameComputed(count: number) {
|
function createShareTypeNameComputed(count: number) {
|
||||||
return computed(() => {
|
return computed(() => {
|
||||||
|
@ -233,6 +242,7 @@ const sharableName = computed(() => {
|
||||||
|
|
||||||
if (props.shareType === 'user') {
|
if (props.shareType === 'user') {
|
||||||
searchService = shallowReactive(new UserService())
|
searchService = shallowReactive(new UserService())
|
||||||
|
// eslint-disable-next-line vue/no-ref-as-operand
|
||||||
sharable = ref(new UserModel())
|
sharable = ref(new UserModel())
|
||||||
searchLabel.value = 'username'
|
searchLabel.value = 'username'
|
||||||
|
|
||||||
|
@ -249,6 +259,7 @@ if (props.shareType === 'user') {
|
||||||
}
|
}
|
||||||
} else if (props.shareType === 'team') {
|
} else if (props.shareType === 'team') {
|
||||||
searchService = new TeamService()
|
searchService = new TeamService()
|
||||||
|
// eslint-disable-next-line vue/no-ref-as-operand
|
||||||
sharable = ref(new TeamModel())
|
sharable = ref(new TeamModel())
|
||||||
searchLabel.value = 'name'
|
searchLabel.value = 'name'
|
||||||
|
|
||||||
|
@ -354,8 +365,8 @@ async function toggleType(sharable) {
|
||||||
|
|
||||||
const found = ref([])
|
const found = ref([])
|
||||||
|
|
||||||
const currentUserId = computed(() => store.state.auth.info.id)
|
const currentUserId = computed(() => authStore.info.id)
|
||||||
async function find(query) {
|
async function find(query: string) {
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
found.value = []
|
found.value = []
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<p class="control has-icons-left is-expanded">
|
<p class="control has-icons-left is-expanded">
|
||||||
<textarea
|
<textarea
|
||||||
:disabled="taskService.loading || undefined"
|
:disabled="loading || undefined"
|
||||||
class="add-task-textarea input"
|
class="add-task-textarea input"
|
||||||
:class="{'textarea-empty': newTaskTitle === ''}"
|
:class="{'textarea-empty': newTaskTitle === ''}"
|
||||||
:placeholder="$t('list.list.addPlaceholder')"
|
:placeholder="$t('list.list.addPlaceholder')"
|
||||||
|
@ -21,10 +21,10 @@
|
||||||
<p class="control">
|
<p class="control">
|
||||||
<x-button
|
<x-button
|
||||||
class="add-task-button"
|
class="add-task-button"
|
||||||
:disabled="newTaskTitle === '' || taskService.loading || undefined"
|
:disabled="newTaskTitle === '' || loading || undefined"
|
||||||
@click="addTask()"
|
@click="addTask()"
|
||||||
icon="plus"
|
icon="plus"
|
||||||
:loading="taskService.loading"
|
:loading="loading"
|
||||||
:aria-label="$t('list.list.add')"
|
:aria-label="$t('list.list.add')"
|
||||||
>
|
>
|
||||||
<span class="button-text">
|
<span class="button-text">
|
||||||
|
@ -41,17 +41,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watch, unref, shallowReactive} from 'vue'
|
import {computed, ref, unref, watch} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {useStore} from 'vuex'
|
import {debouncedWatch, type MaybeRef, tryOnMounted, useWindowSize} from '@vueuse/core'
|
||||||
import {tryOnMounted, debouncedWatch, useWindowSize, MaybeRef} from '@vueuse/core'
|
|
||||||
|
|
||||||
import TaskService from '@/services/task'
|
|
||||||
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
|
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
function cleanupTitle(title: string) {
|
import {parseSubtasksViaIndention} from '@/helpers/parseSubtasksViaIndention'
|
||||||
return title.replace(/^((\* |\+ |- )(\[ \] )?)/g, '')
|
import TaskRelationService from '@/services/taskRelation'
|
||||||
}
|
import TaskRelationModel from '@/models/taskRelation'
|
||||||
|
import {RELATION_KIND} from '@/types/IRelationKind'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
function useAutoHeightTextarea(value: MaybeRef<string>) {
|
function useAutoHeightTextarea(value: MaybeRef<string>) {
|
||||||
const textarea = ref<HTMLInputElement>()
|
const textarea = ref<HTMLInputElement>()
|
||||||
|
@ -134,9 +135,9 @@ const newTaskTitle = ref('')
|
||||||
const newTaskInput = useAutoHeightTextarea(newTaskTitle)
|
const newTaskInput = useAutoHeightTextarea(newTaskTitle)
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
const store = useStore()
|
const authStore = useAuthStore()
|
||||||
|
const taskStore = useTaskStore()
|
||||||
|
|
||||||
const taskService = shallowReactive(new TaskService())
|
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
|
|
||||||
function resetEmptyTitleError(e) {
|
function resetEmptyTitleError(e) {
|
||||||
|
@ -148,6 +149,7 @@ function resetEmptyTitleError(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loading = computed(() => taskStore.isLoading)
|
||||||
async function addTask() {
|
async function addTask() {
|
||||||
if (newTaskTitle.value === '') {
|
if (newTaskTitle.value === '') {
|
||||||
errorMessage.value = t('list.create.addTitleRequired')
|
errorMessage.value = t('list.create.addTitleRequired')
|
||||||
|
@ -155,30 +157,64 @@ async function addTask() {
|
||||||
}
|
}
|
||||||
errorMessage.value = ''
|
errorMessage.value = ''
|
||||||
|
|
||||||
if (taskService.loading) {
|
if (loading.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskTitleBackup = newTaskTitle.value
|
const taskTitleBackup = newTaskTitle.value
|
||||||
const newTasks = newTaskTitle.value.split(/[\r\n]+/).map(async uncleanedTitle => {
|
// This allows us to find the tasks with the title they had before being parsed
|
||||||
const title = cleanupTitle(uncleanedTitle)
|
// by quick add magic.
|
||||||
|
const createdTasks: { [key: ITask['title']]: ITask } = {}
|
||||||
|
const tasksToCreate = parseSubtasksViaIndention(newTaskTitle.value)
|
||||||
|
const newTasks = tasksToCreate.map(async ({title}) => {
|
||||||
if (title === '') {
|
if (title === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const task = await store.dispatch('tasks/createNewTask', {
|
const task = await taskStore.createNewTask({
|
||||||
title,
|
title,
|
||||||
listId: store.state.auth.settings.defaultListId,
|
listId: authStore.settings.defaultListId,
|
||||||
position: props.defaultPosition,
|
position: props.defaultPosition,
|
||||||
})
|
})
|
||||||
emit('taskAdded', task)
|
createdTasks[title] = task
|
||||||
return task
|
return task
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newTaskTitle.value = ''
|
newTaskTitle.value = ''
|
||||||
await Promise.all(newTasks)
|
await Promise.all(newTasks)
|
||||||
} catch (e: any) {
|
|
||||||
|
const taskRelationService = new TaskRelationService()
|
||||||
|
const relations = tasksToCreate.map(async t => {
|
||||||
|
const createdTask = createdTasks[t.title]
|
||||||
|
if (typeof createdTask === 'undefined') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.parent === null) {
|
||||||
|
emit('taskAdded', createdTask)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const createdParentTask = createdTasks[t.parent]
|
||||||
|
if (typeof createdTask === 'undefined' || typeof createdParentTask === 'undefined') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const rel = await taskRelationService.create(new TaskRelationModel({
|
||||||
|
taskId: createdTask.id,
|
||||||
|
otherTaskId: createdParentTask.id,
|
||||||
|
relationKind: RELATION_KIND.PARENTTASK,
|
||||||
|
}))
|
||||||
|
|
||||||
|
createdTask.relatedTasks[RELATION_KIND.PARENTTASK] = [createdParentTask]
|
||||||
|
// we're only emitting here so that the relation shows up in the task list
|
||||||
|
emit('taskAdded', createdTask)
|
||||||
|
|
||||||
|
return rel
|
||||||
|
})
|
||||||
|
await Promise.all(relations)
|
||||||
|
} catch (e: { message?: string }) {
|
||||||
newTaskTitle.value = taskTitleBackup
|
newTaskTitle.value = taskTitleBackup
|
||||||
if (e?.message === 'NO_LIST') {
|
if (e?.message === 'NO_LIST') {
|
||||||
errorMessage.value = t('list.create.addListRequired')
|
errorMessage.value = t('list.create.addListRequired')
|
||||||
|
@ -200,7 +236,7 @@ function handleEnter(e: KeyboardEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusTaskInput() {
|
function focusTaskInput() {
|
||||||
newTaskInput.value.focus()
|
newTaskInput.value?.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
@ -214,7 +250,7 @@ defineExpose({
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-task-button {
|
.add-task-button {
|
||||||
height: 2.5rem;
|
height: 100% !important;
|
||||||
|
|
||||||
@media screen and (max-width: $mobile) {
|
@media screen and (max-width: $mobile) {
|
||||||
.button-text {
|
.button-text {
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
|
|
||||||
<strong>{{ $t('task.attributes.reminders') }}</strong>
|
<strong>{{ $t('task.attributes.reminders') }}</strong>
|
||||||
<reminders
|
<reminders
|
||||||
@change="editTaskSubmit()"
|
|
||||||
v-model="taskEditTask.reminderDates"
|
v-model="taskEditTask.reminderDates"
|
||||||
|
@update:model-value="editTaskSubmit()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, reactive, computed, shallowReactive, watch, nextTick} from 'vue'
|
import {ref, reactive, computed, shallowReactive, watch, nextTick, type PropType} from 'vue'
|
||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ import Editor from '@/components/input/AsyncEditor'
|
||||||
|
|
||||||
import TaskService from '@/services/task'
|
import TaskService from '@/services/task'
|
||||||
import TaskModel from '@/models/task'
|
import TaskModel from '@/models/task'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
import EditLabels from './partials/editLabels.vue'
|
import EditLabels from './partials/editLabels.vue'
|
||||||
import Reminders from './partials/reminders.vue'
|
import Reminders from './partials/reminders.vue'
|
||||||
import ColorPicker from '../input/colorPicker.vue'
|
import ColorPicker from '../input/colorPicker.vue'
|
||||||
|
@ -95,15 +96,14 @@ const router = useRouter()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
task: {
|
task: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask | null>,
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const taskService = shallowReactive(new TaskService())
|
const taskService = shallowReactive(new TaskService())
|
||||||
|
|
||||||
const editorActive = ref(false)
|
const editorActive = ref(false)
|
||||||
let taskEditTask: TaskModel | undefined
|
let taskEditTask: ITask | undefined
|
||||||
|
|
||||||
|
|
||||||
// FIXME: this initialization should not be necessary here
|
// FIXME: this initialization should not be necessary here
|
||||||
|
|
|
@ -173,21 +173,24 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {defineComponent} from 'vue'
|
||||||
|
import {mapState} from 'pinia'
|
||||||
|
|
||||||
import VueDragResize from 'vue-drag-resize'
|
import VueDragResize from 'vue-drag-resize'
|
||||||
import EditTask from './edit-task'
|
import EditTask from './edit-task.vue'
|
||||||
|
|
||||||
import TaskService from '../../services/task'
|
import TaskService from '../../services/task'
|
||||||
import TaskModel from '../../models/task'
|
import TaskModel from '../../models/task'
|
||||||
import priorities from '../../models/constants/priorities'
|
import {PRIORITIES as priorities} from '@/constants/priorities'
|
||||||
import PriorityLabel from './partials/priorityLabel'
|
import PriorityLabel from './partials/priorityLabel.vue'
|
||||||
import TaskCollectionService from '../../services/taskCollection'
|
import TaskCollectionService from '../../services/taskCollection'
|
||||||
import {mapState} from 'vuex'
|
import {RIGHTS as Rights} from '@/constants/rights'
|
||||||
import Rights from '../../models/constants/rights.json'
|
|
||||||
import FilterPopup from '@/components/list/partials/filter-popup.vue'
|
import FilterPopup from '@/components/list/partials/filter-popup.vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
||||||
|
import {formatDate} from '@/helpers/time/formatDate'
|
||||||
|
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'GanttChart',
|
name: 'GanttChart',
|
||||||
|
@ -255,7 +258,7 @@ export default defineComponent({
|
||||||
mounted() {
|
mounted() {
|
||||||
this.buildTheGanttChart()
|
this.buildTheGanttChart()
|
||||||
},
|
},
|
||||||
computed: mapState({
|
computed: mapState(useBaseStore, {
|
||||||
canWrite: (state) => state.currentList.maxRight > Rights.READ,
|
canWrite: (state) => state.currentList.maxRight > Rights.READ,
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -275,13 +278,13 @@ export default defineComponent({
|
||||||
prepareGanttDays() {
|
prepareGanttDays() {
|
||||||
console.debug('prepareGanttDays; start date: ', this.startDate, 'end date:', this.endDate)
|
console.debug('prepareGanttDays; start date: ', this.startDate, 'end date:', this.endDate)
|
||||||
// Layout: years => [months => [days]]
|
// Layout: years => [months => [days]]
|
||||||
let years = {}
|
const years = {}
|
||||||
for (
|
for (
|
||||||
let d = this.startDate;
|
let d = this.startDate;
|
||||||
d <= this.endDate;
|
d <= this.endDate;
|
||||||
d.setDate(d.getDate() + 1)
|
d.setDate(d.getDate() + 1)
|
||||||
) {
|
) {
|
||||||
let date = new Date(d)
|
const date = new Date(d)
|
||||||
if (years[date.getFullYear() + ''] === undefined) {
|
if (years[date.getFullYear() + ''] === undefined) {
|
||||||
years[date.getFullYear() + ''] = {}
|
years[date.getFullYear() + ''] = {}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +353,7 @@ export default defineComponent({
|
||||||
|
|
||||||
const didntHaveDates = newTask.startDate === null ? true : false
|
const didntHaveDates = newTask.startDate === null ? true : false
|
||||||
|
|
||||||
let startDate = new Date(this.startDate)
|
const startDate = new Date(this.startDate)
|
||||||
startDate.setDate(
|
startDate.setDate(
|
||||||
startDate.getDate() + newRect.left / this.dayWidth,
|
startDate.getDate() + newRect.left / this.dayWidth,
|
||||||
)
|
)
|
||||||
|
@ -359,7 +362,7 @@ export default defineComponent({
|
||||||
startDate.setUTCSeconds(0)
|
startDate.setUTCSeconds(0)
|
||||||
startDate.setUTCMilliseconds(0)
|
startDate.setUTCMilliseconds(0)
|
||||||
newTask.startDate = startDate
|
newTask.startDate = startDate
|
||||||
let endDate = new Date(startDate)
|
const endDate = new Date(startDate)
|
||||||
endDate.setDate(
|
endDate.setDate(
|
||||||
startDate.getDate() + newRect.width / this.dayWidth,
|
startDate.getDate() + newRect.width / this.dayWidth,
|
||||||
)
|
)
|
||||||
|
@ -427,7 +430,7 @@ export default defineComponent({
|
||||||
if (!this.newTaskFieldActive) {
|
if (!this.newTaskFieldActive) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let task = new TaskModel({
|
const task = new TaskModel({
|
||||||
title: this.newTaskTitle,
|
title: this.newTaskTitle,
|
||||||
listId: this.listId,
|
listId: this.listId,
|
||||||
})
|
})
|
||||||
|
@ -439,7 +442,7 @@ export default defineComponent({
|
||||||
formatMonthAndYear(year, month) {
|
formatMonthAndYear(year, month) {
|
||||||
month = month < 10 ? '0' + month : month
|
month = month < 10 ? '0' + month : month
|
||||||
const date = new Date(`${year}-${month}-01`)
|
const date = new Date(`${year}-${month}-01`)
|
||||||
return this.format(date, 'MMMM, yyyy')
|
return formatDate(date, 'MMMM, yyyy')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
:disabled="attachmentService.loading || undefined"
|
v-if="editEnabled"
|
||||||
|
:disabled="loading || undefined"
|
||||||
@change="uploadNewAttachment()"
|
@change="uploadNewAttachment()"
|
||||||
id="files"
|
id="files"
|
||||||
multiple
|
multiple
|
||||||
ref="files"
|
ref="filesRef"
|
||||||
type="file"
|
type="file"
|
||||||
v-if="editEnabled"
|
|
||||||
/>
|
/>
|
||||||
<progress
|
<progress
|
||||||
|
v-if="attachmentService.uploadProgress > 0"
|
||||||
:value="attachmentService.uploadProgress"
|
:value="attachmentService.uploadProgress"
|
||||||
class="progress is-primary"
|
class="progress is-primary"
|
||||||
max="100"
|
max="100"
|
||||||
v-if="attachmentService.uploadProgress > 0"
|
|
||||||
>
|
>
|
||||||
{{ attachmentService.uploadProgress }}%
|
{{ attachmentService.uploadProgress }}%
|
||||||
</progress>
|
</progress>
|
||||||
|
@ -35,21 +35,29 @@
|
||||||
:key="a.id"
|
:key="a.id"
|
||||||
@click="viewOrDownload(a)"
|
@click="viewOrDownload(a)"
|
||||||
>
|
>
|
||||||
<div class="filename">{{ a.file.name }}</div>
|
<div class="filename">
|
||||||
|
{{ a.file.name }}
|
||||||
|
<span
|
||||||
|
v-if="task.coverImageAttachmentId === a.id"
|
||||||
|
class="is-task-cover"
|
||||||
|
>
|
||||||
|
{{ $t('task.attachment.usedAsCover') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<p class="attachment-info-meta">
|
<p class="attachment-info-meta">
|
||||||
<i18n-t keypath="task.attachment.createdBy">
|
<i18n-t keypath="task.attachment.createdBy" scope="global">
|
||||||
<span v-tooltip="formatDate(a.created)">
|
<span v-tooltip="formatDateLong(a.created)">
|
||||||
{{ formatDateSince(a.created) }}
|
{{ formatDateSince(a.created) }}
|
||||||
</span>
|
</span>
|
||||||
<user
|
<User
|
||||||
:avatar-size="24"
|
:avatar-size="24"
|
||||||
:user="a.createdBy"
|
:user="a.createdBy"
|
||||||
:is-inline="true"
|
:is-inline="true"
|
||||||
/>
|
/>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
<span>
|
<span>
|
||||||
{{ a.file.getHumanSize() }}
|
{{ getHumanSize(a.file.size) }}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="a.file.mime">
|
<span v-if="a.file.mime">
|
||||||
{{ a.file.mime }}
|
{{ a.file.mime }}
|
||||||
|
@ -73,11 +81,22 @@
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="editEnabled"
|
v-if="editEnabled"
|
||||||
class="attachment-info-meta-button"
|
class="attachment-info-meta-button"
|
||||||
@click.prevent.stop="() => {attachmentToDelete = a; showDeleteModal = true}"
|
@click.prevent.stop="setAttachmentToDelete(a)"
|
||||||
v-tooltip="$t('task.attachment.deleteTooltip')"
|
v-tooltip="$t('task.attachment.deleteTooltip')"
|
||||||
>
|
>
|
||||||
{{ $t('misc.delete') }}
|
{{ $t('misc.delete') }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
|
<BaseButton
|
||||||
|
v-if="editEnabled"
|
||||||
|
class="attachment-info-meta-button"
|
||||||
|
@click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
task.coverImageAttachmentId === a.id
|
||||||
|
? $t('task.attachment.unsetAsCover')
|
||||||
|
: $t('task.attachment.setAsCover')
|
||||||
|
}}
|
||||||
|
</BaseButton>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -85,8 +104,8 @@
|
||||||
|
|
||||||
<x-button
|
<x-button
|
||||||
v-if="editEnabled"
|
v-if="editEnabled"
|
||||||
:disabled="attachmentService.loading"
|
:disabled="loading"
|
||||||
@click="$refs.files.click()"
|
@click="filesRef?.click()"
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
icon="cloud-upload-alt"
|
icon="cloud-upload-alt"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
|
@ -97,7 +116,7 @@
|
||||||
|
|
||||||
<!-- Dropzone -->
|
<!-- Dropzone -->
|
||||||
<div
|
<div
|
||||||
:class="{ hidden: !showDropzone }"
|
:class="{ hidden: !isOverDropZone }"
|
||||||
class="dropzone"
|
class="dropzone"
|
||||||
v-if="editEnabled"
|
v-if="editEnabled"
|
||||||
>
|
>
|
||||||
|
@ -110,13 +129,14 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Delete modal -->
|
<!-- Delete modal -->
|
||||||
<transition name="modal">
|
|
||||||
<modal
|
<modal
|
||||||
@close="showDeleteModal = false"
|
v-if="attachmentToDelete !== null"
|
||||||
v-if="showDeleteModal"
|
@close="setAttachmentToDelete(null)"
|
||||||
@submit="deleteAttachment()"
|
@submit="deleteAttachment()"
|
||||||
>
|
>
|
||||||
<template #header><span>{{ $t('task.attachment.delete') }}</span></template>
|
<template #header>
|
||||||
|
<span>{{ $t('task.attachment.delete') }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #text>
|
<template #text>
|
||||||
<p>
|
<p>
|
||||||
|
@ -125,150 +145,130 @@
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</transition>
|
|
||||||
|
|
||||||
<transition name="modal">
|
<!-- Attachment image modal -->
|
||||||
<modal
|
<modal
|
||||||
@close="
|
v-if="attachmentImageBlobUrl !== null"
|
||||||
() => {
|
@close="attachmentImageBlobUrl = null"
|
||||||
showImageModal = false
|
|
||||||
attachmentImageBlobUrl = null
|
|
||||||
}
|
|
||||||
"
|
|
||||||
v-if="showImageModal"
|
|
||||||
>
|
>
|
||||||
<img :src="attachmentImageBlobUrl" alt=""/>
|
<img :src="attachmentImageBlobUrl" alt=""/>
|
||||||
</modal>
|
</modal>
|
||||||
</transition>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {ref, shallowReactive, computed} from 'vue'
|
||||||
|
import {useDropZone} from '@vueuse/core'
|
||||||
|
|
||||||
import AttachmentService from '../../../services/attachment'
|
import User from '@/components/misc/user.vue'
|
||||||
import AttachmentModel from '../../../models/attachment'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import User from '../../misc/user'
|
|
||||||
import {mapState} from 'vuex'
|
|
||||||
|
|
||||||
import { useCopyToClipboard } from '@/composables/useCopyToClipboard'
|
import AttachmentService from '@/services/attachment'
|
||||||
|
import {SUPPORTED_IMAGE_SUFFIX} from '@/models/attachment'
|
||||||
|
import type AttachmentModel from '@/models/attachment'
|
||||||
|
import type {IAttachment} from '@/modelTypes/IAttachment'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
|
||||||
|
import {useAttachmentStore} from '@/stores/attachments'
|
||||||
|
import {formatDateSince, formatDateLong} from '@/helpers/time/formatDate'
|
||||||
import {uploadFiles, generateAttachmentUrl} from '@/helpers/attachments'
|
import {uploadFiles, generateAttachmentUrl} from '@/helpers/attachments'
|
||||||
|
import {getHumanSize} from '@/helpers/getHumanSize'
|
||||||
|
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
|
||||||
|
import {error, success} from '@/message'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton'
|
const taskStore = useTaskStore()
|
||||||
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
export default defineComponent({
|
const props = withDefaults(defineProps<{
|
||||||
name: 'attachments',
|
task: ITask,
|
||||||
components: {
|
initialAttachments?: IAttachment[],
|
||||||
BaseButton,
|
editEnabled: boolean,
|
||||||
User,
|
}>(), {
|
||||||
},
|
editEnabled: true,
|
||||||
data() {
|
})
|
||||||
return {
|
|
||||||
attachmentService: new AttachmentService(),
|
|
||||||
showDropzone: false,
|
|
||||||
|
|
||||||
showDeleteModal: false,
|
// FIXME: this should go through the store
|
||||||
attachmentToDelete: AttachmentModel,
|
const emit = defineEmits(['task-changed'])
|
||||||
|
|
||||||
showImageModal: false,
|
const attachmentService = shallowReactive(new AttachmentService())
|
||||||
attachmentImageBlobUrl: null,
|
|
||||||
|
const attachmentStore = useAttachmentStore()
|
||||||
|
const attachments = computed(() => attachmentStore.attachments)
|
||||||
|
|
||||||
|
const loading = computed(() => attachmentService.loading || taskStore.isLoading)
|
||||||
|
|
||||||
|
function onDrop(files: File[] | null) {
|
||||||
|
if (files && files.length !== 0) {
|
||||||
|
uploadFilesToTask(files)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
props: {
|
|
||||||
taskId: {
|
|
||||||
required: true,
|
|
||||||
type: Number,
|
|
||||||
},
|
|
||||||
initialAttachments: {
|
|
||||||
type: Array,
|
|
||||||
},
|
|
||||||
editEnabled: {
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup(props) {
|
|
||||||
const copy = useCopyToClipboard()
|
|
||||||
|
|
||||||
function copyUrl(attachment: AttachmentModel) {
|
|
||||||
copy(generateAttachmentUrl(props.taskId, attachment.id))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { copyUrl }
|
const {isOverDropZone} = useDropZone(document, onDrop)
|
||||||
},
|
|
||||||
|
|
||||||
computed: mapState({
|
function downloadAttachment(attachment: IAttachment) {
|
||||||
attachments: (state) => state.attachments.attachments,
|
attachmentService.download(attachment)
|
||||||
}),
|
}
|
||||||
mounted() {
|
|
||||||
document.addEventListener('dragenter', (e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
this.showDropzone = true
|
|
||||||
})
|
|
||||||
|
|
||||||
window.addEventListener('dragleave', (e) => {
|
const filesRef = ref<HTMLInputElement | null>(null)
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
this.showDropzone = false
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('dragover', (e) => {
|
function uploadNewAttachment() {
|
||||||
e.stopPropagation()
|
const files = filesRef.value?.files
|
||||||
e.preventDefault()
|
|
||||||
this.showDropzone = true
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('drop', (e) => {
|
if (!files || files.length === 0) {
|
||||||
e.stopPropagation()
|
return
|
||||||
e.preventDefault()
|
}
|
||||||
|
|
||||||
let files = e.dataTransfer.files
|
uploadFilesToTask(files)
|
||||||
this.uploadFiles(files)
|
}
|
||||||
this.showDropzone = false
|
|
||||||
})
|
function uploadFilesToTask(files: File[] | FileList) {
|
||||||
},
|
uploadFiles(attachmentService, props.task.id, files)
|
||||||
methods: {
|
}
|
||||||
downloadAttachment(attachment) {
|
|
||||||
this.attachmentService.download(attachment)
|
const attachmentToDelete = ref<AttachmentModel | null>(null)
|
||||||
},
|
|
||||||
uploadNewAttachment() {
|
function setAttachmentToDelete(attachment: AttachmentModel | null) {
|
||||||
if (this.$refs.files.files.length === 0) {
|
attachmentToDelete.value = attachment
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteAttachment() {
|
||||||
|
if (attachmentToDelete.value === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.uploadFiles(this.$refs.files.files)
|
|
||||||
},
|
|
||||||
uploadFiles(files) {
|
|
||||||
uploadFiles(this.attachmentService, this.taskId, files)
|
|
||||||
},
|
|
||||||
async deleteAttachment() {
|
|
||||||
try {
|
try {
|
||||||
const r = await this.attachmentService.delete(this.attachmentToDelete)
|
const r = await attachmentService.delete(attachmentToDelete.value)
|
||||||
this.$store.commit(
|
attachmentStore.removeById(attachmentToDelete.value.id)
|
||||||
'attachments/removeById',
|
success(r)
|
||||||
this.attachmentToDelete.id,
|
setAttachmentToDelete(null)
|
||||||
)
|
} catch (e) {
|
||||||
this.$message.success(r)
|
error(e)
|
||||||
} finally{
|
|
||||||
this.showDeleteModal = false
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
async viewOrDownload(attachment) {
|
|
||||||
if (
|
const attachmentImageBlobUrl = ref<string | null>(null)
|
||||||
attachment.file.name.endsWith('.jpg') ||
|
|
||||||
attachment.file.name.endsWith('.png') ||
|
async function viewOrDownload(attachment: AttachmentModel) {
|
||||||
attachment.file.name.endsWith('.bmp') ||
|
if (SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.endsWith(suffix))) {
|
||||||
attachment.file.name.endsWith('.gif')
|
attachmentImageBlobUrl.value = await attachmentService.getBlobUrl(attachment)
|
||||||
) {
|
|
||||||
this.showImageModal = true
|
|
||||||
this.attachmentImageBlobUrl = await this.attachmentService.getBlobUrl(attachment)
|
|
||||||
} else {
|
} else {
|
||||||
this.downloadAttachment(attachment)
|
downloadAttachment(attachment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const copy = useCopyToClipboard()
|
||||||
|
|
||||||
|
function copyUrl(attachment: IAttachment) {
|
||||||
|
copy(generateAttachmentUrl(props.task.id, attachment.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setCoverImage(attachment: IAttachment | null) {
|
||||||
|
const task = await taskStore.setCoverImage(props.task, attachment)
|
||||||
|
emit('task-changed', task)
|
||||||
|
success({message: t('task.attachment.successfullyChangedCoverImage')})
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -277,8 +277,16 @@ export default defineComponent({
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: $tablet) {
|
||||||
|
.button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.files {
|
.files {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.attachment {
|
.attachment {
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
|
@ -290,6 +298,7 @@ export default defineComponent({
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--grey-200);
|
background-color: var(--grey-200);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.filename {
|
.filename {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -312,14 +321,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: $tablet) {
|
|
||||||
.button {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropzone {
|
.dropzone {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -365,7 +366,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-info-meta {
|
.attachment-info-meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -426,5 +426,13 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.is-task-cover {
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--white);
|
||||||
|
padding: .25rem .35rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
@include modal-transition();
|
@include modal-transition();
|
||||||
</style>
|
</style>
|
|
@ -10,15 +10,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed} from 'vue'
|
import {computed, type PropType} from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import {getChecklistStatistics} from '@/helpers/checklistFromText'
|
import {getChecklistStatistics} from '@/helpers/checklistFromText'
|
||||||
import TaskModel from '@/models/task'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
task: {
|
task: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div :key="c.id" class="media comment" v-for="c in comments">
|
<div :key="c.id" class="media comment" v-for="c in comments">
|
||||||
<figure class="media-left is-hidden-mobile">
|
<figure class="media-left is-hidden-mobile">
|
||||||
<img
|
<img
|
||||||
:src="c.author.getAvatarUrl(48)"
|
:src="getAvatarUrl(c.author, 48)"
|
||||||
alt=""
|
alt=""
|
||||||
class="image is-avatar"
|
class="image is-avatar"
|
||||||
height="48"
|
height="48"
|
||||||
|
@ -27,19 +27,19 @@
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
<div class="comment-info">
|
<div class="comment-info">
|
||||||
<img
|
<img
|
||||||
:src="c.author.getAvatarUrl(20)"
|
:src="getAvatarUrl(c.author, 20)"
|
||||||
alt=""
|
alt=""
|
||||||
class="image is-avatar d-print-none"
|
class="image is-avatar d-print-none"
|
||||||
height="20"
|
height="20"
|
||||||
width="20"
|
width="20"
|
||||||
/>
|
/>
|
||||||
<strong>{{ c.author.getDisplayName() }}</strong>
|
<strong>{{ getDisplayName(c.author) }}</strong>
|
||||||
<span v-tooltip="formatDate(c.created)" class="has-text-grey">
|
<span v-tooltip="formatDateLong(c.created)" class="has-text-grey">
|
||||||
{{ formatDateSince(c.created) }}
|
{{ formatDateSince(c.created) }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="+new Date(c.created) !== +new Date(c.updated)"
|
v-if="+new Date(c.created) !== +new Date(c.updated)"
|
||||||
v-tooltip="formatDate(c.updated)"
|
v-tooltip="formatDateLong(c.updated)"
|
||||||
>
|
>
|
||||||
· {{ $t('task.comment.edited', {date: formatDateSince(c.updated)}) }}
|
· {{ $t('task.comment.edited', {date: formatDateSince(c.updated)}) }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -70,13 +70,13 @@
|
||||||
:is-edit-enabled="canWrite && c.author.id === currentUserId"
|
:is-edit-enabled="canWrite && c.author.id === currentUserId"
|
||||||
:upload-callback="attachmentUpload"
|
:upload-callback="attachmentUpload"
|
||||||
:upload-enabled="true"
|
:upload-enabled="true"
|
||||||
@change="
|
v-model="c.comment"
|
||||||
|
@update:model-value="
|
||||||
() => {
|
() => {
|
||||||
toggleEdit(c)
|
toggleEdit(c)
|
||||||
editComment()
|
editComment()
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
v-model="c.comment"
|
|
||||||
:bottom-actions="actions[c.id]"
|
:bottom-actions="actions[c.id]"
|
||||||
:show-save="true"
|
:show-save="true"
|
||||||
/>
|
/>
|
||||||
|
@ -153,15 +153,22 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, reactive, computed, shallowReactive, watch, nextTick} from 'vue'
|
import {ref, reactive, computed, shallowReactive, watch, nextTick} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import Editor from '@/components/input/AsyncEditor'
|
import Editor from '@/components/input/AsyncEditor'
|
||||||
|
|
||||||
import TaskCommentService from '@/services/taskComment'
|
import TaskCommentService from '@/services/taskComment'
|
||||||
import TaskCommentModel from '@/models/taskComment'
|
import TaskCommentModel from '@/models/taskComment'
|
||||||
|
|
||||||
|
import type {ITaskComment} from '@/modelTypes/ITaskComment'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
|
||||||
import {uploadFile} from '@/helpers/attachments'
|
import {uploadFile} from '@/helpers/attachments'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||||
|
import {getAvatarUrl, getDisplayName} from '@/models/user'
|
||||||
|
import {useConfigStore} from '@/stores/config'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
taskId: {
|
taskId: {
|
||||||
|
@ -174,9 +181,10 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
const store = useStore()
|
const configStore = useConfigStore()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const comments = ref<TaskCommentModel[]>([])
|
const comments = ref<ITaskComment[]>([])
|
||||||
|
|
||||||
const showDeleteModal = ref(false)
|
const showDeleteModal = ref(false)
|
||||||
const commentToDelete = reactive(new TaskCommentModel())
|
const commentToDelete = reactive(new TaskCommentModel())
|
||||||
|
@ -186,12 +194,12 @@ const commentEdit = reactive(new TaskCommentModel())
|
||||||
|
|
||||||
const newComment = reactive(new TaskCommentModel())
|
const newComment = reactive(new TaskCommentModel())
|
||||||
|
|
||||||
const saved = ref(null)
|
const saved = ref<ITask['id'] | null>(null)
|
||||||
const saving = ref(null)
|
const saving = ref<ITask['id'] | null>(null)
|
||||||
|
|
||||||
const userAvatar = computed(() => store.state.auth.info.getAvatarUrl(48))
|
const userAvatar = computed(() => getAvatarUrl(authStore.info, 48))
|
||||||
const currentUserId = computed(() => store.state.auth.info.id)
|
const currentUserId = computed(() => authStore.info.id)
|
||||||
const enabled = computed(() => store.state.config.taskCommentsEnabled)
|
const enabled = computed(() => configStore.taskCommentsEnabled)
|
||||||
const actions = computed(() => {
|
const actions = computed(() => {
|
||||||
if (!props.canWrite) {
|
if (!props.canWrite) {
|
||||||
return {}
|
return {}
|
||||||
|
@ -207,13 +215,18 @@ const actions = computed(() => {
|
||||||
])))
|
])))
|
||||||
})
|
})
|
||||||
|
|
||||||
function attachmentUpload(...args) {
|
function attachmentUpload(
|
||||||
return uploadFile(props.taskId, ...args)
|
file: File,
|
||||||
|
onSuccess: (url: string) => void,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
onError: (error: string) => void,
|
||||||
|
) {
|
||||||
|
return uploadFile(props.taskId, file, onSuccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskCommentService = shallowReactive(new TaskCommentService())
|
const taskCommentService = shallowReactive(new TaskCommentService())
|
||||||
|
|
||||||
async function loadComments(taskId) {
|
async function loadComments(taskId: ITask['id']) {
|
||||||
if (!enabled.value) {
|
if (!enabled.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -257,12 +270,12 @@ async function addComment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEdit(comment: TaskCommentModel) {
|
function toggleEdit(comment: ITaskComment) {
|
||||||
isCommentEdit.value = !isCommentEdit.value
|
isCommentEdit.value = !isCommentEdit.value
|
||||||
Object.assign(commentEdit, comment)
|
Object.assign(commentEdit, comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDelete(commentId) {
|
function toggleDelete(commentId: ITaskComment['id']) {
|
||||||
showDeleteModal.value = !showDeleteModal.value
|
showDeleteModal.value = !showDeleteModal.value
|
||||||
commentToDelete.id = commentId
|
commentToDelete.id = commentId
|
||||||
}
|
}
|
||||||
|
@ -292,7 +305,7 @@ async function editComment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteComment(commentToDelete: TaskCommentModel) {
|
async function deleteComment(commentToDelete: ITaskComment) {
|
||||||
try {
|
try {
|
||||||
await taskCommentService.delete(commentToDelete)
|
await taskCommentService.delete(commentToDelete)
|
||||||
const index = comments.value.findIndex(({id}) => id === commentToDelete.id)
|
const index = comments.value.findIndex(({id}) => id === commentToDelete.id)
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<p class="created">
|
<p class="created">
|
||||||
<time :datetime="formatISO(task.created)" v-tooltip="formatDate(task.created)">
|
<time :datetime="formatISO(task.created)" v-tooltip="formatDateLong(task.created)">
|
||||||
<i18n-t keypath="task.detail.created">
|
<i18n-t keypath="task.detail.created" scope="global">
|
||||||
<span>{{ formatDateSince(task.created) }}</span>
|
<span>{{ formatDateSince(task.created) }}</span>
|
||||||
{{ task.createdBy.getDisplayName() }}
|
{{ getDisplayName(task.createdBy) }}
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</time>
|
</time>
|
||||||
<template v-if="+new Date(task.created) !== +new Date(task.updated)">
|
<template v-if="+new Date(task.created) !== +new Date(task.updated)">
|
||||||
<br/>
|
<br/>
|
||||||
<!-- Computed properties to show the actual date every time it gets updated -->
|
<!-- Computed properties to show the actual date every time it gets updated -->
|
||||||
<time :datetime="formatISO(task.updated)" v-tooltip="updatedFormatted">
|
<time :datetime="formatISO(task.updated)" v-tooltip="updatedFormatted">
|
||||||
<i18n-t keypath="task.detail.updated">
|
<i18n-t keypath="task.detail.updated" scope="global">
|
||||||
<span>{{ updatedSince }}</span>
|
<span>{{ updatedSince }}</span>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</time>
|
</time>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<template v-if="task.done">
|
<template v-if="task.done">
|
||||||
<br/>
|
<br/>
|
||||||
<time :datetime="formatISO(task.doneAt)" v-tooltip="doneFormatted">
|
<time :datetime="formatISO(task.doneAt)" v-tooltip="doneFormatted">
|
||||||
<i18n-t keypath="task.detail.doneAt">
|
<i18n-t keypath="task.detail.doneAt" scope="global">
|
||||||
<span>{{ doneSince }}</span>
|
<span>{{ doneSince }}</span>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</time>
|
</time>
|
||||||
|
@ -27,13 +27,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, toRefs} from 'vue'
|
import {computed, toRefs, type PropType} from 'vue'
|
||||||
import TaskModel from '@/models/task'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
import {formatISO, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||||
|
import {getDisplayName} from '@/models/user'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
task: {
|
task: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<td v-tooltip="+date === 0 ? '' : formatDate(date)">
|
<td v-tooltip="+date === 0 ? '' : formatDateLong(date)">
|
||||||
<time :datetime="date ? formatISO(date) : null">
|
<time :datetime="date ? formatISO(date) : undefined">
|
||||||
{{ +date === 0 ? '-' : formatDateSince(date) }}
|
{{ +date === 0 ? '-' : formatDateSince(date) }}
|
||||||
</time>
|
</time>
|
||||||
</td>
|
</td>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import {formatISO, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
date: {
|
date: {
|
||||||
type: Date,
|
type: Date,
|
||||||
|
|
|
@ -38,37 +38,37 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount} from 'vue'
|
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount, toRef, type PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import flatPickr from 'vue-flatpickr-component'
|
import flatPickr from 'vue-flatpickr-component'
|
||||||
|
|
||||||
import TaskService from '@/services/task'
|
import TaskService from '@/services/task'
|
||||||
import TaskModel from '@/models/task'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
const store = useStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const taskService = shallowReactive(new TaskService())
|
const taskService = shallowReactive(new TaskService())
|
||||||
const task = ref<TaskModel>()
|
const task = ref<ITask>()
|
||||||
|
|
||||||
// We're saving the due date seperately to prevent null errors in very short periods where the task is null.
|
// We're saving the due date seperately to prevent null errors in very short periods where the task is null.
|
||||||
const dueDate = ref<Date>()
|
const dueDate = ref<Date>()
|
||||||
const lastValue = ref<Date>()
|
const lastValue = ref<Date>()
|
||||||
const changeInterval = ref<number>()
|
const changeInterval = ref<ReturnType<typeof setInterval>>()
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
toRef(props, 'modelValue'),
|
||||||
(value) => {
|
(value) => {
|
||||||
task.value = value
|
task.value = { ...value }
|
||||||
dueDate.value = value.dueDate
|
dueDate.value = value.dueDate
|
||||||
lastValue.value = value.dueDate
|
lastValue.value = value.dueDate
|
||||||
},
|
},
|
||||||
|
@ -103,7 +103,7 @@ const flatPickerConfig = computed(() => ({
|
||||||
time_24hr: true,
|
time_24hr: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: store.state.auth.settings.weekStart,
|
firstDayOfWeek: authStore.settings.weekStart,
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -123,9 +123,10 @@ async function updateDueDate() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: direct prop manipulation
|
const newTask = await taskService.update({
|
||||||
task.value.dueDate = new Date(dueDate.value)
|
...task.value,
|
||||||
const newTask = await taskService.update(task.value)
|
dueDate: new Date(dueDate.value),
|
||||||
|
})
|
||||||
lastValue.value = newTask.dueDate
|
lastValue.value = newTask.dueDate
|
||||||
task.value = newTask
|
task.value = newTask
|
||||||
emit('update:modelValue', newTask)
|
emit('update:modelValue', newTask)
|
||||||
|
|
|
@ -20,47 +20,50 @@
|
||||||
:is-edit-enabled="canWrite"
|
:is-edit-enabled="canWrite"
|
||||||
:upload-callback="attachmentUpload"
|
:upload-callback="attachmentUpload"
|
||||||
:upload-enabled="true"
|
:upload-enabled="true"
|
||||||
@change="save"
|
|
||||||
:placeholder="$t('task.description.placeholder')"
|
:placeholder="$t('task.description.placeholder')"
|
||||||
:empty-text="$t('task.description.empty')"
|
:empty-text="$t('task.description.empty')"
|
||||||
:show-save="true"
|
:show-save="true"
|
||||||
|
edit-shortcut="e"
|
||||||
v-model="task.description"
|
v-model="task.description"
|
||||||
|
@update:model-value="save"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref,computed, watch} from 'vue'
|
import {ref,computed, watch, type PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
|
|
||||||
import Editor from '@/components/input/AsyncEditor'
|
import Editor from '@/components/input/AsyncEditor'
|
||||||
|
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
import TaskModel from '@/models/task'
|
import TaskModel from '@/models/task'
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
attachmentUpload: {
|
attachmentUpload: {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
canWrite: {
|
canWrite: {
|
||||||
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const task = ref<TaskModel>({description: ''})
|
const task = ref<ITask>(new TaskModel())
|
||||||
const saved = ref(false)
|
const saved = ref(false)
|
||||||
|
|
||||||
// Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.
|
// Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
|
|
||||||
const store = useStore()
|
const taskStore = useTaskStore()
|
||||||
const loading = computed(() => store.state.loading)
|
const loading = computed(() => taskStore.isLoading)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
|
@ -75,7 +78,7 @@ async function save() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// FIXME: don't update state from internal.
|
// FIXME: don't update state from internal.
|
||||||
task.value = await store.dispatch('tasks/update', task.value)
|
task.value = await taskStore.update(task.value)
|
||||||
emit('update:modelValue', task.value)
|
emit('update:modelValue', task.value)
|
||||||
|
|
||||||
saved.value = true
|
saved.value = true
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
@search="findUser"
|
@search="findUser"
|
||||||
:search-results="foundUsers"
|
:search-results="foundUsers"
|
||||||
@select="addAssignee"
|
@select="addAssignee"
|
||||||
label="username"
|
label="name"
|
||||||
:select-placeholder="$t('task.assignee.selectPlaceholder')"
|
:select-placeholder="$t('task.assignee.selectPlaceholder')"
|
||||||
v-model="assignees"
|
v-model="assignees"
|
||||||
ref="multiselect"
|
ref="multiselect"
|
||||||
|
@ -28,8 +28,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, shallowReactive, watch, PropType} from 'vue'
|
import {ref, shallowReactive, watch, nextTick, type PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import User from '@/components/misc/user.vue'
|
import User from '@/components/misc/user.vue'
|
||||||
|
@ -37,9 +36,11 @@ import Multiselect from '@/components/input/multiselect.vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
import {includesById} from '@/helpers/utils'
|
import {includesById} from '@/helpers/utils'
|
||||||
import UserModel from '@/models/user'
|
|
||||||
import ListUserService from '@/services/listUsers'
|
import ListUserService from '@/services/listUsers'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
|
import type {IUser} from '@/modelTypes/IUser'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
taskId: {
|
taskId: {
|
||||||
|
@ -54,18 +55,19 @@ const props = defineProps({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array as PropType<UserModel[]>,
|
type: Array as PropType<IUser[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const store = useStore()
|
const taskStore = useTaskStore()
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const listUserService = shallowReactive(new ListUserService())
|
const listUserService = shallowReactive(new ListUserService())
|
||||||
const foundUsers = ref([])
|
const foundUsers = ref([])
|
||||||
const assignees = ref<UserModel[]>([])
|
const assignees = ref<IUser[]>([])
|
||||||
|
let isAdding = false
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
|
@ -78,14 +80,24 @@ watch(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
async function addAssignee(user: UserModel) {
|
async function addAssignee(user: IUser) {
|
||||||
await store.dispatch('tasks/addAssignee', {user: user, taskId: props.taskId})
|
if (isAdding) {
|
||||||
emit('update:modelValue', assignees.value)
|
return
|
||||||
success({message: t('task.assignee.assignSuccess')})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeAssignee(user: UserModel) {
|
try {
|
||||||
await store.dispatch('tasks/removeAssignee', {user: user, taskId: props.taskId})
|
nextTick(() => isAdding = true)
|
||||||
|
|
||||||
|
await taskStore.addAssignee({user: user, taskId: props.taskId})
|
||||||
|
emit('update:modelValue', assignees.value)
|
||||||
|
success({message: t('task.assignee.assignSuccess')})
|
||||||
|
} finally {
|
||||||
|
nextTick(() => isAdding = false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeAssignee(user: IUser) {
|
||||||
|
await taskStore.removeAssignee({user: user, taskId: props.taskId})
|
||||||
|
|
||||||
// Remove the assignee from the list
|
// Remove the assignee from the list
|
||||||
for (const a in assignees.value) {
|
for (const a in assignees.value) {
|
||||||
|
@ -106,6 +118,11 @@ async function findUser(query: string) {
|
||||||
|
|
||||||
// Filter the results to not include users who are already assigned
|
// Filter the results to not include users who are already assigned
|
||||||
foundUsers.value = response.filter(({id}) => !includesById(assignees.value, id))
|
foundUsers.value = response.filter(({id}) => !includesById(assignees.value, id))
|
||||||
|
.map(u => {
|
||||||
|
// Users may not have a display name set, so we fall back on the username in that case
|
||||||
|
u.name = u.name === '' ? u.username : u.name
|
||||||
|
return u
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAllFoundUsers() {
|
function clearAllFoundUsers() {
|
||||||
|
@ -113,6 +130,7 @@ function clearAllFoundUsers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const multiselect = ref()
|
const multiselect = ref()
|
||||||
|
|
||||||
function focus() {
|
function focus() {
|
||||||
multiselect.value.focus()
|
multiselect.value.focus()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {PropType, ref, computed, shallowReactive, watch} from 'vue'
|
import {type PropType, ref, computed, shallowReactive, watch} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import LabelModel from '@/models/label'
|
import LabelModel from '@/models/label'
|
||||||
|
@ -49,10 +48,13 @@ import {success} from '@/message'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
|
import type {ILabel} from '@/modelTypes/ILabel'
|
||||||
|
import {useLabelStore} from '@/stores/labels'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array as PropType<LabelModel[]>,
|
type: Array as PropType<ILabel[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
taskId: {
|
taskId: {
|
||||||
|
@ -65,13 +67,12 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const store = useStore()
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const labelTaskService = shallowReactive(new LabelTaskService())
|
const labelTaskService = shallowReactive(new LabelTaskService())
|
||||||
const labels = ref<LabelModel[]>([])
|
const labels = ref<ILabel[]>([])
|
||||||
const query = ref('')
|
const query = ref('')
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -85,43 +86,40 @@ watch(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const foundLabels = computed(() => store.getters['labels/filterLabelsByQuery'](labels.value, query.value))
|
const taskStore = useTaskStore()
|
||||||
const loading = computed(() => labelTaskService.loading || (store.state.loading && store.state.loadingModule === 'labels'))
|
const labelStore = useLabelStore()
|
||||||
|
|
||||||
|
const foundLabels = computed(() => labelStore.filterLabelsByQuery(labels.value, query.value))
|
||||||
|
const loading = computed(() => labelTaskService.loading || labelStore.isLoading)
|
||||||
|
|
||||||
function findLabel(newQuery: string) {
|
function findLabel(newQuery: string) {
|
||||||
query.value = newQuery
|
query.value = newQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addLabel(label: LabelModel, showNotification = true) {
|
async function addLabel(label: ILabel, showNotification = true) {
|
||||||
const bubble = () => {
|
|
||||||
emit('update:modelValue', labels.value)
|
|
||||||
emit('change', labels.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.taskId === 0) {
|
if (props.taskId === 0) {
|
||||||
bubble()
|
emit('update:modelValue', labels.value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await store.dispatch('tasks/addLabel', {label, taskId: props.taskId})
|
await taskStore.addLabel({label, taskId: props.taskId})
|
||||||
bubble()
|
emit('update:modelValue', labels.value)
|
||||||
if (showNotification) {
|
if (showNotification) {
|
||||||
success({message: t('task.label.addSuccess')})
|
success({message: t('task.label.addSuccess')})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeLabel(label: LabelModel) {
|
async function removeLabel(label: ILabel) {
|
||||||
if (props.taskId !== 0) {
|
if (props.taskId !== 0) {
|
||||||
await store.dispatch('tasks/removeLabel', {label, taskId: props.taskId})
|
await taskStore.removeLabel({label, taskId: props.taskId})
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const l in labels.value) {
|
for (const l in labels.value) {
|
||||||
if (labels.value[l].id === label.id) {
|
if (labels.value[l].id === label.id) {
|
||||||
labels.value.splice(l, 1)
|
labels.value.splice(l, 1) // FIXME: l should be index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit('update:modelValue', labels.value)
|
emit('update:modelValue', labels.value)
|
||||||
emit('change', labels.value)
|
|
||||||
success({message: t('task.label.removeSuccess')})
|
success({message: t('task.label.removeSuccess')})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +128,8 @@ async function createAndAddLabel(title: string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const newLabel = await store.dispatch('labels/createLabel', new LabelModel({title}))
|
const labelStore = useLabelStore()
|
||||||
|
const newLabel = await labelStore.createLabel(new LabelModel({title}))
|
||||||
addLabel(newLabel, false)
|
addLabel(newLabel, false)
|
||||||
labels.value.push(newLabel)
|
labels.value.push(newLabel)
|
||||||
success({message: t('task.label.addCreateSuccess')})
|
success({message: t('task.label.addCreateSuccess')})
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
<div class="heading">
|
<div class="heading">
|
||||||
<BaseButton @click="copyUrl"><h1 class="title task-id">{{ textIdentifier }}</h1></BaseButton>
|
<BaseButton @click="copyUrl"><h1 class="title task-id">{{ textIdentifier }}</h1></BaseButton>
|
||||||
<Done class="heading__done" :is-done="task.done"/>
|
<Done class="heading__done" :is-done="task.done"/>
|
||||||
|
<ColorBubble
|
||||||
|
v-if="task.hexColor !== ''"
|
||||||
|
:color="task.getHexColor()"
|
||||||
|
class="mt-1 ml-2"
|
||||||
|
/>
|
||||||
<h1
|
<h1
|
||||||
class="title input"
|
class="title input"
|
||||||
:class="{'disabled': !canWrite}"
|
:class="{'disabled': !canWrite}"
|
||||||
|
@ -32,18 +37,21 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, computed} from 'vue'
|
import {ref, computed, type PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useRouter} from 'vue-router'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
import ColorBubble from '@/components/misc/colorBubble.vue'
|
||||||
import Done from '@/components/misc/Done.vue'
|
import Done from '@/components/misc/Done.vue'
|
||||||
import TaskModel from '@/models/task'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
|
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
task: {
|
task: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
canWrite: {
|
canWrite: {
|
||||||
|
@ -56,6 +64,7 @@ const emit = defineEmits(['update:task'])
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const copy = useCopyToClipboard()
|
const copy = useCopyToClipboard()
|
||||||
|
|
||||||
async function copyUrl() {
|
async function copyUrl() {
|
||||||
const route = router.resolve({name: 'task.detail', query: {taskId: props.task.id}})
|
const route = router.resolve({name: 'task.detail', query: {taskId: props.task.id}})
|
||||||
const absoluteURL = new URL(route.href, window.location.href).href
|
const absoluteURL = new URL(route.href, window.location.href).href
|
||||||
|
@ -63,8 +72,8 @@ async function copyUrl() {
|
||||||
await copy(absoluteURL)
|
await copy(absoluteURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = useStore()
|
const taskStore = useTaskStore()
|
||||||
const loading = computed(() => store.state.loading)
|
const loading = computed(() => taskStore.isLoading)
|
||||||
|
|
||||||
const textIdentifier = computed(() => props.task?.getTextIdentifier() || '')
|
const textIdentifier = computed(() => props.task?.getTextIdentifier() || '')
|
||||||
|
|
||||||
|
@ -84,7 +93,7 @@ async function save(title: string) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
saving.value = true
|
saving.value = true
|
||||||
const newTask = await store.dispatch('tasks/update', {
|
const newTask = await taskStore.update({
|
||||||
...props.task,
|
...props.task,
|
||||||
title,
|
title,
|
||||||
})
|
})
|
||||||
|
@ -93,8 +102,7 @@ async function save(title: string) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showSavedMessage.value = false
|
showSavedMessage.value = false
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,4 +112,9 @@ async function save(title: string) {
|
||||||
.heading__done {
|
.heading__done {
|
||||||
margin-left: .5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.color-bubble {
|
||||||
|
height: .75rem;
|
||||||
|
width: .75rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -6,11 +6,18 @@
|
||||||
'draggable': !(loadingInternal || loading),
|
'draggable': !(loadingInternal || loading),
|
||||||
'has-light-text': color !== TASK_DEFAULT_COLOR && !colorIsDark(color),
|
'has-light-text': color !== TASK_DEFAULT_COLOR && !colorIsDark(color),
|
||||||
}"
|
}"
|
||||||
:style="{'background-color': color !== TASK_DEFAULT_COLOR ? color : false}"
|
:style="{'background-color': color !== TASK_DEFAULT_COLOR ? color : undefined}"
|
||||||
@click.exact="openTaskDetail()"
|
@click.exact="openTaskDetail()"
|
||||||
@click.ctrl="() => toggleTaskDone(task)"
|
@click.ctrl="() => toggleTaskDone(task)"
|
||||||
@click.meta="() => toggleTaskDone(task)"
|
@click.meta="() => toggleTaskDone(task)"
|
||||||
>
|
>
|
||||||
|
<img
|
||||||
|
v-if="coverImageBlobUrl"
|
||||||
|
:src="coverImageBlobUrl"
|
||||||
|
alt=""
|
||||||
|
class="cover-image"
|
||||||
|
/>
|
||||||
|
<div class="p-2">
|
||||||
<span class="task-id">
|
<span class="task-id">
|
||||||
<Done class="kanban-card__done" :is-done="task.done" variant="small"/>
|
<Done class="kanban-card__done" :is-done="task.done" variant="small"/>
|
||||||
<template v-if="task.identifier === ''">
|
<template v-if="task.identifier === ''">
|
||||||
|
@ -24,7 +31,7 @@
|
||||||
:class="{'overdue': task.dueDate <= new Date() && !task.done}"
|
:class="{'overdue': task.dueDate <= new Date() && !task.done}"
|
||||||
class="due-date"
|
class="due-date"
|
||||||
v-if="task.dueDate > 0"
|
v-if="task.dueDate > 0"
|
||||||
v-tooltip="formatDate(task.dueDate)">
|
v-tooltip="formatDateLong(task.dueDate)">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<icon :icon="['far', 'calendar-alt']"/>
|
<icon :icon="['far', 'calendar-alt']"/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -44,11 +51,11 @@
|
||||||
<priority-label :priority="task.priority" :done="task.done"/>
|
<priority-label :priority="task.priority" :done="task.done"/>
|
||||||
<div class="assignees" v-if="task.assignees.length > 0">
|
<div class="assignees" v-if="task.assignees.length > 0">
|
||||||
<user
|
<user
|
||||||
|
v-for="u in task.assignees"
|
||||||
:avatar-size="24"
|
:avatar-size="24"
|
||||||
:key="task.id + 'assignee' + u.id"
|
:key="task.id + 'assignee' + u.id"
|
||||||
:show-username="false"
|
:show-username="false"
|
||||||
:user="u"
|
:user="u"
|
||||||
v-for="u in task.assignees"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<checklist-summary :task="task"/>
|
<checklist-summary :task="task"/>
|
||||||
|
@ -63,79 +70,83 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import {defineComponent} from 'vue'
|
import {ref, computed, watch} from 'vue'
|
||||||
|
import {useRouter} from 'vue-router'
|
||||||
|
|
||||||
import {playPop} from '../../../helpers/playPop'
|
import PriorityLabel from '@/components/tasks/partials/priorityLabel.vue'
|
||||||
import PriorityLabel from '../../../components/tasks/partials/priorityLabel'
|
import User from '@/components/misc/user.vue'
|
||||||
import User from '../../../components/misc/user'
|
|
||||||
import Done from '@/components/misc/Done.vue'
|
import Done from '@/components/misc/Done.vue'
|
||||||
import Labels from '../../../components/tasks/partials/labels'
|
import Labels from '@/components/tasks/partials/labels.vue'
|
||||||
import ChecklistSummary from './checklist-summary'
|
import ChecklistSummary from './checklist-summary.vue'
|
||||||
import {TASK_DEFAULT_COLOR} from '@/models/task'
|
|
||||||
|
|
||||||
|
import {TASK_DEFAULT_COLOR, getHexColor} from '@/models/task'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
import {SUPPORTED_IMAGE_SUFFIX} from '@/models/attachment'
|
||||||
|
import AttachmentService from '@/services/attachment'
|
||||||
|
|
||||||
|
import {formatDateLong, formatISO, formatDateSince} from '@/helpers/time/formatDate'
|
||||||
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
export default defineComponent({
|
const router = useRouter()
|
||||||
name: 'kanban-card',
|
|
||||||
components: {
|
const loadingInternal = ref(false)
|
||||||
ChecklistSummary,
|
|
||||||
Done,
|
const props = withDefaults(defineProps<{
|
||||||
PriorityLabel,
|
task: ITask,
|
||||||
User,
|
loading: boolean,
|
||||||
Labels,
|
}>(), {
|
||||||
},
|
loading: false,
|
||||||
data() {
|
})
|
||||||
return {
|
|
||||||
loadingInternal: false,
|
const color = computed(() => getHexColor(props.task.hexColor))
|
||||||
TASK_DEFAULT_COLOR,
|
|
||||||
}
|
async function toggleTaskDone(task: ITask) {
|
||||||
},
|
loadingInternal.value = true
|
||||||
props: {
|
|
||||||
task: {
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
loading: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
color() {
|
|
||||||
return this.task.getHexColor
|
|
||||||
? this.task.getHexColor()
|
|
||||||
: TASK_DEFAULT_COLOR
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
colorIsDark,
|
|
||||||
async toggleTaskDone(task) {
|
|
||||||
this.loadingInternal = true
|
|
||||||
try {
|
try {
|
||||||
const done = !task.done
|
await useTaskStore().update({
|
||||||
await this.$store.dispatch('tasks/update', {
|
|
||||||
...task,
|
...task,
|
||||||
done,
|
done: !task.done,
|
||||||
})
|
})
|
||||||
if (done) {
|
|
||||||
playPop()
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
this.loadingInternal = false
|
loadingInternal.value = false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
openTaskDetail() {
|
|
||||||
this.$router.push({
|
function openTaskDetail() {
|
||||||
|
router.push({
|
||||||
name: 'task.detail',
|
name: 'task.detail',
|
||||||
params: { id: this.task.id },
|
params: {id: props.task.id},
|
||||||
state: { backdropView: this.$router.currentRoute.value.fullPath },
|
state: {backdropView: router.currentRoute.value.fullPath},
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const coverImageBlobUrl = ref<string | null>(null)
|
||||||
|
|
||||||
|
async function maybeDownloadCoverImage() {
|
||||||
|
if (!props.task.coverImageAttachmentId) {
|
||||||
|
coverImageBlobUrl.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const attachment = props.task.attachments.find(a => a.id === props.task.coverImageAttachmentId)
|
||||||
|
if (!attachment || !SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.endsWith(suffix))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const attachmentService = new AttachmentService()
|
||||||
|
coverImageBlobUrl.value = await attachmentService.getBlobUrl(attachment)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.task.coverImageAttachmentId,
|
||||||
|
maybeDownloadCoverImage,
|
||||||
|
{immediate: true},
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -147,12 +158,11 @@ $task-background: var(--white);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: var(--shadow-xs);
|
box-shadow: var(--shadow-xs);
|
||||||
display: block;
|
display: block;
|
||||||
border: 3px solid transparent;
|
|
||||||
|
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
padding: .4rem;
|
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
background: $task-background;
|
background: $task-background;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
&.loader-container.is-loading::after {
|
&.loader-container.is-loading::after {
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type {PropType} from 'vue'
|
||||||
|
import type {ILabel} from '@/modelTypes/ILabel'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
labels: {
|
labels: {
|
||||||
|
type: Array as PropType<ILabel[]>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<multiselect
|
<Multiselect
|
||||||
class="control is-expanded"
|
class="control is-expanded"
|
||||||
:placeholder="$t('list.search')"
|
:placeholder="$t('list.search')"
|
||||||
@search="findLists"
|
@search="findLists"
|
||||||
|
@ -13,32 +13,30 @@
|
||||||
<span class="list-namespace-title search-result">{{ namespace(props.option.namespaceId) }} ></span>
|
<span class="list-namespace-title search-result">{{ namespace(props.option.namespaceId) }} ></span>
|
||||||
{{ props.option.title }}
|
{{ props.option.title }}
|
||||||
</template>
|
</template>
|
||||||
</multiselect>
|
</Multiselect>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {reactive, ref, watch} from 'vue'
|
import {reactive, ref, watch} from 'vue'
|
||||||
import type {PropType} from 'vue'
|
import type {PropType} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import ListModel from '@/models/list'
|
import ListModel from '@/models/list'
|
||||||
|
import type {IList} from '@/modelTypes/IList'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object as PropType<ListModel>,
|
type: Object as PropType<IList>,
|
||||||
validator(value) {
|
|
||||||
return value instanceof ListModel
|
|
||||||
},
|
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const store = useStore()
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const list = reactive<ListModel>(new ListModel())
|
const list: IList = reactive(new ListModel())
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
|
@ -49,21 +47,26 @@ watch(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const foundLists = ref([])
|
const listStore = useListStore()
|
||||||
|
const namespaceStore = useNamespaceStore()
|
||||||
|
const foundLists = ref<IList[]>([])
|
||||||
function findLists(query: string) {
|
function findLists(query: string) {
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
select(null)
|
select(null)
|
||||||
}
|
}
|
||||||
foundLists.value = store.getters['lists/searchList'](query)
|
foundLists.value = listStore.searchList(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
function select(l: ListModel | null) {
|
function select(l: IList | null) {
|
||||||
|
if (l === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
Object.assign(list, l)
|
Object.assign(list, l)
|
||||||
emit('update:modelValue', list)
|
emit('update:modelValue', list)
|
||||||
}
|
}
|
||||||
|
|
||||||
function namespace(namespaceId: number) {
|
function namespace(namespaceId: number) {
|
||||||
const namespace = store.getters['namespaces/getNamespaceById'](namespaceId)
|
const namespace = namespaceStore.getNamespaceById(namespaceId)
|
||||||
return namespace !== null
|
return namespace !== null
|
||||||
? namespace.title
|
? namespace.title
|
||||||
: t('list.shared')
|
: t('list.shared')
|
||||||
|
|
|
@ -32,13 +32,12 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const percentDone = computed({
|
const percentDone = computed({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
set(percentDone) {
|
set(percentDone) {
|
||||||
emit('update:modelValue', percentDone)
|
emit('update:modelValue', percentDone)
|
||||||
emit('change')
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import priorities from '@/models/constants/priorities'
|
import {PRIORITIES as priorities} from '@/constants/priorities'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
priority: {
|
priority: {
|
||||||
|
|
|
@ -5,33 +5,33 @@
|
||||||
@change="updateData"
|
@change="updateData"
|
||||||
:disabled="disabled || undefined"
|
:disabled="disabled || undefined"
|
||||||
>
|
>
|
||||||
<option :value="priorities.UNSET">{{ $t('task.priority.unset') }}</option>
|
<option :value="PRIORITIES.UNSET">{{ $t('task.priority.unset') }}</option>
|
||||||
<option :value="priorities.LOW">{{ $t('task.priority.low') }}</option>
|
<option :value="PRIORITIES.LOW">{{ $t('task.priority.low') }}</option>
|
||||||
<option :value="priorities.MEDIUM">{{ $t('task.priority.medium') }}</option>
|
<option :value="PRIORITIES.MEDIUM">{{ $t('task.priority.medium') }}</option>
|
||||||
<option :value="priorities.HIGH">{{ $t('task.priority.high') }}</option>
|
<option :value="PRIORITIES.HIGH">{{ $t('task.priority.high') }}</option>
|
||||||
<option :value="priorities.URGENT">{{ $t('task.priority.urgent') }}</option>
|
<option :value="PRIORITIES.URGENT">{{ $t('task.priority.urgent') }}</option>
|
||||||
<option :value="priorities.DO_NOW">{{ $t('task.priority.doNow') }}</option>
|
<option :value="PRIORITIES.DO_NOW">{{ $t('task.priority.doNow') }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watch} from 'vue'
|
import {ref, watch} from 'vue'
|
||||||
import priorities from '@/models/constants/priorities.json'
|
import {PRIORITIES} from '@/constants/priorities'
|
||||||
|
|
||||||
const priority = ref(0)
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
default: 0,
|
|
||||||
type: Number,
|
type: Number,
|
||||||
|
default: 0,
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
|
const priority = ref(0)
|
||||||
|
|
||||||
// FIXME: store value outside
|
// FIXME: store value outside
|
||||||
// Set the priority to the :value every time it changes from the outside
|
// Set the priority to the :value every time it changes from the outside
|
||||||
|
@ -45,6 +45,5 @@ watch(
|
||||||
|
|
||||||
function updateData() {
|
function updateData() {
|
||||||
emit('update:modelValue', priority.value)
|
emit('update:modelValue', priority.value)
|
||||||
emit('change')
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -25,49 +25,52 @@
|
||||||
</transition>
|
</transition>
|
||||||
</label>
|
</label>
|
||||||
<div class="field" key="field-search">
|
<div class="field" key="field-search">
|
||||||
<multiselect
|
<Multiselect
|
||||||
:placeholder="$t('task.relation.searchPlaceholder')"
|
:placeholder="$t('task.relation.searchPlaceholder')"
|
||||||
@search="findTasks"
|
@search="findTasks"
|
||||||
:loading="taskService.loading"
|
:loading="taskService.loading"
|
||||||
:search-results="mappedFoundTasks"
|
:search-results="mappedFoundTasks"
|
||||||
label="title"
|
label="title"
|
||||||
v-model="newTaskRelationTask"
|
v-model="newTaskRelation.task"
|
||||||
:creatable="true"
|
:creatable="true"
|
||||||
:create-placeholder="$t('task.relation.createPlaceholder')"
|
:create-placeholder="$t('task.relation.createPlaceholder')"
|
||||||
@create="createAndRelateTask"
|
@create="createAndRelateTask"
|
||||||
@select="addTaskRelation"
|
|
||||||
>
|
>
|
||||||
<template #searchResult="props">
|
<template #searchResult="{option: task}">
|
||||||
<span v-if="typeof props.option !== 'string'" class="search-result">
|
<span
|
||||||
|
v-if="typeof task !== 'string'"
|
||||||
|
class="search-result"
|
||||||
|
:class="{'is-strikethrough': task.done}"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
class="different-list"
|
class="different-list"
|
||||||
v-if="props.option.listId !== listId"
|
v-if="task.listId !== listId"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="props.option.differentNamespace !== null"
|
v-if="task.differentNamespace !== null"
|
||||||
v-tooltip="$t('task.relation.differentNamespace')">
|
v-tooltip="$t('task.relation.differentNamespace')">
|
||||||
{{ props.option.differentNamespace }} >
|
{{ task.differentNamespace }} >
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="props.option.differentList !== null"
|
v-if="task.differentList !== null"
|
||||||
v-tooltip="$t('task.relation.differentList')">
|
v-tooltip="$t('task.relation.differentList')">
|
||||||
{{ props.option.differentList }} >
|
{{ task.differentList }} >
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
{{ props.option.title }}
|
{{ task.title }}
|
||||||
</span>
|
</span>
|
||||||
<span class="search-result" v-else>
|
<span class="search-result" v-else>
|
||||||
{{ props.option }}
|
{{ task }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</multiselect>
|
</Multiselect>
|
||||||
</div>
|
</div>
|
||||||
<div class="field has-addons mb-4" key="field-kind">
|
<div class="field has-addons mb-4" key="field-kind">
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<div class="select is-fullwidth has-defaults">
|
<div class="select is-fullwidth has-defaults">
|
||||||
<select v-model="newTaskRelationKind">
|
<select v-model="newTaskRelation.kind">
|
||||||
<option value="unset">{{ $t('task.relation.select') }}</option>
|
<option value="unset">{{ $t('task.relation.select') }}</option>
|
||||||
<option :key="rk" :value="rk" v-for="rk in relationKinds">
|
<option :key="`option_${rk}`" :value="rk" v-for="rk in RELATION_KINDS">
|
||||||
{{ $tc(`task.relation.kinds.${rk}`, 1) }}
|
{{ $tc(`task.relation.kinds.${rk}`, 1) }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -84,9 +87,16 @@
|
||||||
<span class="title">{{ rts.title }}</span>
|
<span class="title">{{ rts.title }}</span>
|
||||||
<div class="tasks">
|
<div class="tasks">
|
||||||
<div :key="t.id" class="task" v-for="t in rts.tasks">
|
<div :key="t.id" class="task" v-for="t in rts.tasks">
|
||||||
|
<div class="is-flex is-align-items-center">
|
||||||
|
<Fancycheckbox
|
||||||
|
class="task-done-checkbox"
|
||||||
|
v-model="t.done"
|
||||||
|
@update:model-value="toggleTaskDone(t)"
|
||||||
|
/>
|
||||||
<router-link
|
<router-link
|
||||||
:to="{ name: $route.name, params: { id: t.id } }"
|
:to="{ name: route.name as string, params: { id: t.id } }"
|
||||||
:class="{ 'is-strikethrough': t.done}">
|
:class="{ 'is-strikethrough': t.done}"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
class="different-list"
|
class="different-list"
|
||||||
v-if="t.listId !== listId"
|
v-if="t.listId !== listId"
|
||||||
|
@ -104,9 +114,13 @@
|
||||||
</span>
|
</span>
|
||||||
{{ t.title }}
|
{{ t.title }}
|
||||||
</router-link>
|
</router-link>
|
||||||
|
</div>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="editEnabled"
|
v-if="editEnabled"
|
||||||
@click="() => {showDeleteModal = true; relationToDelete = {relationKind: rts.kind, otherTaskId: t.id}}"
|
@click="setRelationToDelete({
|
||||||
|
relationKind: rts.kind,
|
||||||
|
otherTaskId: t.id
|
||||||
|
})"
|
||||||
class="remove"
|
class="remove"
|
||||||
>
|
>
|
||||||
<icon icon="trash-alt"/>
|
<icon icon="trash-alt"/>
|
||||||
|
@ -118,12 +132,10 @@
|
||||||
{{ $t('task.relation.noneYet') }}
|
{{ $t('task.relation.noneYet') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Delete modal -->
|
|
||||||
<transition name="modal">
|
|
||||||
<modal
|
<modal
|
||||||
@close="showDeleteModal = false"
|
v-if="relationToDelete !== undefined"
|
||||||
|
@close="relationToDelete = undefined"
|
||||||
@submit="removeTaskRelation()"
|
@submit="removeTaskRelation()"
|
||||||
v-if="showDeleteModal"
|
|
||||||
>
|
>
|
||||||
<template #header><span>{{ $t('task.relation.delete') }}</span></template>
|
<template #header><span>{{ $t('task.relation.delete') }}</span></template>
|
||||||
|
|
||||||
|
@ -134,53 +146,40 @@
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</transition>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {ref, reactive, shallowReactive, watch, computed, type PropType} from 'vue'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
import {useRoute} from 'vue-router'
|
||||||
|
|
||||||
import TaskService from '../../../services/task'
|
import TaskService from '@/services/task'
|
||||||
import TaskModel from '../../../models/task'
|
import TaskModel from '@/models/task'
|
||||||
import TaskRelationService from '../../../services/taskRelation'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
import relationKinds from '../../../models/constants/relationKinds'
|
import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
|
||||||
import TaskRelationModel from '../../../models/taskRelation'
|
import {RELATION_KINDS, RELATION_KIND, type IRelationKind} from '@/types/IRelationKind'
|
||||||
|
|
||||||
|
import TaskRelationService from '@/services/taskRelation'
|
||||||
|
import TaskRelationModel from '@/models/taskRelation'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
|
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
name: 'relatedTasks',
|
|
||||||
data() {
|
import {error, success} from '@/message'
|
||||||
return {
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
relatedTasks: {},
|
|
||||||
taskService: new TaskService(),
|
const props = defineProps({
|
||||||
foundTasks: [],
|
|
||||||
relationKinds: relationKinds,
|
|
||||||
newTaskRelationTask: new TaskModel(),
|
|
||||||
newTaskRelationKind: 'related',
|
|
||||||
taskRelationService: new TaskRelationService(),
|
|
||||||
showDeleteModal: false,
|
|
||||||
relationToDelete: {},
|
|
||||||
saved: false,
|
|
||||||
showNewRelationForm: false,
|
|
||||||
query: '',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
BaseButton,
|
|
||||||
Multiselect,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
taskId: {
|
taskId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
initialRelatedTasks: {
|
initialRelatedTasks: {
|
||||||
type: Object,
|
type: Object as PropType<ITask['relatedTasks']>,
|
||||||
default: () => {
|
default: () => ({}),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
showNoRelationsNotice: {
|
showNoRelationsNotice: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -193,129 +192,177 @@ export default defineComponent({
|
||||||
editEnabled: {
|
editEnabled: {
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
initialRelatedTasks: {
|
|
||||||
handler(value) {
|
|
||||||
this.relatedTasks = value
|
|
||||||
},
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
showCreate() {
|
|
||||||
return Object.keys(this.relatedTasks).length === 0 || this.showNewRelationForm
|
|
||||||
},
|
|
||||||
namespace() {
|
|
||||||
return this.$store.getters['namespaces/getListAndNamespaceById'](this.listId, true)?.namespace
|
|
||||||
},
|
|
||||||
mappedRelatedTasks() {
|
|
||||||
return Object.entries(this.relatedTasks).map(([kind, tasks]) => ({
|
|
||||||
title: this.$tc(`task.relation.kinds.${kind}`, tasks.length),
|
|
||||||
tasks: this.mapRelatedTasks(tasks),
|
|
||||||
kind,
|
|
||||||
}))
|
|
||||||
},
|
|
||||||
mappedFoundTasks() {
|
|
||||||
return this.mapRelatedTasks(this.foundTasks.filter(t => t.id !== this.taskId))
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async findTasks(query) {
|
|
||||||
this.query = query
|
|
||||||
this.foundTasks = await this.taskService.getAll({}, {s: query})
|
|
||||||
},
|
|
||||||
|
|
||||||
async addTaskRelation() {
|
|
||||||
if (this.newTaskRelationTask.id === 0 && this.query !== '') {
|
|
||||||
return this.createAndRelateTask(this.query)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.newTaskRelationTask.id === 0) {
|
|
||||||
this.$message.error({message: this.$t('task.relation.taskRequired')})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const rel = new TaskRelationModel({
|
|
||||||
taskId: this.taskId,
|
|
||||||
otherTaskId: this.newTaskRelationTask.id,
|
|
||||||
relationKind: this.newTaskRelationKind,
|
|
||||||
})
|
})
|
||||||
await this.taskRelationService.create(rel)
|
|
||||||
if (!this.relatedTasks[this.newTaskRelationKind]) {
|
|
||||||
this.relatedTasks[this.newTaskRelationKind] = []
|
|
||||||
}
|
|
||||||
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
|
|
||||||
this.newTaskRelationTask = null
|
|
||||||
this.saved = true
|
|
||||||
this.showNewRelationForm = false
|
|
||||||
setTimeout(() => {
|
|
||||||
this.saved = false
|
|
||||||
}, 2000)
|
|
||||||
},
|
|
||||||
|
|
||||||
async removeTaskRelation() {
|
const taskStore = useTaskStore()
|
||||||
const rel = new TaskRelationModel({
|
const namespaceStore = useNamespaceStore()
|
||||||
relationKind: this.relationToDelete.relationKind,
|
const route = useRoute()
|
||||||
taskId: this.taskId,
|
const {t} = useI18n({useScope: 'global'})
|
||||||
otherTaskId: this.relationToDelete.otherTaskId,
|
|
||||||
|
type TaskRelation = {kind: IRelationKind, task: ITask}
|
||||||
|
|
||||||
|
const taskService = shallowReactive(new TaskService())
|
||||||
|
|
||||||
|
const relatedTasks = ref<ITask['relatedTasks']>({})
|
||||||
|
|
||||||
|
const newTaskRelation: TaskRelation = reactive({
|
||||||
|
kind: RELATION_KIND.RELATED,
|
||||||
|
task: new TaskModel(),
|
||||||
})
|
})
|
||||||
try {
|
|
||||||
await this.taskRelationService.delete(rel)
|
|
||||||
|
|
||||||
const kind = this.relationToDelete.relationKind
|
watch(
|
||||||
for (const t in this.relatedTasks[kind]) {
|
() => props.initialRelatedTasks,
|
||||||
if (this.relatedTasks[kind][t].id === this.relationToDelete.otherTaskId) {
|
(value) => {
|
||||||
this.relatedTasks[kind].splice(t, 1)
|
relatedTasks.value = value
|
||||||
|
},
|
||||||
|
{immediate: true},
|
||||||
|
)
|
||||||
|
|
||||||
break
|
const showNewRelationForm = ref(false)
|
||||||
}
|
const showCreate = computed(() => Object.keys(relatedTasks.value).length === 0 || showNewRelationForm.value)
|
||||||
|
|
||||||
|
const query = ref('')
|
||||||
|
const foundTasks = ref<ITask[]>([])
|
||||||
|
|
||||||
|
async function findTasks(newQuery: string) {
|
||||||
|
query.value = newQuery
|
||||||
|
foundTasks.value = await taskService.getAll({}, {s: newQuery})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saved = true
|
const getListAndNamespaceById = (listId: number) => namespaceStore.getListAndNamespaceById(listId, true)
|
||||||
setTimeout(() => {
|
|
||||||
this.saved = false
|
|
||||||
}, 2000)
|
|
||||||
} finally {
|
|
||||||
this.showDeleteModal = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async createAndRelateTask(title) {
|
const namespace = computed(() => getListAndNamespaceById(props.listId)?.namespace)
|
||||||
const newTask = new TaskModel({title: title, listId: this.listId})
|
|
||||||
this.newTaskRelationTask = await this.taskService.create(newTask)
|
|
||||||
await this.addTaskRelation()
|
|
||||||
},
|
|
||||||
|
|
||||||
relationKindTitle(kind, length) {
|
function mapRelatedTasks(tasks: ITask[]) {
|
||||||
return this.$tc(`task.relation.kinds.${kind}`, length)
|
return tasks.map(task => {
|
||||||
},
|
|
||||||
|
|
||||||
mapRelatedTasks(tasks) {
|
|
||||||
return tasks
|
|
||||||
.map(task => {
|
|
||||||
// by doing this here once we can save a lot of duplicate calls in the template
|
// by doing this here once we can save a lot of duplicate calls in the template
|
||||||
const listAndNamespace = this.$store.getters['namespaces/getListAndNamespaceById'](task.listId, true)
|
|
||||||
const {
|
const {
|
||||||
list,
|
list,
|
||||||
namespace,
|
namespace: taskNamespace,
|
||||||
} = listAndNamespace === null ? {list: null, namespace: null} : listAndNamespace
|
} = getListAndNamespaceById(task.listId) || {list: null, namespace: null}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
differentNamespace:
|
differentNamespace:
|
||||||
(namespace !== null &&
|
(taskNamespace !== null &&
|
||||||
namespace.id !== this.namespace.id &&
|
taskNamespace.id !== namespace.value.id &&
|
||||||
namespace?.title) || null,
|
taskNamespace?.title) || null,
|
||||||
differentList:
|
differentList:
|
||||||
(list !== null &&
|
(list !== null &&
|
||||||
task.listId !== this.listId &&
|
task.listId !== props.listId &&
|
||||||
list?.title) || null,
|
list?.title) || null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
},
|
|
||||||
|
const mapRelationKindsTitleGetter = computed(() => ({
|
||||||
|
'subtask': (count: number) => t('task.relation.kinds.subtask', count),
|
||||||
|
'parenttask': (count: number) => t('task.relation.kinds.parenttask', count),
|
||||||
|
'related': (count: number) => t('task.relation.kinds.related', count),
|
||||||
|
'duplicateof': (count: number) => t('task.relation.kinds.duplicateof', count),
|
||||||
|
'duplicates': (count: number) => t('task.relation.kinds.duplicates', count),
|
||||||
|
'blocking': (count: number) => t('task.relation.kinds.blocking', count),
|
||||||
|
'blocked': (count: number) => t('task.relation.kinds.blocked', count),
|
||||||
|
'precedes': (count: number) => t('task.relation.kinds.precedes', count),
|
||||||
|
'follows': (count: number) => t('task.relation.kinds.follows', count),
|
||||||
|
'copiedfrom': (count: number) => t('task.relation.kinds.copiedfrom', count),
|
||||||
|
'copiedto': (count: number) => t('task.relation.kinds.copiedto', count),
|
||||||
|
}))
|
||||||
|
|
||||||
|
const mappedRelatedTasks = computed(() => Object.entries(relatedTasks.value).map(
|
||||||
|
([kind, tasks]) => ({
|
||||||
|
title: mapRelationKindsTitleGetter.value[kind as IRelationKind](tasks.length),
|
||||||
|
tasks: mapRelatedTasks(tasks),
|
||||||
|
kind: kind as IRelationKind,
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
const mappedFoundTasks = computed(() => mapRelatedTasks(foundTasks.value.filter(t => t.id !== props.taskId)))
|
||||||
|
|
||||||
|
const taskRelationService = shallowReactive(new TaskRelationService())
|
||||||
|
const saved = ref(false)
|
||||||
|
|
||||||
|
async function addTaskRelation() {
|
||||||
|
if (newTaskRelation.task.id === 0 && query.value !== '') {
|
||||||
|
return createAndRelateTask(query.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newTaskRelation.task.id === 0) {
|
||||||
|
error({message: t('task.relation.taskRequired')})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await taskRelationService.create(new TaskRelationModel({
|
||||||
|
taskId: props.taskId,
|
||||||
|
otherTaskId: newTaskRelation.task.id,
|
||||||
|
relationKind: newTaskRelation.kind,
|
||||||
|
}))
|
||||||
|
relatedTasks.value[newTaskRelation.kind] = [
|
||||||
|
...(relatedTasks.value[newTaskRelation.kind] || []),
|
||||||
|
newTaskRelation.task,
|
||||||
|
]
|
||||||
|
newTaskRelation.task = new TaskModel()
|
||||||
|
saved.value = true
|
||||||
|
showNewRelationForm.value = false
|
||||||
|
setTimeout(() => {
|
||||||
|
saved.value = false
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
|
||||||
|
const relationToDelete = ref<Partial<ITaskRelation>>()
|
||||||
|
|
||||||
|
function setRelationToDelete(relation: Partial<ITaskRelation>) {
|
||||||
|
relationToDelete.value = relation
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeTaskRelation() {
|
||||||
|
const relation = relationToDelete.value
|
||||||
|
if (!relation || !relation.relationKind || !relation.otherTaskId) {
|
||||||
|
relationToDelete.value = undefined
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const relationKind = relation.relationKind
|
||||||
|
await taskRelationService.delete(new TaskRelationModel({
|
||||||
|
relationKind,
|
||||||
|
taskId: props.taskId,
|
||||||
|
otherTaskId: relation.otherTaskId,
|
||||||
|
}))
|
||||||
|
|
||||||
|
relatedTasks.value[relationKind] = relatedTasks.value[relationKind]?.filter(
|
||||||
|
({id}) => id !== relation.otherTaskId,
|
||||||
|
)
|
||||||
|
|
||||||
|
saved.value = true
|
||||||
|
setTimeout(() => {
|
||||||
|
saved.value = false
|
||||||
|
}, 2000)
|
||||||
|
} finally {
|
||||||
|
relationToDelete.value = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createAndRelateTask(title: string) {
|
||||||
|
const newTask = await taskService.create(new TaskModel({title, listId: props.listId}))
|
||||||
|
newTaskRelation.task = newTask
|
||||||
|
await addTaskRelation()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleTaskDone(task: ITask) {
|
||||||
|
await taskStore.update(task)
|
||||||
|
|
||||||
|
// Find the task in the list and update it so that it is correctly strike through
|
||||||
|
Object.entries(relatedTasks.value).some(([kind, tasks]) => {
|
||||||
|
return (tasks as ITask[]).some((t, key) => {
|
||||||
|
const found = t.id === task.id
|
||||||
|
if (found) {
|
||||||
|
relatedTasks.value[kind as IRelationKind]![key] = task
|
||||||
|
}
|
||||||
|
return found
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
success({message: t('task.detail.updateSuccess')})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -366,15 +413,16 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.remove {
|
.remove {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity $transition;
|
transition: opacity $transition;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.related-tasks:hover .tasks .task .remove {
|
.task:hover .remove {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,5 +435,13 @@ export default defineComponent({
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: The height of the actual checkbox in the <Fancycheckbox/> component is too much resulting in a
|
||||||
|
// weired positioning of the checkbox. Setting the height here is a workaround until we fix the styling
|
||||||
|
// of the component.
|
||||||
|
.task-done-checkbox {
|
||||||
|
padding: 0;
|
||||||
|
height: 18px; // The exact height of the checkbox in the container
|
||||||
|
}
|
||||||
|
|
||||||
@include modal-transition();
|
@include modal-transition();
|
||||||
</style>
|
</style>
|
|
@ -26,7 +26,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {PropType, ref, onMounted, watch} from 'vue'
|
import {type PropType, ref, onMounted, watch} from 'vue'
|
||||||
|
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import Datepicker from '@/components/input/datepicker.vue'
|
import Datepicker from '@/components/input/datepicker.vue'
|
||||||
|
@ -45,8 +45,8 @@ const props = defineProps({
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDate = (e: any) => e instanceof Date
|
const isDate = (e: unknown) => e instanceof Date
|
||||||
const isString = (e: any) => typeof e === 'string'
|
const isString = (e: unknown) => typeof e === 'string'
|
||||||
|
|
||||||
for (const e of prop) {
|
for (const e of prop) {
|
||||||
if (!isDate(e) && !isString(e)) {
|
if (!isDate(e) && !isString(e)) {
|
||||||
|
@ -63,7 +63,7 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const reminders = ref<Reminder[]>([])
|
const reminders = ref<Reminder[]>([])
|
||||||
|
|
||||||
|
@ -86,7 +86,6 @@ watch(
|
||||||
|
|
||||||
function updateData() {
|
function updateData() {
|
||||||
emit('update:modelValue', reminders.value)
|
emit('update:modelValue', reminders.value)
|
||||||
emit('change')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newReminder = ref(null)
|
const newReminder = ref(null)
|
||||||
|
|
|
@ -18,17 +18,14 @@
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select @change="updateData" v-model="task.repeatMode" id="repeatMode">
|
<select @change="updateData" v-model="task.repeatMode" id="repeatMode">
|
||||||
<option :value="repeatModes.REPEAT_MODE_DEFAULT">{{ $t('misc.default') }}</option>
|
<option :value="TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT">{{ $t('misc.default') }}</option>
|
||||||
<option :value="repeatModes.REPEAT_MODE_MONTH">{{ $t('task.repeat.monthly') }}</option>
|
<option :value="TASK_REPEAT_MODES.REPEAT_MODE_MONTH">{{ $t('task.repeat.monthly') }}</option>
|
||||||
<option :value="repeatModes.REPEAT_MODE_FROM_CURRENT_DATE">{{
|
<option :value="TASK_REPEAT_MODES.REPEAT_MODE_FROM_CURRENT_DATE">{{ $t('task.repeat.fromCurrentDate') }}</option>
|
||||||
$t('task.repeat.fromCurrentDate')
|
|
||||||
}}
|
|
||||||
</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-flex" v-if="task.repeatMode !== repeatModes.REPEAT_MODE_MONTH">
|
<div class="is-flex" v-if="task.repeatMode !== TASK_REPEAT_MODES.REPEAT_MODE_MONTH">
|
||||||
<p class="pr-4">
|
<p class="pr-4">
|
||||||
{{ $t('task.repeat.each') }}
|
{{ $t('task.repeat.each') }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -65,14 +62,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, reactive, watch} from 'vue'
|
import {ref, reactive, watch, type PropType} from 'vue'
|
||||||
import repeatModes from '@/models/constants/taskRepeatModes.json'
|
|
||||||
import TaskModel from '@/models/task'
|
|
||||||
import {error} from '@/message'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
|
import {error} from '@/message'
|
||||||
|
|
||||||
|
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
|
||||||
|
import type {IRepeatAfter} from '@/types/IRepeatAfter'
|
||||||
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
type: Object as PropType<ITask>,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
@ -82,11 +83,11 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const {t} = useI18n()
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const task = ref<TaskModel>()
|
const task = ref<ITask>()
|
||||||
const repeatAfter = reactive({
|
const repeatAfter = reactive({
|
||||||
amount: 0,
|
amount: 0,
|
||||||
type: '',
|
type: '',
|
||||||
|
@ -104,7 +105,7 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
function updateData() {
|
function updateData() {
|
||||||
if (task.value.repeatMode !== repeatModes.REPEAT_MODE_DEFAULT && repeatAfter.amount === 0) {
|
if (!task.value || task.value.repeatMode !== TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT && repeatAfter.amount === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,10 +116,9 @@ function updateData() {
|
||||||
|
|
||||||
Object.assign(task.value.repeatAfter, repeatAfter)
|
Object.assign(task.value.repeatAfter, repeatAfter)
|
||||||
emit('update:modelValue', task.value)
|
emit('update:modelValue', task.value)
|
||||||
emit('change')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRepeatAfter(amount: number, type) {
|
function setRepeatAfter(amount: number, type: IRepeatAfter['type']) {
|
||||||
Object.assign(repeatAfter, { amount, type})
|
Object.assign(repeatAfter, { amount, type})
|
||||||
updateData()
|
updateData()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="{'is-loading': taskService.loading}" class="task loader-container">
|
<div :class="{'is-loading': taskService.loading}" class="task loader-container">
|
||||||
<fancycheckbox :disabled="(isArchived || disabled) && !canMarkAsDone" @change="markAsDone" v-model="task.done"/>
|
<fancycheckbox :disabled="(isArchived || disabled) && !canMarkAsDone" @change="markAsDone" v-model="task.done"/>
|
||||||
<span
|
<ColorBubble
|
||||||
v-if="showListColor && listColor !== ''"
|
v-if="showListColor && listColor !== ''"
|
||||||
:style="{backgroundColor: listColor }"
|
:color="listColor"
|
||||||
class="color-bubble"
|
class="mr-1"
|
||||||
>
|
/>
|
||||||
</span>
|
|
||||||
<router-link
|
<router-link
|
||||||
:to="taskDetailRoute"
|
:to="taskDetailRoute"
|
||||||
:class="{ 'done': task.done}"
|
:class="{ 'done': task.done}"
|
||||||
|
@ -15,11 +14,17 @@
|
||||||
<router-link
|
<router-link
|
||||||
:to="{ name: 'list.list', params: { listId: task.listId } }"
|
:to="{ name: 'list.list', params: { listId: task.listId } }"
|
||||||
class="task-list"
|
class="task-list"
|
||||||
v-if="showList && $store.getters['lists/getListById'](task.listId) !== null"
|
:class="{'mr-2': task.hexColor !== ''}"
|
||||||
v-tooltip="$t('task.detail.belongsToList', {list: $store.getters['lists/getListById'](task.listId).title})">
|
v-if="showList && getListById(task.listId) !== null"
|
||||||
{{ $store.getters['lists/getListById'](task.listId).title }}
|
v-tooltip="$t('task.detail.belongsToList', {list: getListById(task.listId).title})">
|
||||||
|
{{ getListById(task.listId).title }}
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
|
<ColorBubble
|
||||||
|
v-if="task.hexColor !== ''"
|
||||||
|
:color="task.getHexColor()"
|
||||||
|
class="mr-1"
|
||||||
|
/>
|
||||||
<!-- Show any parent tasks to make it clear this task is a sub task of something -->
|
<!-- Show any parent tasks to make it clear this task is a sub task of something -->
|
||||||
<span class="parent-tasks" v-if="typeof task.relatedTasks.parenttask !== 'undefined'">
|
<span class="parent-tasks" v-if="typeof task.relatedTasks.parenttask !== 'undefined'">
|
||||||
<template v-for="(pt, i) in task.relatedTasks.parenttask">
|
<template v-for="(pt, i) in task.relatedTasks.parenttask">
|
||||||
|
@ -43,7 +48,7 @@
|
||||||
v-if="+new Date(task.dueDate) > 0"
|
v-if="+new Date(task.dueDate) > 0"
|
||||||
class="dueDate"
|
class="dueDate"
|
||||||
@click.prevent.stop="showDefer = !showDefer"
|
@click.prevent.stop="showDefer = !showDefer"
|
||||||
v-tooltip="formatDate(task.dueDate)"
|
v-tooltip="formatDateLong(task.dueDate)"
|
||||||
>
|
>
|
||||||
<time
|
<time
|
||||||
:datetime="formatISO(task.dueDate)"
|
:datetime="formatISO(task.dueDate)"
|
||||||
|
@ -80,9 +85,9 @@
|
||||||
<router-link
|
<router-link
|
||||||
:to="{ name: 'list.list', params: { listId: task.listId } }"
|
:to="{ name: 'list.list', params: { listId: task.listId } }"
|
||||||
class="task-list"
|
class="task-list"
|
||||||
v-if="!showList && currentList.id !== task.listId && $store.getters['lists/getListById'](task.listId) !== null"
|
v-if="!showList && currentList.id !== task.listId && getListById(task.listId) !== null"
|
||||||
v-tooltip="$t('task.detail.belongsToList', {list: $store.getters['lists/getListById'](task.listId).title})">
|
v-tooltip="$t('task.detail.belongsToList', {list: getListById(task.listId).title})">
|
||||||
{{ $store.getters['lists/getListById'](task.listId).title }}
|
{{ getListById(task.listId).title }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
:class="{'is-favorite': task.isFavorite}"
|
:class="{'is-favorite': task.isFavorite}"
|
||||||
|
@ -96,19 +101,26 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {defineComponent, type PropType} from 'vue'
|
||||||
|
import {mapState} from 'pinia'
|
||||||
|
|
||||||
import TaskModel from '../../../models/task'
|
import TaskModel from '@/models/task'
|
||||||
import PriorityLabel from './priorityLabel'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
import PriorityLabel from './priorityLabel.vue'
|
||||||
import TaskService from '../../../services/task'
|
import TaskService from '../../../services/task'
|
||||||
import Labels from './labels'
|
import Labels from '@/components/tasks/partials/labels.vue'
|
||||||
import User from '../../misc/user'
|
import User from '@/components/misc/user.vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import Fancycheckbox from '../../input/fancycheckbox'
|
import Fancycheckbox from '../../input/fancycheckbox.vue'
|
||||||
import DeferTask from './defer-task'
|
import DeferTask from './defer-task.vue'
|
||||||
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
|
||||||
import {playPop} from '@/helpers/playPop'
|
import ChecklistSummary from './checklist-summary.vue'
|
||||||
import ChecklistSummary from './checklist-summary'
|
import {formatDateSince, formatISO, formatDateLong} from '@/helpers/time/formatDate'
|
||||||
|
import ColorBubble from '@/components/misc/colorBubble.vue'
|
||||||
|
import {useListStore} from '@/stores/lists'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'singleTaskInList',
|
name: 'singleTaskInList',
|
||||||
|
@ -120,6 +132,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
ColorBubble,
|
||||||
BaseButton,
|
BaseButton,
|
||||||
ChecklistSummary,
|
ChecklistSummary,
|
||||||
DeferTask,
|
DeferTask,
|
||||||
|
@ -130,7 +143,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
theTask: {
|
theTask: {
|
||||||
type: TaskModel,
|
type: Object as PropType<ITask>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
isArchived: {
|
isArchived: {
|
||||||
|
@ -168,15 +181,19 @@ export default defineComponent({
|
||||||
document.removeEventListener('click', this.hideDeferDueDatePopup)
|
document.removeEventListener('click', this.hideDeferDueDatePopup)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState(useListStore, {
|
||||||
|
getListById: 'getListById',
|
||||||
|
}),
|
||||||
listColor() {
|
listColor() {
|
||||||
const list = this.$store.getters['lists/getListById'](this.task.listId)
|
const list = this.getListById(this.task.listId)
|
||||||
return list !== null ? list.hexColor : ''
|
return list !== null ? list.hexColor : ''
|
||||||
},
|
},
|
||||||
currentList() {
|
currentList() {
|
||||||
return typeof this.$store.state.currentList === 'undefined' ? {
|
const baseStore = useBaseStore()
|
||||||
|
return typeof baseStore.currentList === 'undefined' ? {
|
||||||
id: 0,
|
id: 0,
|
||||||
title: '',
|
title: '',
|
||||||
} : this.$store.state.currentList
|
} : baseStore.currentList
|
||||||
},
|
},
|
||||||
taskDetailRoute() {
|
taskDetailRoute() {
|
||||||
return {
|
return {
|
||||||
|
@ -188,12 +205,13 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async markAsDone(checked) {
|
formatDateSince,
|
||||||
|
formatISO,
|
||||||
|
formatDateLong,
|
||||||
|
|
||||||
|
async markAsDone(checked: boolean) {
|
||||||
const updateFunc = async () => {
|
const updateFunc = async () => {
|
||||||
const task = await this.taskService.update(this.task)
|
const task = await useTaskStore().update(this.task)
|
||||||
if (this.task.done) {
|
|
||||||
playPop()
|
|
||||||
}
|
|
||||||
this.task = task
|
this.task = task
|
||||||
this.$emit('task-updated', task)
|
this.$emit('task-updated', task)
|
||||||
this.$message.success({
|
this.$message.success({
|
||||||
|
@ -213,7 +231,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
undoDone(checked) {
|
undoDone(checked: boolean) {
|
||||||
this.task.done = !this.task.done
|
this.task.done = !this.task.done
|
||||||
this.markAsDone(!checked)
|
this.markAsDone(!checked)
|
||||||
},
|
},
|
||||||
|
@ -222,7 +240,7 @@ export default defineComponent({
|
||||||
this.task.isFavorite = !this.task.isFavorite
|
this.task.isFavorite = !this.task.isFavorite
|
||||||
this.task = await this.taskService.update(this.task)
|
this.task = await this.taskService.update(this.task)
|
||||||
this.$emit('task-updated', this.task)
|
this.$emit('task-updated', this.task)
|
||||||
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
|
useNamespaceStore().loadNamespacesIfFavoritesDontExist()
|
||||||
},
|
},
|
||||||
hideDeferDueDatePopup(e) {
|
hideDeferDueDatePopup(e) {
|
||||||
if (!this.showDefer) {
|
if (!this.showDefer) {
|
||||||
|
@ -276,11 +294,6 @@ export default defineComponent({
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-bubble {
|
|
||||||
height: 10px;
|
|
||||||
flex: 0 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {PropType} from 'vue'
|
import type {PropType} from 'vue'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
|
|
||||||
type Order = 'asc' | 'desc' | 'none'
|
type Order = 'asc' | 'desc' | 'none'
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {ref, shallowReactive, watch, computed} from 'vue'
|
||||||
import {useRoute} from 'vue-router'
|
import {useRoute} from 'vue-router'
|
||||||
|
|
||||||
import TaskCollectionService from '@/services/taskCollection'
|
import TaskCollectionService from '@/services/taskCollection'
|
||||||
|
import type { ITask } from '@/modelTypes/ITask'
|
||||||
|
|
||||||
// FIXME: merge with DEFAULT_PARAMS in filters.vue
|
// FIXME: merge with DEFAULT_PARAMS in filters.vue
|
||||||
export const getDefaultParams = () => ({
|
export const getDefaultParams = () => ({
|
||||||
|
@ -70,7 +71,7 @@ export function useTaskList(listId, sortByDefault = SORT_BY_DEFAULT) {
|
||||||
const loading = computed(() => taskCollectionService.loading)
|
const loading = computed(() => taskCollectionService.loading)
|
||||||
const totalPages = computed(() => taskCollectionService.totalPages)
|
const totalPages = computed(() => taskCollectionService.totalPages)
|
||||||
|
|
||||||
const tasks = ref([])
|
const tasks = ref<ITask[]>([])
|
||||||
async function loadTasks() {
|
async function loadTasks() {
|
||||||
tasks.value = []
|
tasks.value = []
|
||||||
tasks.value = await taskCollectionService.getAll(...getAllTasksParams.value)
|
tasks.value = await taskCollectionService.getAll(...getAllTasksParams.value)
|
||||||
|
@ -81,10 +82,10 @@ export function useTaskList(listId, sortByDefault = SORT_BY_DEFAULT) {
|
||||||
watch(() => route.query, (query) => {
|
watch(() => route.query, (query) => {
|
||||||
const { page: pageQueryValue, search: searchQuery } = query
|
const { page: pageQueryValue, search: searchQuery } = query
|
||||||
if (searchQuery !== undefined) {
|
if (searchQuery !== undefined) {
|
||||||
search.value = searchQuery
|
search.value = searchQuery as string
|
||||||
}
|
}
|
||||||
if (pageQueryValue !== undefined) {
|
if (pageQueryValue !== undefined) {
|
||||||
page.value = parseInt(pageQueryValue)
|
page.value = Number(pageQueryValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
|
@ -4,10 +4,41 @@ import {useI18n} from 'vue-i18n'
|
||||||
export function useCopyToClipboard() {
|
export function useCopyToClipboard() {
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
|
function fallbackCopyTextToClipboard(text: string) {
|
||||||
|
const textArea = document.createElement('textarea')
|
||||||
|
textArea.value = text
|
||||||
|
|
||||||
|
// Avoid scrolling to bottom
|
||||||
|
textArea.style.top = '0'
|
||||||
|
textArea.style.left = '0'
|
||||||
|
textArea.style.position = 'fixed'
|
||||||
|
|
||||||
|
document.body.appendChild(textArea)
|
||||||
|
textArea.focus()
|
||||||
|
textArea.select()
|
||||||
|
|
||||||
|
try {
|
||||||
|
// NOTE: the execCommand is deprecated but as of 2022_09
|
||||||
|
// widely supported and works without https
|
||||||
|
const successful = document.execCommand('copy')
|
||||||
|
if (!successful) {
|
||||||
|
throw new Error()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
error(t('misc.copyError'))
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.removeChild(textArea)
|
||||||
|
}
|
||||||
|
|
||||||
return async (text: string) => {
|
return async (text: string) => {
|
||||||
|
if (!navigator.clipboard) {
|
||||||
|
fallbackCopyTextToClipboard(text)
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text)
|
await navigator.clipboard.writeText(text)
|
||||||
} catch {
|
} catch(e) {
|
||||||
error(t('misc.copyError'))
|
error(t('misc.copyError'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {ref, computed} from 'vue'
|
import {ref, computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
export function useNameSpaceSearch() {
|
export function useNamespaceSearch() {
|
||||||
const query = ref('')
|
const query = ref('')
|
||||||
|
|
||||||
const store = useStore()
|
const namespaceStore = useNamespaceStore()
|
||||||
const namespaces = computed(() => store.getters['namespaces/searchNamespace'](query.value))
|
const namespaces = computed(() => namespaceStore.searchNamespace(query.value))
|
||||||
|
|
||||||
function findNamespaces(newQuery: string) {
|
function findNamespaces(newQuery: string) {
|
||||||
query.value = newQuery
|
query.value = newQuery
|
||||||
|
|
40
src/composables/useRenewTokenOnFocus.ts
Normal file
40
src/composables/useRenewTokenOnFocus.ts
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import {computed} from 'vue'
|
||||||
|
import {useRouter} from 'vue-router'
|
||||||
|
import {useEventListener} from '@vueuse/core'
|
||||||
|
|
||||||
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
|
||||||
|
export function useRenewTokenOnFocus() {
|
||||||
|
const router = useRouter()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
|
const userInfo = computed(() => authStore.info)
|
||||||
|
const authenticated = computed(() => authStore.authenticated)
|
||||||
|
|
||||||
|
// Try renewing the token every time vikunja is loaded initially
|
||||||
|
// (When opening the browser the focus event is not fired)
|
||||||
|
authStore.renewToken()
|
||||||
|
|
||||||
|
// Check if the token is still valid if the window gets focus again to maybe renew it
|
||||||
|
useEventListener('focus', () => {
|
||||||
|
if (!authenticated.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const expiresIn = (userInfo.value !== null ? userInfo.value.exp : 0) - +new Date() / 1000
|
||||||
|
|
||||||
|
// If the token expiry is negative, it is already expired and we have no choice but to redirect
|
||||||
|
// the user to the login page
|
||||||
|
if (expiresIn < 0) {
|
||||||
|
authStore.checkAuth()
|
||||||
|
router.push({name: 'user.login'})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the token is valid for less than 60 hours and renew if thats the case
|
||||||
|
if (expiresIn < 60 * 3600) {
|
||||||
|
authStore.renewToken()
|
||||||
|
console.debug('renewed token')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
54
src/composables/useRouteWithModal.ts
Normal file
54
src/composables/useRouteWithModal.ts
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import { computed, shallowRef, watchEffect, h, type VNode } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
export function useRouteWithModal() {
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
const backdropView = computed(() => route.fullPath && window.history.state.backdropView)
|
||||||
|
|
||||||
|
const routeWithModal = computed(() => {
|
||||||
|
return backdropView.value
|
||||||
|
? router.resolve(backdropView.value)
|
||||||
|
: route
|
||||||
|
})
|
||||||
|
|
||||||
|
const currentModal = shallowRef<VNode>()
|
||||||
|
watchEffect(() => {
|
||||||
|
if (!backdropView.value) {
|
||||||
|
currentModal.value = undefined
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// logic from vue-router
|
||||||
|
// https://github.com/vuejs/vue-router-next/blob/798cab0d1e21f9b4d45a2bd12b840d2c7415f38a/src/RouterView.ts#L125
|
||||||
|
const routePropsOption = route.matched[0]?.props.default
|
||||||
|
const routeProps = routePropsOption
|
||||||
|
? routePropsOption === true
|
||||||
|
? route.params
|
||||||
|
: typeof routePropsOption === 'function'
|
||||||
|
? routePropsOption(route)
|
||||||
|
: routePropsOption
|
||||||
|
: null
|
||||||
|
|
||||||
|
const component = route.matched[0]?.components?.default
|
||||||
|
|
||||||
|
if (!component) {
|
||||||
|
currentModal.value = undefined
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentModal.value = h(component, routeProps)
|
||||||
|
})
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
const historyState = computed(() => route.fullPath && window.history.state)
|
||||||
|
|
||||||
|
if (historyState.value) {
|
||||||
|
router.back()
|
||||||
|
} else {
|
||||||
|
const backdropRoute = historyState.value?.backdropView && router.resolve(historyState.value.backdropView)
|
||||||
|
router.push(backdropRoute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {routeWithModal, currentModal, closeModal}
|
||||||
|
}
|
|
@ -1,12 +1,21 @@
|
||||||
import { computed, watchEffect } from 'vue'
|
import { computed } from 'vue'
|
||||||
import type { ComputedGetter } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
import { setTitle } from '@/helpers/setTitle'
|
import {useTitle as useTitleVueUse, resolveRef} from '@vueuse/core'
|
||||||
|
|
||||||
export function useTitle(titleGetter: ComputedGetter<string>) {
|
type UseTitleParameters = Parameters<typeof useTitleVueUse>
|
||||||
const titleRef = computed(titleGetter)
|
|
||||||
|
|
||||||
watchEffect(() => setTitle(titleRef.value))
|
export function useTitle(...args: UseTitleParameters) {
|
||||||
|
|
||||||
return titleRef
|
const [newTitle, ...restArgs] = args
|
||||||
|
|
||||||
|
const pageTitle = resolveRef(newTitle) as Ref<string>
|
||||||
|
|
||||||
|
const completeTitle = computed(() =>
|
||||||
|
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
|
||||||
|
? 'Vikunja'
|
||||||
|
: `${pageTitle.value} | Vikunja`,
|
||||||
|
)
|
||||||
|
|
||||||
|
return useTitleVueUse(completeTitle, ...restArgs)
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue