Sort / Move project boards (#14634)

Sort Project board (#14533)
This commit is contained in:
Romain 2021-02-11 17:32:27 +01:00 committed by GitHub
parent ac97ea573c
commit c69c01d2b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 16 deletions

View file

@ -8,6 +8,34 @@ export default async function initProject() {
const {Sortable} = await import(/* webpackChunkName: "sortable" */'sortablejs');
const boardColumns = document.getElementsByClassName('board-column');
new Sortable(
document.getElementsByClassName('board')[0],
{
group: 'board-column',
draggable: '.board-column',
animation: 150,
onSort: () => {
const board = document.getElementsByClassName('board')[0];
const boardColumns = board.getElementsByClassName('board-column');
boardColumns.forEach((column, i) => {
if (parseInt($(column).data('sorting')) !== i) {
$.ajax({
url: $(column).data('url'),
data: JSON.stringify({sorting: i}),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
},
contentType: 'application/json',
method: 'PUT',
});
}
});
},
},
);
for (const column of boardColumns) {
new Sortable(
column.getElementsByClassName('board')[0],
@ -74,6 +102,7 @@ export default async function initProject() {
window.location.reload();
});
$('.delete-project-board').each(function () {
$(this).click(function (e) {
e.preventDefault();