This commit is contained in:
Vanessa 2023-07-22 10:20:11 +08:00
parent 0af27fa5d8
commit 09fd48f25a
2 changed files with 12 additions and 12 deletions

View file

@ -5,16 +5,16 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
return item; return item;
} }
}); });
let hasEndDate = true let hasEndDate = true;
let hasMatch = false let hasMatch = false;
cellElements.forEach((cellElement) => { cellElements.forEach((cellElement) => {
data.rows.find(row => { data.rows.find(row => {
if (cellElement.parentElement.dataset.id === row.id) { if (cellElement.parentElement.dataset.id === row.id) {
row.cells.find(cell => { row.cells.find(cell => {
if (cell.id === cellElement.dataset.id) { if (cell.id === cellElement.dataset.id) {
if (!cell.value || !cell.value.date || !cell.value.date.content2) { if (!cell.value || !cell.value.date || !cell.value.date.content2) {
hasEndDate = false hasEndDate = false;
hasMatch = true hasMatch = true;
} }
return true; return true;
} }
@ -24,20 +24,20 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
}); });
}); });
if (!hasMatch) { if (!hasMatch) {
hasEndDate = false hasEndDate = false;
} }
return `<div> return `<div>
<input type="date" class="b3-text-field fn__block"> <input type="datetime-local" class="b3-text-field fn__block">
<input type="date" class="b3-text-field fn__block${hasEndDate ? "" : " fn__none"}"> <input type="datetime-local" class="b3-text-field fn__block${hasEndDate ? "" : " fn__none"}">
<button class="b3-menu__separator"></button> <button class="b3-menu__separator"></button>
<button class="b3-menu__item"> <button class="b3-menu__item">
<span>${window.siyuan.languages.endDate}</span> <span>${window.siyuan.languages.endDate}</span>
<span class="fn__space fn__flex-1"></span> <span class="fn__space fn__flex-1"></span>
<input type="checkbox" class="b3-switch fn__flex-center"${hasEndDate ? " checked" : ""}> <input type="checkbox" class="b3-switch fn__flex-center"${hasEndDate ? " checked" : ""}>
</button> </button>
</div>` </div>`;
} };
export const bindDateEvent = (options: { protyle: IProtyle, data: IAV, menuElement: HTMLElement }) => { export const bindDateEvent = (options: { protyle: IProtyle, data: IAV, menuElement: HTMLElement }) => {
} };

View file

@ -53,14 +53,14 @@ export const openMenuPanel = (options: {
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect(); const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height); setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
bindSelectEvent(options.protyle, data, menuElement, options.cellElements); bindSelectEvent(options.protyle, data, menuElement, options.cellElements);
const inputElement = menuElement.querySelector("input") const inputElement = menuElement.querySelector("input");
inputElement.select(); inputElement.select();
inputElement.focus(); inputElement.focus();
} else if (options.type === "date") { } else if (options.type === "date") {
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect(); const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height); setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
bindDateEvent({protyle: options.protyle, data, menuElement}); bindDateEvent({protyle: options.protyle, data, menuElement});
const inputElement = menuElement.querySelector("input") const inputElement = menuElement.querySelector("input");
inputElement.select(); inputElement.select();
inputElement.focus(); inputElement.focus();
} else { } else {