mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 01:34:27 +00:00 
			
		
		
		
	Remove jQuery AJAX from the notice selection deletion button (#29381)
- Removed all jQuery AJAX calls and replaced with our fetch wrapper - Tested the repo notice selection deletion button functionality and it works as before Signed-off-by: Yarden Shoham <git@yardenshoham.com>
This commit is contained in:
		@@ -1,8 +1,9 @@
 | 
				
			|||||||
import $ from 'jquery';
 | 
					import $ from 'jquery';
 | 
				
			||||||
import {checkAppUrl} from '../common-global.js';
 | 
					import {checkAppUrl} from '../common-global.js';
 | 
				
			||||||
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
 | 
					import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
 | 
				
			||||||
 | 
					import {POST} from '../../modules/fetch.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {csrfToken, appSubUrl} = window.config;
 | 
					const {appSubUrl} = window.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function initAdminCommon() {
 | 
					export function initAdminCommon() {
 | 
				
			||||||
  if ($('.page-content.admin').length === 0) {
 | 
					  if ($('.page-content.admin').length === 0) {
 | 
				
			||||||
@@ -204,22 +205,18 @@ export function initAdminCommon() {
 | 
				
			|||||||
          break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    $('#delete-selection').on('click', function (e) {
 | 
					    $('#delete-selection').on('click', async function (e) {
 | 
				
			||||||
      e.preventDefault();
 | 
					      e.preventDefault();
 | 
				
			||||||
      const $this = $(this);
 | 
					      const $this = $(this);
 | 
				
			||||||
      $this.addClass('loading disabled');
 | 
					      $this.addClass('loading disabled');
 | 
				
			||||||
      const ids = [];
 | 
					      const data = new FormData();
 | 
				
			||||||
      $checkboxes.each(function () {
 | 
					      $checkboxes.each(function () {
 | 
				
			||||||
        if ($(this).checkbox('is checked')) {
 | 
					        if ($(this).checkbox('is checked')) {
 | 
				
			||||||
          ids.push($(this).data('id'));
 | 
					          data.append('ids[]', $(this).data('id'));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      $.post($this.data('link'), {
 | 
					      await POST($this.data('link'), {data});
 | 
				
			||||||
        _csrf: csrfToken,
 | 
					 | 
				
			||||||
        ids
 | 
					 | 
				
			||||||
      }).done(() => {
 | 
					 | 
				
			||||||
      window.location.href = $this.data('redirect');
 | 
					      window.location.href = $this.data('redirect');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user