From 3c7f8d7aa2a46a523ea66b43b8422694dd31e9c1 Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 28 Jul 2021 19:56:29 +0000 Subject: [PATCH] Reorder tasks, lists and kanban buckets (#620) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/620 Co-authored-by: konrad Co-committed-by: konrad --- cypress/integration/list/list.spec.js | 35 +- cypress/support/index.js | 1 + package.json | 4 +- src/App.vue | 20 +- src/components/home/navigation.vue | 109 ++- src/components/tasks/add-task.vue | 8 +- src/components/tasks/mixins/createTask.js | 17 +- src/components/tasks/mixins/taskList.js | 24 +- src/components/tasks/partials/kanban-card.vue | 111 +++ src/helpers/applyDrag.js | 18 - src/helpers/calculateItemPosition.ts | 19 + src/helpers/calculateTaskPosition.test.ts | 18 + src/main.ts | 2 + src/models/task.js | 3 + src/store/modules/kanban.js | 4 +- src/styles/components/kanban.scss | 480 ++++++------ src/styles/components/tasks.scss | 542 ++++++------- src/styles/theme/navigation.scss | 729 +++++++++--------- src/styles/theme/theme.scss | 4 + src/views/list/views/Kanban.vue | 515 +++++-------- src/views/list/views/List.vue | 89 ++- src/views/namespaces/ListNamespaces.vue | 4 + yarn.lock | 34 +- 23 files changed, 1524 insertions(+), 1266 deletions(-) create mode 100644 src/components/tasks/partials/kanban-card.vue delete mode 100644 src/helpers/applyDrag.js create mode 100644 src/helpers/calculateItemPosition.ts create mode 100644 src/helpers/calculateTaskPosition.test.ts diff --git a/cypress/integration/list/list.spec.js b/cypress/integration/list/list.spec.js index a79236d1..107b5528 100644 --- a/cypress/integration/list/list.spec.js +++ b/cypress/integration/list/list.spec.js @@ -436,26 +436,23 @@ describe('Lists', () => { .should('exist') }) + it('Can drag tasks around', () => { + const tasks = TaskFactory.create(2, { + list_id: 1, + bucket_id: 1, + }) + cy.visit('/lists/1/kanban') - // The following test does not work. It seems like vue-smooth-dnd does not use either mousemove or dragstart - // (not sure why this actually works at all?) and as I'm planning to swap that out for vuedraggable/sortable.js - // anyway, I figured it wouldn't be worth the hassle right now. - -// it('Can drag tasks around', () => { -// const tasks = TaskFactory.create(2, { -// list_id: 1, -// bucket_id: 1, -// }) -// cy.visit('/lists/1/kanban') -// -// cy.get('.kanban .bucket .tasks .task') -// .contains(tasks[0].title) -// .first() -// .drag('.kanban .bucket:nth-child(2) .tasks .smooth-dnd-container.vertical') -// .trigger('mousedown', {which: 1}) -// .trigger('mousemove', {clientX: 500, clientY: 0}) -// .trigger('mouseup', {force: true}) -// }) + cy.get('.kanban .bucket .tasks .task') + .contains(tasks[0].title) + .first() + .drag('.kanban .bucket:nth-child(2) .tasks .dropper div') + + cy.get('.kanban .bucket:nth-child(2) .tasks') + .should('contain', tasks[0].title) + cy.get('.kanban .bucket:nth-child(1) .tasks') + .should('not.contain', tasks[0].title) + }) it('Should navigate to the task when the task card is clicked', () => { const tasks = TaskFactory.create(5, { diff --git a/cypress/support/index.js b/cypress/support/index.js index 74c1400d..22ec961f 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -1,3 +1,4 @@ import './commands' import 'cypress-file-upload' +import '@4tw/cypress-drag-drop' diff --git a/package.json b/package.json index a1a7ba0a..25c6d6bf 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "date-fns": "2.23.0", "dompurify": "2.3.0", "highlight.js": "11.1.0", + "is-touch-device": "^1.0.1", "lodash": "4.17.21", "marked": "2.1.3", "register-service-worker": "1.7.2", @@ -32,11 +33,12 @@ "vue-easymde": "1.4.0", "vue-i18n": "8.25.0", "vue-shortkey": "3.1.7", - "vue-smooth-dnd": "0.8.1", + "vuedraggable": "^2.24.3", "vuex": "3.6.2", "workbox-precaching": "6.1.5" }, "devDependencies": { + "@4tw/cypress-drag-drop": "^1.8.0", "@fortawesome/fontawesome-svg-core": "1.2.35", "@fortawesome/free-regular-svg-icons": "5.15.3", "@fortawesome/free-solid-svg-icons": "5.15.3", diff --git a/src/App.vue b/src/App.vue index 9dae1e76..4525a079 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@