This commit is contained in:
parent
4406dc687b
commit
55fdc3741e
7 changed files with 73 additions and 15 deletions
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"searchRemoveName": "Do you want to delete ${x} and assign its query condition to ${y}?",
|
||||
"searchUpdateName": "Update name ${x} to ${y}?",
|
||||
"searchAssetContent": "Search asset file content",
|
||||
"searchOverwrite": "The query name is duplicated, do you want to overwrite it?",
|
||||
"onepay": "PRO",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"searchRemoveName": "¿Desea eliminar ${x} y asignar su condición de consulta a ${y}?",
|
||||
"searchUpdateName": "¿Actualizar nombre ${x} a ${y}?",
|
||||
"searchAssetContent": "Buscar contenido del archivo de activos",
|
||||
"searchOverwrite": "El nombre de la consulta está duplicado, ¿quieres sobrescribirlo?",
|
||||
"onepay": "PRO",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"searchRemoveName": "Voulez-vous supprimer ${x} et affecter sa condition de requête à ${y} ?",
|
||||
"searchUpdateName": "Mettre à jour le nom ${x} en ${y} ?",
|
||||
"searchAssetContent": "Rechercher le contenu du fichier d'actif",
|
||||
"searchOverwrite": "Le nom de la requête est dupliqué, voulez-vous l'écraser ?",
|
||||
"onepay": "PRO",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"searchRemoveName": "是否刪 ${x} 並將其查詢條件賦值給 ${y}?",
|
||||
"searchUpdateName": "是否將查詢名稱 ${x} 更新為 ${y}?",
|
||||
"searchAssetContent": "搜索資源文件內容",
|
||||
"searchOverwrite": "查詢名稱重複,是否進行覆蓋?",
|
||||
"onepay": "功能特性",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"searchRemoveName": "是否删 ${x} 并将其查询条件赋值给 ${y}?",
|
||||
"searchUpdateName": "是否将查询名称 ${x} 更新为 ${y}?",
|
||||
"searchAssetContent": "搜索资源文件内容",
|
||||
"searchOverwrite": "查询名称重复,是否进行覆盖?",
|
||||
"onepay": "功能特性",
|
||||
|
|
|
@ -458,7 +458,6 @@ const initSearchEvent = (app: App, element: Element, config: ISearchOption) => {
|
|||
}
|
||||
}, config);
|
||||
});
|
||||
element.querySelector("#criteria .b3-chip--current")?.classList.remove("b3-chip--current");
|
||||
window.siyuan.menus.menu.element.style.zIndex = "220";
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
event.stopPropagation();
|
||||
|
|
|
@ -192,13 +192,6 @@ const saveCriterionData = (config: ISearchOption,
|
|||
element: Element,
|
||||
value: string,
|
||||
saveDialog: Dialog) => {
|
||||
if (isMobile()) {
|
||||
config.k = (document.querySelector("#toolbarSearch") as HTMLInputElement).value;
|
||||
config.r = (element.querySelector("#toolbarReplace") as HTMLInputElement).value;
|
||||
} else {
|
||||
config.k = (element.querySelector("#searchInput") as HTMLInputElement).value;
|
||||
config.r = (element.querySelector("#replaceInput") as HTMLInputElement).value;
|
||||
}
|
||||
config.removed = false;
|
||||
const criterion = config;
|
||||
criterion.name = value;
|
||||
|
@ -240,14 +233,26 @@ export const saveCriterion = (config: ISearchOption,
|
|||
showMessage(window.siyuan.languages["_kernel"]["142"]);
|
||||
return;
|
||||
}
|
||||
const hasSame = criteriaData.find(item => {
|
||||
if (isMobile()) {
|
||||
config.k = (document.querySelector("#toolbarSearch") as HTMLInputElement).value;
|
||||
config.r = (element.querySelector("#toolbarReplace") as HTMLInputElement).value;
|
||||
} else {
|
||||
config.k = (element.querySelector("#searchInput") as HTMLInputElement).value;
|
||||
config.r = (element.querySelector("#replaceInput") as HTMLInputElement).value;
|
||||
}
|
||||
const criteriaElement = element.querySelector("#criteria").firstElementChild;
|
||||
let hasSameName = "";
|
||||
let hasSameConfig = "";
|
||||
criteriaData.forEach(item => {
|
||||
if (item.name === value) {
|
||||
return true;
|
||||
hasSameName = item.name;
|
||||
}
|
||||
if (configIsSame(item, config)) {
|
||||
hasSameConfig = item.name;
|
||||
}
|
||||
});
|
||||
if (hasSame) {
|
||||
if (hasSameName && !hasSameConfig) {
|
||||
confirmDialog(window.siyuan.languages.confirm, window.siyuan.languages.searchOverwrite, () => {
|
||||
const criteriaElement = element.querySelector("#criteria").firstElementChild;
|
||||
Array.from(criteriaElement.children).forEach(item => {
|
||||
if (item.textContent === value) {
|
||||
item.remove();
|
||||
|
@ -261,6 +266,43 @@ export const saveCriterion = (config: ISearchOption,
|
|||
});
|
||||
saveCriterionData(config, criteriaData, element, value, saveDialog);
|
||||
});
|
||||
} else if (hasSameName && hasSameConfig) {
|
||||
if (hasSameName === hasSameConfig) {
|
||||
saveDialog.destroy();
|
||||
} else {
|
||||
const removeName = hasSameName === value ? hasSameConfig : hasSameName;
|
||||
confirmDialog(window.siyuan.languages.confirm, window.siyuan.languages.searchRemoveName.replace("${x}", removeName).replace("${y}", value), () => {
|
||||
Array.from(criteriaElement.children).forEach(item => {
|
||||
if (item.textContent === hasSameConfig || item.textContent === hasSameName) {
|
||||
item.remove();
|
||||
}
|
||||
});
|
||||
criteriaData.find((item, index) => {
|
||||
if (item.name === removeName || item.name === hasSameName) {
|
||||
fetchPost("/api/storage/removeCriterion", {name: removeName});
|
||||
criteriaData.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
saveCriterionData(config, criteriaData, element, value, saveDialog);
|
||||
})
|
||||
}
|
||||
} else if (!hasSameName && hasSameConfig) {
|
||||
confirmDialog(window.siyuan.languages.confirm, window.siyuan.languages.searchUpdateName.replace("${x}", hasSameConfig).replace("${y}", value), () => {
|
||||
Array.from(criteriaElement.children).forEach(item => {
|
||||
if (item.textContent === hasSameConfig) {
|
||||
item.remove();
|
||||
}
|
||||
});
|
||||
criteriaData.find((item, index) => {
|
||||
if (item.name === hasSameConfig) {
|
||||
fetchPost("/api/storage/removeCriterion", {name: hasSameConfig});
|
||||
criteriaData.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
saveCriterionData(config, criteriaData, element, value, saveDialog);
|
||||
});
|
||||
} else {
|
||||
saveCriterionData(config, criteriaData, element, value, saveDialog);
|
||||
}
|
||||
|
@ -411,15 +453,22 @@ export const moreMenu = async (config: ISearchOption,
|
|||
}).element);
|
||||
};
|
||||
|
||||
const configIsSame = (config: ISearchOption, config2: ISearchOption) => {
|
||||
if (config2.group === config.group && config2.hPath === config.hPath && config2.hasReplace === config.hasReplace &&
|
||||
config2.k === config.k && config2.method === config.method && config2.r === config.r &&
|
||||
config2.sort === config.sort && objEquals(config2.types, config.types) && objEquals(config2.idPath, config.idPath)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export const initCriteriaMenu = (element: HTMLElement, data: ISearchOption[], config: ISearchOption) => {
|
||||
fetchPost("/api/storage/getCriteria", {}, (response) => {
|
||||
let html = "";
|
||||
response.data.forEach((item: ISearchOption, index: number) => {
|
||||
data.push(item);
|
||||
let isSame = false;
|
||||
if (item.group === config.group && item.hPath === config.hPath && item.hasReplace === config.hasReplace &&
|
||||
item.k === config.k && item.method === config.method && item.r === config.r &&
|
||||
item.sort === config.sort && objEquals(item.types, config.types) && objEquals(item.idPath, config.idPath)) {
|
||||
if (configIsSame(item, config)) {
|
||||
isSame = true;
|
||||
}
|
||||
html += `<div data-type="set-criteria" class="${isSame ? "b3-chip--current " : ""}b3-chip b3-chip--middle b3-chip--pointer b3-chip--${["secondary", "primary", "info", "success", "warning", "error", ""][index % 7]}">${escapeHtml(item.name)}<svg class="b3-chip__close" data-type="remove-criteria"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
||||
|
|
Loading…
Add table
Reference in a new issue