Tags in public collection
This commit is contained in:
parent
4640c1c966
commit
a1f48bbd79
|
@ -125,6 +125,32 @@ export default function EditCollectionSharingModal({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{permissions === true && collection.isPublic && (
|
||||||
|
<div>
|
||||||
|
<p>Show tags in public collection</p>
|
||||||
|
|
||||||
|
<label className="label cursor-pointer justify-start gap-2">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={collection.tagsArePublic}
|
||||||
|
onChange={() =>
|
||||||
|
setCollection({
|
||||||
|
...collection,
|
||||||
|
tagsArePublic: !collection.tagsArePublic,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="checkbox checkbox-primary"
|
||||||
|
/>
|
||||||
|
<span className="label-text">Show tags in public collection</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<p className="text-neutral text-sm">
|
||||||
|
This will let <b>Anyone</b> view this collections tags and search
|
||||||
|
this collections links by them.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{collection.isPublic ? (
|
{collection.isPublic ? (
|
||||||
<div className={permissions === true ? "pl-5" : ""}>
|
<div className={permissions === true ? "pl-5" : ""}>
|
||||||
<p className="mb-2">Sharable Link (Click to copy)</p>
|
<p className="mb-2">Sharable Link (Click to copy)</p>
|
||||||
|
|
|
@ -62,6 +62,7 @@ export default async function updateCollection(
|
||||||
description: data.description,
|
description: data.description,
|
||||||
color: data.color,
|
color: data.color,
|
||||||
isPublic: data.isPublic,
|
isPublic: data.isPublic,
|
||||||
|
tagsArePublic: data.tagsArePublic,
|
||||||
parent:
|
parent:
|
||||||
data.parentId && data.parentId !== ("root" as any)
|
data.parentId && data.parentId !== ("root" as any)
|
||||||
? {
|
? {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import getPublicCollectionData from "@/lib/client/getPublicCollectionData";
|
||||||
import {
|
import {
|
||||||
CollectionIncludingMembersAndLinkCount,
|
CollectionIncludingMembersAndLinkCount,
|
||||||
Sort,
|
Sort,
|
||||||
|
TagIncludingLinkCount,
|
||||||
ViewMode,
|
ViewMode,
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
@ -24,6 +25,7 @@ import EditCollectionSharingModal from "@/components/ModalContent/EditCollection
|
||||||
import ViewDropdown from "@/components/ViewDropdown";
|
import ViewDropdown from "@/components/ViewDropdown";
|
||||||
import CardView from "@/components/LinkViews/Layouts/CardView";
|
import CardView from "@/components/LinkViews/Layouts/CardView";
|
||||||
import ListView from "@/components/LinkViews/Layouts/ListView";
|
import ListView from "@/components/LinkViews/Layouts/ListView";
|
||||||
|
import useTagStore from "@/store/tags";
|
||||||
// import GridView from "@/components/LinkViews/Layouts/GridView";
|
// import GridView from "@/components/LinkViews/Layouts/GridView";
|
||||||
|
|
||||||
const cardVariants: Variants = {
|
const cardVariants: Variants = {
|
||||||
|
@ -56,6 +58,24 @@ export default function PublicCollections() {
|
||||||
archiveAsPDF: undefined as unknown as boolean,
|
archiveAsPDF: undefined as unknown as boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { tags } = useTagStore();
|
||||||
|
const handleTagSelection = (tag: TagIncludingLinkCount | undefined) => {
|
||||||
|
if (tag) {
|
||||||
|
Object.keys(searchFilter).forEach((v) => searchFilter[(v as keyof {name: boolean, url: boolean, description: boolean, tags: boolean, textContent: boolean})] = false)
|
||||||
|
searchFilter.tags = true;
|
||||||
|
return router.push(
|
||||||
|
"/public/collections/" +
|
||||||
|
router.query.id +
|
||||||
|
"?q=" +
|
||||||
|
encodeURIComponent(tag.name || "")
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return router.push(
|
||||||
|
"/public/collections/" +
|
||||||
|
router.query.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [searchFilter, setSearchFilter] = useState({
|
const [searchFilter, setSearchFilter] = useState({
|
||||||
name: true,
|
name: true,
|
||||||
url: true,
|
url: true,
|
||||||
|
@ -221,7 +241,49 @@ export default function PublicCollections() {
|
||||||
<ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />
|
<ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{collection.tagsArePublic && tags[0] && (
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">Browse by topic</p>
|
||||||
|
<div className="flex gap-2 mt-2 mb-6">
|
||||||
|
<button onClick={() => handleTagSelection(undefined)}>
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
bg-neutral-content/20 hover:bg-neutral/20 duration-100 py-1 px-2 cursor-pointer flex items-center gap-2 rounded-md h-8"
|
||||||
|
>
|
||||||
|
<i className="text-primary bi-hash text-2xl text-primary drop-shadow"></i>
|
||||||
|
<p className="truncate pr-7">All</p>
|
||||||
|
<div className="text-neutral drop-shadow text-neutral text-xs">
|
||||||
|
{collection._count?.links}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
{tags
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
.map((e, i) => {
|
||||||
|
const active = router.query.q === e.name;
|
||||||
|
return (
|
||||||
|
<button key={i} onClick={() => handleTagSelection(e)}>
|
||||||
|
<div
|
||||||
|
className={`
|
||||||
|
${
|
||||||
|
active
|
||||||
|
? "bg-primary/20"
|
||||||
|
: "bg-neutral-content/20 hover:bg-neutral/20"
|
||||||
|
} duration-100 py-1 px-2 cursor-pointer flex items-center gap-2 rounded-md h-8`}
|
||||||
|
>
|
||||||
|
<i className="bi-hash text-2xl text-primary drop-shadow"></i>
|
||||||
|
<p className="truncate pr-7">{e.name}</p>
|
||||||
|
<div className="drop-shadow text-neutral text-xs">
|
||||||
|
{e._count?.links}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{links[0] ? (
|
{links[0] ? (
|
||||||
<LinkComponent
|
<LinkComponent
|
||||||
links={links
|
links={links
|
||||||
|
|
|
@ -87,6 +87,7 @@ model Collection {
|
||||||
parent Collection? @relation("SubCollections", fields: [parentId], references: [id])
|
parent Collection? @relation("SubCollections", fields: [parentId], references: [id])
|
||||||
subCollections Collection[] @relation("SubCollections")
|
subCollections Collection[] @relation("SubCollections")
|
||||||
isPublic Boolean @default(false)
|
isPublic Boolean @default(false)
|
||||||
|
tagsArePublic Boolean @default(false)
|
||||||
owner User @relation(fields: [ownerId], references: [id])
|
owner User @relation(fields: [ownerId], references: [id])
|
||||||
ownerId Int
|
ownerId Int
|
||||||
members UsersAndCollections[]
|
members UsersAndCollections[]
|
||||||
|
|
Ŝarĝante…
Reference in New Issue