Support sorting for project board issuses (#17152)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
4cbe792562
commit
0ff18a808c
8 changed files with 115 additions and 58 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue