mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00: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