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