Merge feature/date-group-relative-labels
@@ -252,7 +252,7 @@
252
252
- openSidebar(item) - Renders item details/actions in sidebar; root selections include alias/original name/usage/access list and keep Rename while hiding Move To/Delete.
253
253
- openFolderSidebar() - Shows current folder details when nothing is selected; when at root base-level it also shows root access list.
254
254
- openFolderSidebar() / renderFolderViewControls(actions, dirPath) - In folder overview mode, renders per-folder view controls (Sort by, Group by, folders-first, ascending) and persists them per user+folder in localStorage.
255
- renderFileGrid() / buildFileGridRows(items, prefs) - Applies folder view ordering as Group option > folders-first option > sort option, and inserts labelled separator rows when grouping is enabled.
255
- renderFileGrid() / buildFileGridRows(items, prefs) - Applies folder view ordering as Group option > folders-first option > sort option, inserts labelled separator rows when grouping is enabled, and uses relative date labels for recent date groups (`today`, `yesterday`, `two`-`six days ago`, `one week ago`) before falling back to calendar dates.
256
256
- openRenameModal(item) - Renames files/folders; for roots this writes display alias via /api/files/root-alias and reloads roots.
257
257
- uploadFiles(fileList) - Uploads files one-by-one with per-file conflict prompt (overwrite/rename/cancel) when names already exist.
258
258
- openUserModal(user, paths) - Admin user editor; enforces UI permission rule that Write is disabled/unchecked while Read is unchecked and disables the Admin checkbox when editing the current signed-in admin account.
@@ -252,7 +252,7 @@252
- openSidebar(item) - Renders item details/actions in sidebar; root selections include alias/original name/usage/access list and keep Rename while hiding Move To/Delete.
252
- openSidebar(item) - Renders item details/actions in sidebar; root selections include alias/original name/usage/access list and keep Rename while hiding Move To/Delete.
253
- openFolderSidebar() - Shows current folder details when nothing is selected; when at root base-level it also shows root access list.
253
- openFolderSidebar() - Shows current folder details when nothing is selected; when at root base-level it also shows root access list.
254
- openFolderSidebar() / renderFolderViewControls(actions, dirPath) - In folder overview mode, renders per-folder view controls (Sort by, Group by, folders-first, ascending) and persists them per user+folder in localStorage.
254
- openFolderSidebar() / renderFolderViewControls(actions, dirPath) - In folder overview mode, renders per-folder view controls (Sort by, Group by, folders-first, ascending) and persists them per user+folder in localStorage.
255
- renderFileGrid() / buildFileGridRows(items, prefs) - Applies folder view ordering as Group option > folders-first option > sort option, and inserts labelled separator rows when grouping is enabled.
255
- renderFileGrid() / buildFileGridRows(items, prefs) - Applies folder view ordering as Group option > folders-first option > sort option, inserts labelled separator rows when grouping is enabled, and uses relative date labels for recent date groups (`today`, `yesterday`, `two`-`six days ago`, `one week ago`) before falling back to calendar dates.
256
- openRenameModal(item) - Renames files/folders; for roots this writes display alias via /api/files/root-alias and reloads roots.
256
- openRenameModal(item) - Renames files/folders; for roots this writes display alias via /api/files/root-alias and reloads roots.
257
- uploadFiles(fileList) - Uploads files one-by-one with per-file conflict prompt (overwrite/rename/cancel) when names already exist.
257
- uploadFiles(fileList) - Uploads files one-by-one with per-file conflict prompt (overwrite/rename/cancel) when names already exist.
258
- openUserModal(user, paths) - Admin user editor; enforces UI permission rule that Write is disabled/unchecked while Read is unchecked and disables the Admin checkbox when editing the current signed-in admin account.
258
- openUserModal(user, paths) - Admin user editor; enforces UI permission rule that Write is disabled/unchecked while Read is unchecked and disables the Admin checkbox when editing the current signed-in admin account.
@@ -2086,9 +2086,31 @@ function dayStartMsFromTimestamp (value)
2086
2086
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
2087
2087
}
2088
2088
2089
function dayCountWord (count)
2090
{
2091
const words = {
2092
2: 'two',
2093
3: 'three',
2094
4: 'four',
2095
5: 'five',
2096
6: 'six',
2097
};
2098
return words[count] || String(count);
2099
}
2100
2089
2101
function groupDateLabel (dayStartMs)
2090
2102
{
2091
2103
if (!Number.isFinite(dayStartMs)) return 'Unknown date';
2104
2105
const now = new Date();
2106
const todayStartMs = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
2107
const diffDays = Math.floor((todayStartMs - dayStartMs) / (24 * 60 * 60 * 1000));
2108
2109
if (diffDays === 0) return 'today';
2110
if (diffDays === 1) return 'yesterday';
2111
if (diffDays >= 2 && diffDays <= 6) return `${dayCountWord(diffDays)} days ago`;
2112
if (diffDays === 7) return 'one week ago';
2113
2092
2114
return new Date(dayStartMs).toLocaleDateString('en-GB', {
2093
2115
day: '2-digit',
2094
2116
month: 'short',
@@ -3354,6 +3376,7 @@ function globalFaviconFallbackMarkup ()
3354
3376
3355
3377
function applyGlobalFaviconPreview (hasFavicon)
3356
3378
{
3379
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
3357
3380
const preview = document.getElementById('global-favicon-preview');
3358
3381
if (!preview) return;
3359
3382
@@ -3376,6 +3399,7 @@ function applyGlobalFaviconPreview (hasFavicon)
3376
3399
3377
3400
function applyGlobalFaviconLink (hasFavicon)
3378
3401
{
3402
if (typeof document === 'undefined' || typeof document.getElementById !== 'function' || !document.head) return;
3379
3403
let link = document.getElementById('global-favicon-link');
3380
3404
if (!link)
3381
3405
{
@@ -2086,9 +2086,31 @@ function dayStartMsFromTimestamp (value)2086
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();2086
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();2087
}2087
}2088
2088
2089
function dayCountWord (count)2090
{2091
const words = {2092
2: 'two',2093
3: 'three',2094
4: 'four',2095
5: 'five',2096
6: 'six',2097
};2098
return words[count] || String(count);2099
}2100
2089
function groupDateLabel (dayStartMs)2101
function groupDateLabel (dayStartMs)2090
{2102
{2091
if (!Number.isFinite(dayStartMs)) return 'Unknown date';2103
if (!Number.isFinite(dayStartMs)) return 'Unknown date';2104
2105
const now = new Date();2106
const todayStartMs = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();2107
const diffDays = Math.floor((todayStartMs - dayStartMs) / (24 * 60 * 60 * 1000));2108
2109
if (diffDays === 0) return 'today';2110
if (diffDays === 1) return 'yesterday';2111
if (diffDays >= 2 && diffDays <= 6) return `${dayCountWord(diffDays)} days ago`;2112
if (diffDays === 7) return 'one week ago';2113
2092
return new Date(dayStartMs).toLocaleDateString('en-GB', {2114
return new Date(dayStartMs).toLocaleDateString('en-GB', {2093
day: '2-digit',2115
day: '2-digit',2094
month: 'short',2116
month: 'short',@@ -3354,6 +3376,7 @@ function globalFaviconFallbackMarkup ()3354
3376
3355
function applyGlobalFaviconPreview (hasFavicon)3377
function applyGlobalFaviconPreview (hasFavicon)3356
{3378
{3379
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;3357
const preview = document.getElementById('global-favicon-preview');3380
const preview = document.getElementById('global-favicon-preview');3358
if (!preview) return;3381
if (!preview) return;3359
3382
@@ -3376,6 +3399,7 @@ function applyGlobalFaviconPreview (hasFavicon)3376
3399
3377
function applyGlobalFaviconLink (hasFavicon)3400
function applyGlobalFaviconLink (hasFavicon)3378
{3401
{3402
if (typeof document === 'undefined' || typeof document.getElementById !== 'function' || !document.head) return;3379
let link = document.getElementById('global-favicon-link');3403
let link = document.getElementById('global-favicon-link');3380
if (!link)3404
if (!link)3381
{3405
{@@ -799,6 +799,51 @@ describe('page load smoke test', () =>
799
799
dom.window.close();
800
800
});
801
801
802
test('date grouping uses relative written labels for recent days', async () =>
803
{
804
const now = new Date();
805
const dayMs = 24 * 60 * 60 * 1000;
806
function isoDaysAgo (days)
807
{
808
return new Date(now.getTime() - (days * dayMs)).toISOString();
809
}
810
811
listFixture = {
812
'/data': [
813
{ name: 'today.txt', path: '/data/today.txt', isDir: false, size: 1, mtime: isoDaysAgo(0), uploadedAt: isoDaysAgo(0) },
814
{ name: 'yesterday.txt', path: '/data/yesterday.txt', isDir: false, size: 1, mtime: isoDaysAgo(1), uploadedAt: isoDaysAgo(1) },
815
{ name: 'three.txt', path: '/data/three.txt', isDir: false, size: 1, mtime: isoDaysAgo(3), uploadedAt: isoDaysAgo(3) },
816
{ name: 'week.txt', path: '/data/week.txt', isDir: false, size: 1, mtime: isoDaysAgo(7), uploadedAt: isoDaysAgo(7) },
817
{ name: 'old.txt', path: '/data/old.txt', isDir: false, size: 1, mtime: isoDaysAgo(8), uploadedAt: isoDaysAgo(8) },
818
],
819
};
820
821
const { dom, runtimeErrors } = await bootClient();
822
expect(runtimeErrors).toEqual([]);
823
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
824
825
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
826
groupSelect.value = 'lastChangedDate';
827
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
828
829
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 5);
830
831
const labels = Array.from(dom.window.document.querySelectorAll('.file-group-separator span')).map((el) => String(el.textContent || '').trim());
832
expect(labels).toContain('today');
833
expect(labels).toContain('yesterday');
834
expect(labels).toContain('three days ago');
835
expect(labels).toContain('one week ago');
836
837
const oldDateLabel = new Date(isoDaysAgo(8)).toLocaleDateString('en-GB', {
838
day: '2-digit',
839
month: 'short',
840
year: 'numeric',
841
});
842
expect(labels).toContain(oldDateLabel);
843
844
dom.window.close();
845
});
846
802
847
test('shows pending icon spinner when image thumbnail cache is not ready', async () =>
803
848
{
804
849
listFixture = {
@@ -799,6 +799,51 @@ describe('page load smoke test', () =>799
dom.window.close();
799
dom.window.close();
800
});
800
});
801
801
802
test('date grouping uses relative written labels for recent days', async () =>
803
{
804
const now = new Date();
805
const dayMs = 24 * 60 * 60 * 1000;
806
function isoDaysAgo (days)
807
{
808
return new Date(now.getTime() - (days * dayMs)).toISOString();
809
}
810
811
listFixture = {
812
'/data': [
813
{ name: 'today.txt', path: '/data/today.txt', isDir: false, size: 1, mtime: isoDaysAgo(0), uploadedAt: isoDaysAgo(0) },
814
{ name: 'yesterday.txt', path: '/data/yesterday.txt', isDir: false, size: 1, mtime: isoDaysAgo(1), uploadedAt: isoDaysAgo(1) },
815
{ name: 'three.txt', path: '/data/three.txt', isDir: false, size: 1, mtime: isoDaysAgo(3), uploadedAt: isoDaysAgo(3) },
816
{ name: 'week.txt', path: '/data/week.txt', isDir: false, size: 1, mtime: isoDaysAgo(7), uploadedAt: isoDaysAgo(7) },
817
{ name: 'old.txt', path: '/data/old.txt', isDir: false, size: 1, mtime: isoDaysAgo(8), uploadedAt: isoDaysAgo(8) },
818
],
819
};
820
821
const { dom, runtimeErrors } = await bootClient();
822
expect(runtimeErrors).toEqual([]);
823
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
824
825
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
826
groupSelect.value = 'lastChangedDate';
827
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
828
829
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 5);
830
831
const labels = Array.from(dom.window.document.querySelectorAll('.file-group-separator span')).map((el) => String(el.textContent || '').trim());
832
expect(labels).toContain('today');
833
expect(labels).toContain('yesterday');
834
expect(labels).toContain('three days ago');
835
expect(labels).toContain('one week ago');
836
837
const oldDateLabel = new Date(isoDaysAgo(8)).toLocaleDateString('en-GB', {
838
day: '2-digit',
839
month: 'short',
840
year: 'numeric',
841
});
842
expect(labels).toContain(oldDateLabel);
843
844
dom.window.close();
845
});
846
802
test('shows pending icon spinner when image thumbnail cache is not ready', async () =>
847
test('shows pending icon spinner when image thumbnail cache is not ready', async () =>
803
{
848
{
804
listFixture = {
849
listFixture = {