Align notes workspace filter/load behavior with legacy records
This commit is contained in:
+23
-10
@@ -143,7 +143,8 @@
|
|||||||
<div class="mt-4 grid gap-3 md:grid-cols-2">
|
<div class="mt-4 grid gap-3 md:grid-cols-2">
|
||||||
<input id="searchInput" class="field" placeholder="Search notes..." />
|
<input id="searchInput" class="field" placeholder="Search notes..." />
|
||||||
<select id="hiddenMode" class="field">
|
<select id="hiddenMode" class="field">
|
||||||
<option value="visible" selected>Show Visible</option>
|
<option value="all" selected>Show All</option>
|
||||||
|
<option value="visible">Show Visible</option>
|
||||||
<option value="hidden">Show Hidden</option>
|
<option value="hidden">Show Hidden</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -352,13 +353,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function passFilter(note) {
|
function passFilter(note) {
|
||||||
if (toBoolFlag(note?.delete)) return false;
|
|
||||||
|
|
||||||
const wantHidden = hiddenMode.value === 'hidden';
|
|
||||||
const isHidden = toBoolFlag(note?.hidden);
|
const isHidden = toBoolFlag(note?.hidden);
|
||||||
if (wantHidden !== isHidden) return false;
|
const hiddenView = hiddenMode.value;
|
||||||
|
if (hiddenView === 'visible' && isHidden) return false;
|
||||||
|
if (hiddenView === 'hidden' && !isHidden) return false;
|
||||||
|
|
||||||
if (currentFilter === 'myshared' && !(isMine(note) && toBoolFlag(note?.shared))) return false;
|
if (currentFilter === 'myshared' && !toBoolFlag(note?.shared)) return false;
|
||||||
if (currentFilter === 'sharedwithme' && !isSharedWithCurrentUser(note)) return false;
|
if (currentFilter === 'sharedwithme' && !isSharedWithCurrentUser(note)) return false;
|
||||||
if (currentFilter === 'job' && !(toBoolFlag(note?.job_note) || noteType(note) === 'job')) return false;
|
if (currentFilter === 'job' && !(toBoolFlag(note?.job_note) || noteType(note) === 'job')) return false;
|
||||||
if (currentFilter === 'manager' && noteType(note) !== 'manager') return false;
|
if (currentFilter === 'manager' && noteType(note) !== 'manager') return false;
|
||||||
@@ -507,10 +507,23 @@
|
|||||||
async function loadNotes() {
|
async function loadNotes() {
|
||||||
await ensurePocketBaseClient();
|
await ensurePocketBaseClient();
|
||||||
ensureLoggedIn();
|
ensureLoggedIn();
|
||||||
const records = await pb.collection(NOTES_COLLECTION).getFullList({
|
let records = [];
|
||||||
sort: '-updated,-created',
|
try {
|
||||||
});
|
const page = await pb.collection(NOTES_COLLECTION).getList(1, 200, {
|
||||||
allNotes = Array.isArray(records) ? records : [];
|
sort: '-updated,-created',
|
||||||
|
});
|
||||||
|
records = Array.isArray(page?.items) ? page.items : [];
|
||||||
|
} catch {
|
||||||
|
const full = await pb.collection(NOTES_COLLECTION).getFullList({
|
||||||
|
sort: '-updated,-created',
|
||||||
|
});
|
||||||
|
records = Array.isArray(full) ? full : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
allNotes = records.map((note) => ({
|
||||||
|
...note,
|
||||||
|
_sharedWithMe: isSharedWithCurrentUser(note),
|
||||||
|
}));
|
||||||
if (selectedNote) {
|
if (selectedNote) {
|
||||||
const refreshed = allNotes.find((n) => n.id === selectedNote.id);
|
const refreshed = allNotes.find((n) => n.id === selectedNote.id);
|
||||||
selectedNote = refreshed || null;
|
selectedNote = refreshed || null;
|
||||||
|
|||||||
Reference in New Issue
Block a user