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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ DEFAULT_CURRENCY=USD
# Set the logging level: trace | debug | info | warn | error | fatal | silent
LOG_LEVEL=info
# Maxinum image size that can be uploaded (in bytes)
MAX_IMAGE_SIZE=5000000
MAX_IMAGE_SIZE=5000000
1 change: 1 addition & 0 deletions src/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Config = {
showName: boolean;
showNameAcrossGroups: boolean;
showForOwner: boolean;
showNamePublic: boolean;
requireEmail: boolean;
};
listMode: ListMode;
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
"show-for-list-owner": "Show for list owner",
"show-for-list-owner-description": "Allow list owners to view claims on their own lists.",
"show-name": "Show name",
"show-name-publicly": "Show name publicly",
"show-name-publicly-tooltip": "When enabled, the name provided on a public claim is shown to everyone viewing the public list.",
"smtp": "SMTP",
"smtp-from-email": "From Email",
"smtp-from-name": "From Name",
Expand Down
16 changes: 16 additions & 0 deletions src/lib/components/admin/Settings/General/Claims.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@
{$t("admin.show-name-across-groups-tooltip")}
{/snippet}
</Setting>
<Setting class={[!config.claims.showName && "hidden"]}>
<label class="checkbox-label">
<input
id="claimsShowNamePublic"
name="claimsShowNamePublic"
class="checkbox"
checked={config.claims.showNamePublic}
type="checkbox"
/>
<span>{$t("admin.show-name-publicly")}</span>
</label>

