aboutsummaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorAnbraten <anton@ju60.de>2021-12-08 07:57:18 +0100
committerGitHub <noreply@github.com>2021-12-08 14:57:18 +0800
commit0ff18a808c7c14d42ea2325b5d9623f7a30d9107 (patch)
tree6271529776d63a8c741bc3159cd5cfacd5539be1 /web_src
parent4cbe792562e69e76df07cfa4aa9c0c254b2dec7c (diff)
downloadgitea-0ff18a808c7c14d42ea2325b5d9623f7a30d9107.tar.gz
gitea-0ff18a808c7c14d42ea2325b5d9623f7a30d9107.zip
Support sorting for project board issuses (#17152)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/repo-projects.js40
1 files changed, 26 insertions, 14 deletions
diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js
index 986ada2956..5b3f54f8a6 100644
--- a/web_src/js/features/repo-projects.js
+++ b/web_src/js/features/repo-projects.js
@@ -1,5 +1,29 @@
const {csrfToken} = window.config;
+function moveIssue({item, from, to, oldIndex}) {
+ const columnCards = to.getElementsByClassName('board-card');
+
+ const columnSorting = {
+ issues: [...columnCards].map((card, i) => ({
+ issueID: parseInt($(card).attr('data-issue')),
+ sorting: i
+ }))
+ };
+
+ $.ajax({
+ url: `${to.getAttribute('data-url')}/move`,
+ data: JSON.stringify(columnSorting),
+ headers: {
+ 'X-Csrf-Token': csrfToken,
+ },
+ contentType: 'application/json',
+ type: 'POST',
+ error: () => {
+ from.insertBefore(item, from.children[oldIndex]);
+ }
+ });
+}
+
async function initRepoProjectSortable() {
const els = document.querySelectorAll('#project-board > .board');
if (!els.length) return;
@@ -40,20 +64,8 @@ async function initRepoProjectSortable() {
group: 'shared',
animation: 150,
ghostClass: 'card-ghost',
- onAdd: ({item, from, to, oldIndex}) => {
- const url = to.getAttribute('data-url');
- const issue = item.getAttribute('data-issue');
- $.ajax(`${url}/${issue}`, {
- headers: {
- 'X-Csrf-Token': csrfToken,
- },
- contentType: 'application/json',
- type: 'POST',
- error: () => {
- from.insertBefore(item, from.children[oldIndex]);
- },
- });
- },
+ onAdd: moveIssue,
+ onUpdate: moveIssue,
});
}
}