Update collab permission tests and minor fixes

This commit is contained in:
thiloho
2024-09-06 16:08:34 +02:00
parent a77d2b2d0c
commit b8d23eab00
16 changed files with 804 additions and 610 deletions

View File

@@ -5,33 +5,16 @@ import { join } from "node:path";
export const load: PageServerLoad = async ({ fetch, cookies, url, locals }) => {
const searchQuery = url.searchParams.get("website_search_query");
const sortBy = url.searchParams.get("website_sort");
const filterBy = url.searchParams.get("website_filter");
const params = new URLSearchParams();
const baseFetchUrl = `${API_BASE_PREFIX}/website`;
const baseFetchUrl = `${API_BASE_PREFIX}/website?order=last_modified_at.desc,created_at.desc`;
if (searchQuery) {
params.append("title_search", `wfts(english).${searchQuery}`);
}
switch (sortBy) {
case null:
case "creation-time":
params.append("order", "created_at.desc");
break;
case "last-modified":
params.append("order", "last_modified_at.desc");
break;
case "title-a-to-z":
params.append("order", "title.asc");
break;
case "title-z-to-a":
params.append("order", "title.desc");
break;
}
switch (filterBy) {
case "creations":
params.append("user_id", `eq.${locals.user.id}`);
@@ -41,7 +24,7 @@ export const load: PageServerLoad = async ({ fetch, cookies, url, locals }) => {
break;
}
const constructedFetchUrl = `${baseFetchUrl}?${params.toString()}`;
const constructedFetchUrl = `${baseFetchUrl}&${params.toString()}`;
const totalWebsitesData = await fetch(baseFetchUrl, {
method: "HEAD",

View File

@@ -54,7 +54,7 @@
</h2>
<details>
<summary>Search & Sort & Filter</summary>
<summary>Search & Filter</summary>
<form method="GET">
<label>
Search:
@@ -64,16 +64,6 @@
value={$page.url.searchParams.get("website_search_query")}
/>
</label>
<label>
Sort:
<select name="website_sort">
{#each sortOptions as { value, text }}
<option {value} selected={value === $page.url.searchParams.get("website_sort")}
>{text}</option
>
{/each}
</select>
</label>
<label>
Filter:
<select name="website_filter">

View File

@@ -12,6 +12,11 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
baseFetchUrl +=
",article_weight,docs_category(category_name,category_weight)&order=docs_category(category_weight).desc.nullslast,article_weight.desc.nullslast";
}
if (website.content_type === "Blog") {
baseFetchUrl += "&order=last_modified_at.desc,created_at.desc";
}
console.log(baseFetchUrl);
const parameters = new URLSearchParams();

View File

@@ -5,7 +5,7 @@ export const load: PageServerLoad = async ({ parent, params, fetch, cookies }) =
const { website, home } = await parent();
const collabData = await fetch(
`${API_BASE_PREFIX}/collab?website_id=eq.${params.websiteId}&select=*,user!user_id(*)`,
`${API_BASE_PREFIX}/collab?website_id=eq.${params.websiteId}&select=*,user!user_id(*)&order=last_modified_at.desc,added_at.desc`,
{
method: "GET",
headers: {