updated presentable fields sorting

This commit is contained in:
Gani Georgiev
2023-08-22 12:29:54 +03:00
parent 49f1c869c0
commit ed4f7c7358
34 changed files with 64 additions and 56 deletions
+13 -4
View File
@@ -6,6 +6,7 @@
import tooltip from "@/actions/tooltip";
import { confirm } from "@/stores/confirmation";
import { addSuccessToast } from "@/stores/toasts";
import { collections } from "@/stores/collections";
import SortHeader from "@/components/base/SortHeader.svelte";
import Toggler from "@/components/base/Toggler.svelte";
import Field from "@/components/base/Field.svelte";
@@ -121,12 +122,20 @@
let listSort = sort;
const sortMatch = listSort.match(sortRegex);
const relField = sortMatch ? relFields.find((f) => f.name === sortMatch[2]) : null;
if (sortMatch && relField?.options?.displayFields?.length > 0) {
if (sortMatch && relField) {
const relPresentableFields =
$collections
?.find((c) => c.id == relField.options?.collectionId)
?.schema?.filter((f) => f.presentable)
?.map((f) => f.name) || [];
const parts = [];
for (const displayField of relField.options.displayFields) {
parts.push((sortMatch[1] || "") + sortMatch[2] + "." + displayField);
for (const presentableField of relPresentableFields) {
parts.push((sortMatch[1] || "") + sortMatch[2] + "." + presentableField);
}
if (parts.length > 0) {
listSort = parts.join(",");
}
listSort = parts.join(",");
}
const fallbackSearchFields = CommonHelper.getAllCollectionIdentifiers(collection);