diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 9570f2d35..8f91684c1 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1,4 +1,5 @@ { + "endDate": "End date", "needLogin": "This function needs to be logged in to use", "calcResultCountAll": "COUNT", "calcResultCountValues": "VALUES", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index b927245a0..c6648ab84 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1,4 +1,5 @@ { + "endDate": "Fecha de finalización", "needLogin": "Esta función requiere iniciar sesión en la cuenta antes de poder usarla", "calcResultCountAll": "CONTAR", "calcResultCountValues": "VALORES", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index c8a5cc70b..52ed0cc5c 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1,4 +1,5 @@ { + "endDate": "Date de fin", "needLogin": "La fonctionnalité nécessite un numéro de compte de connexion avant de pouvoir être utilisée", "calcResultCountAll": "COUNT", "calcResultCountValues": "VALEURS", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 04b76c776..26d2df109 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1,4 +1,5 @@ { + "endDate": "結束日期", "needLogin": "該功能需要登錄賬號後才能使用", "calcResultCountAll": "行計數", "calcResultCountValues": "值計數", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index a1977f4c5..29917c847 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1,4 +1,5 @@ { + "endDate": "结束时间", "needLogin": "该功能需要登录账号后才能使用", "calcResultCountAll": "行计数", "calcResultCountValues": "值计数", diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 702b65932..877287ded 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -294,6 +294,9 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[]) => { } else if (["select", "mSelect"].includes(type) && blockElement) { openMenuPanel({protyle, blockElement, type: "select", cellElements}); return; + } else if (type === "date" && blockElement) { + openMenuPanel({protyle, blockElement, type: "date", cellElements}); + return; } window.siyuan.menus.menu.remove(); document.body.insertAdjacentHTML("beforeend", `
diff --git a/app/src/protyle/render/av/date.ts b/app/src/protyle/render/av/date.ts new file mode 100644 index 000000000..fd6694756 --- /dev/null +++ b/app/src/protyle/render/av/date.ts @@ -0,0 +1,43 @@ +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; + } + }); + let hasEndDate = true + let hasMatch = false + 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) { + hasEndDate = false + hasMatch = true + } + return true; + } + }); + return true; + } + }); + }); + if (!hasMatch) { + hasEndDate = false + } + return `
+ + + + +
` +} + +export const bindDateEvent = (options: { protyle: IProtyle, data: IAV, menuElement: HTMLElement }) => { + +} diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index ffa9e8c4f..36601ad55 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -7,13 +7,14 @@ import {hasClosestByAttribute} from "../../util/hasClosest"; import {bindSelectEvent, getSelectHTML, addColOptionOrCell, setColOption, removeCellOption} from "./select"; import {addFilter, getFiltersHTML, setFilter} from "./filter"; import {addSort, bindSortsEvent, getSortsHTML} from "./sort"; +import {bindDateEvent, getDateHTML} from "./date"; export const openMenuPanel = (options: { protyle: IProtyle, blockElement: HTMLElement, - type: "select" | "properties" | "config" | "sorts" | "filters" | "edit", + type: "select" | "properties" | "config" | "sorts" | "filters" | "edit" | "date", colId?: string, // for edit - cellElements?: HTMLElement[] // for select + cellElements?: HTMLElement[] // for select & date }) => { let avPanelElement = document.querySelector(".av__panel"); if (avPanelElement) { @@ -37,6 +38,8 @@ export const openMenuPanel = (options: { html = getSelectHTML(data.view, options.cellElements); } else if (options.type === "edit") { html = getEditHTML({protyle: options.protyle, data, colId: options.colId}); + } else if (options.type === "date") { + html = getDateHTML(data.view, options.cellElements); } document.body.insertAdjacentHTML("beforeend", `
@@ -50,8 +53,16 @@ export const openMenuPanel = (options: { const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect(); setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height); bindSelectEvent(options.protyle, data, menuElement, options.cellElements); - menuElement.querySelector("input").select(); - menuElement.querySelector("input").focus(); + const inputElement = menuElement.querySelector("input") + inputElement.select(); + inputElement.focus(); + } else if (options.type === "date") { + const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect(); + setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height); + bindDateEvent({protyle: options.protyle, data, menuElement}); + const inputElement = menuElement.querySelector("input") + inputElement.select(); + inputElement.focus(); } else { setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); if (options.type === "sorts") { @@ -263,29 +274,32 @@ export const openMenuPanel = (options: { } }); avPanelElement.addEventListener("click", (event) => { - event.preventDefault(); let target = event.target as HTMLElement; while (target && !target.isSameNode(avPanelElement)) { const type = target.dataset.type; if (type === "close") { avPanelElement.remove(); window.siyuan.menus.menu.remove(); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "goConfig") { menuElement.innerHTML = getConfigHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "goProperties") { menuElement.innerHTML = getPropertiesHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "goSorts") { menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts); bindSortsEvent(options.protyle, menuElement, data); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeSorts") { @@ -302,6 +316,7 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts); bindSortsEvent(options.protyle, menuElement, data); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "addSort") { @@ -313,6 +328,7 @@ export const openMenuPanel = (options: { avId: avID, protyle: options.protyle }); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeSort") { @@ -335,11 +351,13 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts); bindSortsEvent(options.protyle, menuElement, data); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "goFilters") { menuElement.innerHTML = getFiltersHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeFilters") { @@ -355,6 +373,7 @@ export const openMenuPanel = (options: { data.view.filters = []; menuElement.innerHTML = getFiltersHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "addFilter") { @@ -366,6 +385,7 @@ export const openMenuPanel = (options: { avId: avID, protyle: options.protyle }); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeFilter") { @@ -388,6 +408,7 @@ export const openMenuPanel = (options: { }]); menuElement.innerHTML = getFiltersHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "setFilter") { @@ -402,6 +423,7 @@ export const openMenuPanel = (options: { return true; } }); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "newCol") { @@ -413,6 +435,7 @@ export const openMenuPanel = (options: { h: tabRect.height, isLeft: true }); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "showAllCol") { @@ -440,6 +463,7 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getPropertiesHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); } + event.preventDefault(); event.stopPropagation(); break; } else if (type === "hideAllCol") { @@ -467,6 +491,7 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getPropertiesHTML(data.view); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); } + event.preventDefault(); event.stopPropagation(); break; } else if (type === "editCol") { @@ -476,6 +501,7 @@ export const openMenuPanel = (options: { colId: target.parentElement.dataset.id }); bindEditEvent({protyle: options.protyle, data, menuElement}); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "hideCol") { @@ -504,6 +530,7 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getPropertiesHTML(data.view); } setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "showCol") { @@ -532,6 +559,7 @@ export const openMenuPanel = (options: { menuElement.innerHTML = getPropertiesHTML(data.view); } setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "duplicateCol") { @@ -539,6 +567,7 @@ export const openMenuPanel = (options: { const colData = data.view.columns.find((item: IAVColumn) => item.id === colId); duplicateCol(options.protyle, colData.type, avID, colId, colData.name); avPanelElement.remove(); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeCol") { @@ -556,19 +585,23 @@ export const openMenuPanel = (options: { id: colId }]); avPanelElement.remove(); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "setColOption") { setColOption(options.protyle, data, target, options.cellElements); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "addColOptionOrCell") { addColOptionOrCell(options.protyle, data, options.cellElements, target, menuElement); window.siyuan.menus.menu.remove(); + event.preventDefault(); event.stopPropagation(); break; } else if (type === "removeCellOption") { removeCellOption(options.protyle, data, options.cellElements, target.parentElement); + event.preventDefault(); event.stopPropagation(); break; }