{#snippet description()}
{$t("admin.show-name-publicly-tooltip")}
{/snippet}
</Setting>
<Setting>
<label class="checkbox-label">
<input
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/wishlists/ItemCard/ClaimButtons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| "showClaimedName"
| "showNameAcrossGroups"
| "showClaimForOwner"
| "showPublicClaimName"
| "onPublicList"
| "onClaim"
| "onUnclaim"
Expand All @@ -22,6 +23,7 @@
showClaimedName = false,
showNameAcrossGroups = false,
showClaimForOwner = false,
showPublicClaimName = false,
onPublicList = false,
onClaim,
onUnclaim,
Expand Down Expand Up @@ -81,15 +83,15 @@
</div>
{:else if item.claims.length === 0 || (item.userId === user?.id && item.isClaimable)}
<div></div>
{:else if item.claims.length === 1 && shouldShowName(item, showClaimedName, showNameAcrossGroups, showClaimForOwner, user, item.claims[0])}
{:else if item.claims.length === 1 && shouldShowName(item, showClaimedName, showNameAcrossGroups, showClaimForOwner, showPublicClaimName, user, item.claims[0])}
<span class="text-subtle line-clamp-2 truncate text-wrap">
{$t("wishes.claimed-by", {
values: {
name: getClaimedName(item.claims[0])
}
})}
</span>
{:else if item.claims.length > 1 && shouldShowName(item, showClaimedName, showNameAcrossGroups, showClaimForOwner, user)}
{:else if item.claims.length > 1 && shouldShowName(item, showClaimedName, showNameAcrossGroups, showClaimForOwner, showPublicClaimName, user)}
<span class="text-subtle line-clamp-2 truncate text-wrap">{$t("wishes.claimed-by-multiple-users")}</span>
{:else}
<span class="text-subtle line-clamp-2 truncate text-wrap">{$t("wishes.claimed")}</span>
Expand Down
12 changes: 11 additions & 1 deletion src/lib/components/wishlists/ItemCard/GridItemCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
showClaimedName = false,
showNameAcrossGroups = false,
showClaimForOwner = false,
showPublicClaimName = false,
showFor = false,
onPublicList = false,
reorderActions = false,
Expand Down Expand Up @@ -44,7 +45,15 @@

<!-- Content area with consistent padding -->
<div class="flex flex-1 flex-col space-y-1 p-4">
<ItemAttributes {item} {onPublicList} {showClaimForOwner} {showClaimedName} {showFor} {user} />
<ItemAttributes
{item}
{onPublicList}
{showClaimForOwner}
{showClaimedName}
{showPublicClaimName}
{showFor}
{user}
/>
</div>

<ItemFooter
Expand All @@ -62,6 +71,7 @@
{showClaimForOwner}
{showClaimedName}
{showNameAcrossGroups}
{showPublicClaimName}
{user}
{userCanManage}
/>
Expand Down
5 changes: 5 additions & 0 deletions src/lib/components/wishlists/ItemCard/ItemCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
showClaimedName?: boolean;
showNameAcrossGroups?: boolean;
showClaimForOwner?: boolean;
showPublicClaimName?: boolean;
requireClaimEmail?: boolean;
groupId?: string;
showFor?: boolean;
Expand All @@ -30,6 +31,7 @@
showClaimedName?: boolean;
showNameAcrossGroups?: boolean;
showClaimForOwner?: boolean;
showPublicClaimName?: boolean;
showFor?: boolean;
onPublicList?: boolean;
reorderActions?: boolean;
Expand Down Expand Up @@ -79,6 +81,7 @@
showClaimedName = false,
showNameAcrossGroups = false,
showClaimForOwner = false,
showPublicClaimName = false,
requireClaimEmail = true,
showFor = false,
onPublicList = false,
Expand Down Expand Up @@ -271,6 +274,7 @@
showClaimedName,
showNameAcrossGroups,
showClaimForOwner,
showPublicClaimName,
requireClaimEmail,
onPublicList,
handleClaim,
Expand Down Expand Up @@ -333,6 +337,7 @@
{reorderActions}
{showClaimForOwner}
{showClaimedName}
{showPublicClaimName}
{showFor}
{showNameAcrossGroups}
{user}
Expand Down
12 changes: 11 additions & 1 deletion src/lib/components/wishlists/ItemCard/ListItemCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
showClaimedName = false,
showClaimForOwner = false,
showNameAcrossGroups = false,
showPublicClaimName = false,
showFor = false,
onPublicList = false,
reorderActions = false,
Expand All @@ -40,7 +41,15 @@
</ItemImage>

<div class="flex flex-col">
<ItemAttributes {item} {onPublicList} {showClaimForOwner} {showClaimedName} {showFor} {user} />
<ItemAttributes
{item}
{onPublicList}
{showClaimForOwner}
{showClaimedName}
{showPublicClaimName}
{showFor}
{user}
/>
</div>
</div>

Expand All @@ -60,6 +69,7 @@
{showClaimForOwner}
{showClaimedName}
{showNameAcrossGroups}
{showPublicClaimName}
{user}
{userCanManage}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

interface Props extends Pick<
ItemCardProps,
"item" | "onPublicList" | "user" | "showClaimForOwner" | "showClaimedName" | "showNameAcrossGroups" | "showFor"
| "item"
| "onPublicList"
| "user"
| "showClaimForOwner"
| "showClaimedName"
| "showNameAcrossGroups"
| "showPublicClaimName"
| "showFor"
> {
showDetail?: boolean;
fullNotes?: boolean;
Expand All @@ -21,6 +28,7 @@
showClaimedName,
showNameAcrossGroups = false,
showClaimForOwner = false,
showPublicClaimName = false,
showFor,
showDetail = false,
fullNotes = false
Expand Down Expand Up @@ -76,6 +84,7 @@
showClaimedName,
showNameAcrossGroups,
showClaimForOwner,
showPublicClaimName,
user,
claim
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
showClaimedName = false,
showClaimForOwner = false,
showNameAcrossGroups = false,
showPublicClaimName = false,
onPublicList = false,
reorderActions = false,
onIncreasePriority,
Expand Down Expand Up @@ -43,6 +44,7 @@
{showClaimForOwner}
{showClaimedName}
{showNameAcrossGroups}
{showPublicClaimName}
{user}
/>

Expand Down
3 changes: 3 additions & 0 deletions src/lib/components/wishlists/ItemDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
const showClaimedName: boolean = $drawerStore.meta.showClaimedName;
const showNameAcrossGroups: boolean = $drawerStore.meta.showNameAcrossGroups;
const showClaimForOwner: boolean = $drawerStore.meta.showClaimForOwner;
const showPublicClaimName: boolean = $drawerStore.meta.showPublicClaimName;
const onPublicList: boolean = $drawerStore.meta.onPublicList;
const handleClaim: (v?: boolean) => void = $drawerStore.meta.handleClaim;
const handleDelete: VoidFunction = $drawerStore.meta.handleDelete;
Expand Down Expand Up @@ -72,6 +73,7 @@
{onPublicList}
{showClaimForOwner}
{showClaimedName}
{showPublicClaimName}
showDetail
{showFor}
{showNameAcrossGroups}
Expand All @@ -87,6 +89,7 @@
onUnclaim={() => handleClaim(true)}
{showClaimForOwner}
{showClaimedName}
{showPublicClaimName}
{showNameAcrossGroups}
{user}
/>
Expand Down
11 changes: 11 additions & 0 deletions src/lib/components/wishlists/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,24 @@ export const shouldShowName = (
showNameConfig: boolean,
showNameAcrossGroups: boolean,
showForOwner: boolean,
showPublicClaimName: boolean,
user: PartialUser | undefined,
claim?: ClaimDTO
) => {
// Completely disabled
if (!showNameConfig) {
return false;
}
// Public claims: allow global visibility when enabled; otherwise fall back to
// authenticated visibility rules so owners/managers can still see names.
if (claim?.publicClaimedBy) {
if (showPublicClaimName) return true;
if (!user) return false;
if (item.user.id === user.id && showForOwner) return true;
if (showNameAcrossGroups) return true;
return true;
}

// No logged in user
if (!user) {
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum ConfigKey {
CLAIMS_SHOW_NAME = "claims.showName",
ClAIMS_SHOW_NAME_ACROSS_GROUPS = "claims.showNameAcrossGroups",
CLAIMS_SHOW_FOR_OWNER = "claims.showForOwner",
CLAIMS_SHOW_NAME_PUBLIC = "claims.showNamePublic",
CLAIMS_REQUIRE_EMAIL = "claims.requireEmail",
LIST_MODE = "listMode",
SECURITY_PASSWORD_STRENGTH = "security.passwordStrength",
Expand Down Expand Up @@ -58,6 +59,7 @@ const transformers: Record<ConfigKey, Transformer<unknown>> = {
"claims.showName": booleanTransformer,
"claims.showNameAcrossGroups": booleanTransformer,
"claims.showForOwner": booleanTransformer,
"claims.showNamePublic": booleanTransformer,
"claims.requireEmail": booleanTransformer,
listMode: stringTransformer,
"security.passwordStrength": numberTransformer,
Expand Down Expand Up @@ -89,6 +91,7 @@ const getDefaultConfig = (): Config => ({
showName: true,
showNameAcrossGroups: false,
showForOwner: false,
showNamePublic: false,
requireEmail: true
},
listMode: "standard",
Expand Down
1 change: 1 addition & 0 deletions src/lib/server/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const settingSchema = z.object({
claimsShowName: z.coerce.boolean().default(false),
claimsShowNameAcrossGroups: z.coerce.boolean().default(false),
claimsShowForOwner: z.coerce.boolean().default(false),
claimsShowNamePublic: z.coerce.boolean().default(false),
claimsRequireEmail: z.coerce.boolean().default(false),
listMode: z.enum(["standard", "registry"]).default("standard"),
passwordStrength: z.coerce.number().min(-1).max(5).default(2),
Expand Down
2 changes: 2 additions & 0 deletions src/routes/admin/groups/[groupId]/settings/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const actions: Actions = {
claimsShowName: true,
claimsShowNameAcrossGroups: true,
claimsShowForOwner: true,
claimsShowNamePublic: true,
claimsRequireEmail: true,
listMode: true,
enableDefaultListCreation: true,
Expand All @@ -75,6 +76,7 @@ export const actions: Actions = {
showName: configData.data.claimsShowName,
showNameAcrossGroups: configData.data.claimsShowNameAcrossGroups,
showForOwner: configData.data.claimsShowForOwner,
showNamePublic: configData.data.claimsShowNamePublic,
requireEmail: configData.data.claimsRequireEmail
},
listMode: configData.data.listMode,
Expand Down
1 change: 1 addition & 0 deletions src/routes/admin/settings/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const generateConfig = (configData: z.infer<typeof settingSchema>) => {
showName: configData.claimsShowName,
showNameAcrossGroups: configData.claimsShowNameAcrossGroups,
showForOwner: configData.claimsShowForOwner,
showNamePublic: configData.claimsShowNamePublic,
requireEmail: configData.claimsRequireEmail
},
listMode: "standard",
Expand Down
1 change: 1 addition & 0 deletions src/routes/lists/[id]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const load = (async ({ params, url, locals, depends, cookies }) => {
showClaimedName: config.claims.showName,
showNameAcrossGroups: config.claims.showNameAcrossGroups,
showClaimForOwner: config.claims.showForOwner,
showPublicClaimName: config.claims.showNamePublic,
requireClaimEmail: config.claims.requireEmail,
suggestionsEnabled: config.suggestions.enable,
initialViewPreference: viewPreference || "list"
Expand Down
3 changes: 3 additions & 0 deletions src/routes/lists/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
requireClaimEmail={data.requireClaimEmail}
showClaimForOwner={data.showClaimForOwner}
showClaimedName={data.showClaimedName}
showPublicClaimName={data.showPublicClaimName}
showNameAcrossGroups={data.showNameAcrossGroups}
user={data.loggedInUser}
userCanManage={data.list.isManager}
Expand Down Expand Up @@ -385,6 +386,7 @@
requireClaimEmail={data.requireClaimEmail}
showClaimForOwner={data.showClaimForOwner}
showClaimedName={data.showClaimedName}
showPublicClaimName={data.showPublicClaimName}
showNameAcrossGroups={data.showNameAcrossGroups}
user={data.loggedInUser}
userCanManage={data.list.isManager}
Expand All @@ -407,6 +409,7 @@
requireClaimEmail={data.requireClaimEmail}
showClaimForOwner={data.showClaimForOwner}
showClaimedName={data.showClaimedName}
showPublicClaimName={data.showPublicClaimName}
showNameAcrossGroups={data.showNameAcrossGroups}
user={data.loggedInUser}
userCanManage={data.list.isManager}
Expand Down