Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/pat/filemanager/src/components/ColumnCell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
// raw-content object URL. Folderish titles drill in-app (onTitleClick).
const openUrl = $derived(contents.config.viewUrl(item));

function displayValue(value) {
if (value == null) return "";
if (column.translationDomain === "plone") return _tp(String(value));
if (column.translationDomain === "widgets") return _t(String(value));
return value;
}

// Folderish titles drill into the folder in-app; everything else keeps the
// plain link so the object opens normally.
function onTitleClick(event) {
Expand Down Expand Up @@ -72,7 +79,7 @@
{formatDate(value)}
{:else if column.type === "state"}
{#if value}
<span class="filemanager-state state-{value}">{_tp(value)}</span>
<span class="filemanager-state state-{value}">{displayValue(value)}</span>
{/if}
{:else if column.type === "tags"}
{#each tags as tag (tag)}
Expand All @@ -81,5 +88,5 @@
{:else if column.key === "getObjSize"}
{formatSize(value)}
{:else}
{value ?? ""}
{displayValue(value)}
{/if}
18 changes: 16 additions & 2 deletions src/pat/filemanager/src/stores/ConfigStore.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@ export interface ColumnDef {
field?: string;
/** catalog index to sort on; omit for non-sortable columns */
sortIndex?: string;
/** translation domain for catalog values; omit for user-authored/raw values */
translationDomain?: "widgets" | "plone";
type: ColumnType;
}

export const COLUMN_DEFS: Record<string, ColumnDef> = {
image: { key: "image", label: "Preview", field: "image_scales", type: "image" },
Title: { key: "Title", label: "Title", sortIndex: "sortable_title", type: "title" },
portal_type: { key: "portal_type", label: "Type", sortIndex: "portal_type", type: "text" },
review_state: { key: "review_state", label: "State", sortIndex: "review_state", type: "state" },
portal_type: {
key: "portal_type",
label: "Type",
sortIndex: "portal_type",
translationDomain: "plone",
type: "text",
},
review_state: {
key: "review_state",
label: "State",
sortIndex: "review_state",
translationDomain: "plone",
type: "state",
},
ModificationDate: { key: "ModificationDate", label: "Modified", sortIndex: "modified", type: "date" },
CreationDate: { key: "CreationDate", label: "Created", sortIndex: "created", type: "date" },
EffectiveDate: { key: "EffectiveDate", label: "Published", sortIndex: "effective", type: "date" },
Expand Down
3 changes: 3 additions & 0 deletions src/pat/filemanager/src/stores/ContentsStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,9 @@ describe("ConfigStore", () => {
it("resolves a column definition by key", () => {
const config = new ConfigStore({ contextUrl: "http://nohost/plone" });
expect(config.column("ModificationDate").type).toBe("date");
expect(config.column("portal_type").translationDomain).toBe("plone");
expect(config.column("review_state").translationDomain).toBe("plone");
expect(config.column("Title").translationDomain).toBeUndefined();
expect(config.column("unknown")).toEqual({
key: "unknown",
label: "unknown",
Expand Down
Loading