Remove jQuery AJAX from the issue branch reference selection (#29722)
- Replaced a single jQuery AJAX instance with our fetch wrapper - Tested the issue branch reference selection and it works as before # Demo using `fetch` instead of jQuery AJAX ![demo](https://github.com/go-gitea/gitea/assets/20454870/7e195632-41f8-494b-b599-f6291860f330) Signed-off-by: Yarden Shoham <git@yardenshoham.com> (cherry picked from commit 75a9f61f89caada64f6398130844281e4f088a73)
This commit is contained in:
parent
c9d9255244
commit
3acb68e5e4
1 changed files with 10 additions and 2 deletions
|
@ -24,6 +24,7 @@ import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
|
||||||
import {hideElem, showElem} from '../utils/dom.js';
|
import {hideElem, showElem} from '../utils/dom.js';
|
||||||
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
|
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
|
||||||
import {attachRefIssueContextPopup} from './contextpopup.js';
|
import {attachRefIssueContextPopup} from './contextpopup.js';
|
||||||
|
import {POST} from '../modules/fetch.js';
|
||||||
|
|
||||||
const {csrfToken} = window.config;
|
const {csrfToken} = window.config;
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ export function initRepoCommentForm() {
|
||||||
const $selectBranch = $('.ui.select-branch');
|
const $selectBranch = $('.ui.select-branch');
|
||||||
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
||||||
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
||||||
$branchMenu.find('.item:not(.no-select)').on('click', function () {
|
$branchMenu.find('.item:not(.no-select)').on('click', async function () {
|
||||||
const selectedValue = $(this).data('id');
|
const selectedValue = $(this).data('id');
|
||||||
const editMode = $('#editing_mode').val();
|
const editMode = $('#editing_mode').val();
|
||||||
$($(this).data('id-selector')).val(selectedValue);
|
$($(this).data('id-selector')).val(selectedValue);
|
||||||
|
@ -76,7 +77,14 @@ export function initRepoCommentForm() {
|
||||||
|
|
||||||
if (editMode === 'true') {
|
if (editMode === 'true') {
|
||||||
const form = $('#update_issueref_form');
|
const form = $('#update_issueref_form');
|
||||||
$.post(form.attr('action'), {_csrf: csrfToken, ref: selectedValue}, () => window.location.reload());
|
const params = new URLSearchParams();
|
||||||
|
params.append('ref', selectedValue);
|
||||||
|
try {
|
||||||
|
await POST(form.attr('action'), {data: params});
|
||||||
|
window.location.reload();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
}
|
||||||
} else if (editMode === '') {
|
} else if (editMode === '') {
|
||||||
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue