mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Support sorting for project board issuses (#17152)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -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,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user