1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

fix lints

This commit is contained in:
jackHay22 2025-01-17 13:50:11 -05:00
parent 12e3e0b3ad
commit 8d71b733ad

View File

@ -1,3 +1,4 @@
import $ from 'jquery';
import {hideElem, showElem, type DOMEvent} from '../utils/dom.ts'; import {hideElem, showElem, type DOMEvent} from '../utils/dom.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts'; import {fomanticQuery} from '../modules/fomantic/base.ts';
@ -23,7 +24,7 @@ function initTagNameEditor() {
if (!el) return; if (!el) return;
const tagWarning = document.querySelector('#tag-warning'); const tagWarning = document.querySelector('#tag-warning');
const tagWarningDetailLinks = Array.from(document.getElementsByClassName('tag-warning-detail')); const tagWarningDetailLinks = Array.from(document.querySelectorAll('.tag-warning-detail'));
const existingTags = JSON.parse(el.getAttribute('data-existing-tags')); const existingTags = JSON.parse(el.getAttribute('data-existing-tags'));
const defaultTagHelperText = el.getAttribute('data-tag-helper'); const defaultTagHelperText = el.getAttribute('data-tag-helper');
@ -38,23 +39,24 @@ function initTagNameEditor() {
$('.tag-confirm').on('click', (event) => { $('.tag-confirm').on('click', (event) => {
if (requiresConfirmation) { if (requiresConfirmation) {
event.preventDefault(); event.preventDefault();
if ($(event.target).hasClass('tag-draft')) { const form = event.target.closest('form');
if (event.target.classList.contains('tag-draft')) {
fomanticQuery(tagConfirmDraftModal).modal({ fomanticQuery(tagConfirmDraftModal).modal({
onApprove() { onApprove() {
// need to add hidden input with draft form value // need to add hidden input with draft form value
// (triggering form submission doesn't include the button data) // (triggering form submission doesn't include the button data)
$('<input>').attr({ const input = document.createElement('input');
type: 'hidden', input.type = 'hidden';
name: 'draft', input.name = 'draft';
value: '1' input.value = '1';
}).appendTo(event.target.form); form.append(input);
$(event.target.form).trigger('submit'); $(form).trigger('submit');
}, },
}).modal('show'); }).modal('show');
} else { } else {
fomanticQuery(tagConfirmModal).modal({ fomanticQuery(tagConfirmModal).modal({
onApprove() { onApprove() {
$(event.target.form).trigger('submit'); $(form).trigger('submit');
}, },
}).modal('show'); }).modal('show');
} }
@ -71,8 +73,9 @@ function initTagNameEditor() {
tagHelper.textContent = existingTagHelperText; tagHelper.textContent = existingTagHelperText;
showElem('#tag-warning'); showElem('#tag-warning');
for (const detail of tagWarningDetailLinks) { for (const detail of tagWarningDetailLinks) {
detail.href = `${tagURLStub}/${existingTags[value]}`; const anchor = detail as HTMLAnchorElement;
detail.textContent = existingTags[value].substring(0, 10); anchor.href = `${tagURLStub}/${existingTags[value]}`;
anchor.textContent = existingTags[value].substring(0, 10);
} }
requiresConfirmation = true; requiresConfirmation = true;
} else { } else {