Fix milestone deadline and date related problems (#32339)
Use zero instead of 9999-12-31 for deadline Fix #32291 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
1887c75c35
commit
24b83ff63e
23 changed files with 147 additions and 165 deletions
|
@ -3,6 +3,7 @@ import {POST} from '../modules/fetch.ts';
|
|||
import {updateIssuesMeta} from './repo-common.ts';
|
||||
import {svg} from '../svg.ts';
|
||||
import {htmlEscape} from 'escape-goat';
|
||||
import {toggleElem} from '../utils/dom.ts';
|
||||
|
||||
// if there are draft comments, confirm before reloading, to avoid losing comments
|
||||
function reloadConfirmDraftComment() {
|
||||
|
@ -258,8 +259,22 @@ function selectItem(select_id, input_id) {
|
|||
});
|
||||
}
|
||||
|
||||
function initRepoIssueDue() {
|
||||
const form = document.querySelector<HTMLFormElement>('.issue-due-form');
|
||||
if (!form) return;
|
||||
const deadline = form.querySelector<HTMLInputElement>('input[name=deadline]');
|
||||
document.querySelector('.issue-due-edit')?.addEventListener('click', () => {
|
||||
toggleElem(form);
|
||||
});
|
||||
document.querySelector('.issue-due-remove')?.addEventListener('click', () => {
|
||||
deadline.value = '';
|
||||
form.dispatchEvent(new Event('submit', {cancelable: true, bubbles: true}));
|
||||
});
|
||||
}
|
||||
|
||||
export function initRepoIssueSidebar() {
|
||||
initBranchSelector();
|
||||
initRepoIssueDue();
|
||||
|
||||
// Init labels and assignees
|
||||
initListSubmits('select-label', 'labels');
|
||||
|
|
|
@ -43,52 +43,6 @@ export function initRepoIssueTimeTracking() {
|
|||
});
|
||||
}
|
||||
|
||||
async function updateDeadline(deadlineString) {
|
||||
hideElem('#deadline-err-invalid-date');
|
||||
document.querySelector('#deadline-loader')?.classList.add('is-loading');
|
||||
|
||||
let realDeadline = null;
|
||||
if (deadlineString !== '') {
|
||||
const newDate = Date.parse(deadlineString);
|
||||
|
||||
if (Number.isNaN(newDate)) {
|
||||
document.querySelector('#deadline-loader')?.classList.remove('is-loading');
|
||||
showElem('#deadline-err-invalid-date');
|
||||
return false;
|
||||
}
|
||||
realDeadline = new Date(newDate);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await POST(document.querySelector('#update-issue-deadline-form').getAttribute('action'), {
|
||||
data: {due_date: realDeadline},
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
throw new Error('Invalid response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
document.querySelector('#deadline-loader').classList.remove('is-loading');
|
||||
showElem('#deadline-err-invalid-date');
|
||||
}
|
||||
}
|
||||
|
||||
export function initRepoIssueDue() {
|
||||
$(document).on('click', '.issue-due-edit', () => {
|
||||
toggleElem('#deadlineForm');
|
||||
});
|
||||
$(document).on('click', '.issue-due-remove', () => {
|
||||
updateDeadline('');
|
||||
});
|
||||
$(document).on('submit', '.issue-due-form', () => {
|
||||
updateDeadline($('#deadlineDate').val());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} item
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import $ from 'jquery';
|
||||
|
||||
export function initRepoMilestone() {
|
||||
// Milestones
|
||||
if ($('.repository.new.milestone').length > 0) {
|
||||
$('#clear-date').on('click', () => {
|
||||
$('#deadline').val('');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
const page = document.querySelector('.repository.new.milestone');
|
||||
if (!page) return;
|
||||
|
||||
const deadline = page.querySelector<HTMLInputElement>('form input[name=deadline]');
|
||||
document.querySelector('#milestone-clear-deadline').addEventListener('click', () => {
|
||||
deadline.value = '';
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import {initPdfViewer} from './render/pdf.ts';
|
|||
|
||||
import {initUserAuthOauth2, initUserCheckAppUrl} from './features/user-auth.ts';
|
||||
import {
|
||||
initRepoIssueDue,
|
||||
initRepoIssueReferenceRepositorySearch,
|
||||
initRepoIssueTimeTracking,
|
||||
initRepoIssueWipTitle,
|
||||
|
@ -181,7 +180,6 @@ onDomReady(() => {
|
|||
initRepoEditor,
|
||||
initRepoGraphGit,
|
||||
initRepoIssueContentHistory,
|
||||
initRepoIssueDue,
|
||||
initRepoIssueList,
|
||||
initRepoIssueSidebarList,
|
||||
initArchivedLabelHandler,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue