This commit is contained in:
admin
2026-03-03 00:01:51 +09:00
parent 068903b933
commit 079057ef41
2 changed files with 36 additions and 13 deletions

View File

@@ -252,7 +252,9 @@
// 科目選択履歴を保存journal-entry.htmlと共通のlocalStorageキー // 科目選択履歴を保存journal-entry.htmlと共通のlocalStorageキー
function saveAccountToRecentEdit(accountId) { function saveAccountToRecentEdit(accountId) {
if (!accountId) return; if (!accountId) return;
let recent = JSON.parse(localStorage.getItem("recentAccounts") || "[]"); let recent = JSON.parse(
localStorage.getItem("recentAccounts") || "[]",
);
recent = recent.filter((id) => id !== accountId); recent = recent.filter((id) => id !== accountId);
recent.unshift(accountId); recent.unshift(accountId);
if (recent.length > 20) recent = recent.slice(0, 20); if (recent.length > 20) recent = recent.slice(0, 20);
@@ -261,7 +263,8 @@
function makeLbl(text) { function makeLbl(text) {
const lbl = document.createElement("div"); const lbl = document.createElement("div");
lbl.style.cssText = "padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;"; lbl.style.cssText =
"padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;";
lbl.textContent = text; lbl.textContent = text;
return lbl; return lbl;
} }
@@ -296,11 +299,17 @@
if (filtered.length === 0) { if (filtered.length === 0) {
dropdown.innerHTML = `<div style="padding: 8px 12px; color: #999;">該当する科目がありません</div>`; dropdown.innerHTML = `<div style="padding: 8px 12px; color: #999;">該当する科目がありません</div>`;
} else if (isFiltered) { } else if (isFiltered) {
const sorted = filtered.slice().sort((a, b) => a.account_code.localeCompare(b.account_code)); const sorted = filtered
.slice()
.sort((a, b) => a.account_code.localeCompare(b.account_code));
sorted.slice(0, 50).forEach(appendOpt); sorted.slice(0, 50).forEach(appendOpt);
} else { } else {
const recentIds = JSON.parse(localStorage.getItem("recentAccounts") || "[]"); const recentIds = JSON.parse(
const recentItems = recentIds.map((id) => filtered.find((a) => a.account_id === id)).filter(Boolean); localStorage.getItem("recentAccounts") || "[]",
);
const recentItems = recentIds
.map((id) => filtered.find((a) => a.account_id === id))
.filter(Boolean);
const recentSet = new Set(recentIds); const recentSet = new Set(recentIds);
const otherItems = filtered const otherItems = filtered
.filter((a) => !recentSet.has(a.account_id)) .filter((a) => !recentSet.has(a.account_id))

View File

@@ -760,7 +760,8 @@
function makeSectionLabel(text) { function makeSectionLabel(text) {
const lbl = document.createElement("div"); const lbl = document.createElement("div");
lbl.style.cssText = "padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;"; lbl.style.cssText =
"padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;";
lbl.textContent = text; lbl.textContent = text;
return lbl; return lbl;
} }
@@ -776,12 +777,18 @@
if (isFiltered) { if (isFiltered) {
// 検索中 → コード順で表示 // 検索中 → コード順で表示
const sorted = list.slice().sort((a, b) => a.account_code.localeCompare(b.account_code)); const sorted = list
.slice()
.sort((a, b) => a.account_code.localeCompare(b.account_code));
sorted.slice(0, 50).forEach((acc) => appendAccountOption(acc)); sorted.slice(0, 50).forEach((acc) => appendAccountOption(acc));
} else { } else {
// 未入力 → 最近使った科目を先頭に、残りはコード順 // 未入力 → 最近使った科目を先頭に、残りはコード順
const recentIds = JSON.parse(localStorage.getItem("recentAccounts") || "[]"); const recentIds = JSON.parse(
const recentItems = recentIds.map((id) => list.find((a) => a.account_id === id)).filter(Boolean); localStorage.getItem("recentAccounts") || "[]",
);
const recentItems = recentIds
.map((id) => list.find((a) => a.account_id === id))
.filter(Boolean);
const recentSet = new Set(recentIds); const recentSet = new Set(recentIds);
const otherItems = list const otherItems = list
.filter((a) => !recentSet.has(a.account_id)) .filter((a) => !recentSet.has(a.account_id))
@@ -925,7 +932,8 @@
function makeSearchSectionLabel(text) { function makeSearchSectionLabel(text) {
const lbl = document.createElement("div"); const lbl = document.createElement("div");
lbl.style.cssText = "padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;"; lbl.style.cssText =
"padding:3px 12px;font-size:11px;color:#888;background:#f5f5f5;font-weight:bold;border-bottom:1px solid #e0e0e0;";
lbl.textContent = text; lbl.textContent = text;
return lbl; return lbl;
} }
@@ -956,11 +964,17 @@
} }
if (isFiltered) { if (isFiltered) {
const sorted = list.slice().sort((a, b) => a.account_code.localeCompare(b.account_code)); const sorted = list
.slice()
.sort((a, b) => a.account_code.localeCompare(b.account_code));
sorted.slice(0, 50).forEach(appendSearchOption); sorted.slice(0, 50).forEach(appendSearchOption);
} else { } else {
const recentIds = JSON.parse(localStorage.getItem("recentAccounts") || "[]"); const recentIds = JSON.parse(
const recentItems = recentIds.map((id) => list.find((a) => a.account_id === id)).filter(Boolean); localStorage.getItem("recentAccounts") || "[]",
);
const recentItems = recentIds
.map((id) => list.find((a) => a.account_id === id))
.filter(Boolean);
const recentSet = new Set(recentIds); const recentSet = new Set(recentIds);
const otherItems = list const otherItems = list
.filter((a) => !recentSet.has(a.account_id)) .filter((a) => !recentSet.has(a.account_id))