diff --git a/js-packages/admin-ui/src/components/LargeLanguageModelCreate.tsx b/js-packages/admin-ui/src/components/LargeLanguageModelCreate.tsx
index cb1d89026..94b3bccd4 100644
--- a/js-packages/admin-ui/src/components/LargeLanguageModelCreate.tsx
+++ b/js-packages/admin-ui/src/components/LargeLanguageModelCreate.tsx
@@ -83,8 +83,8 @@ export function LargeLanguageModel() {
>
-
-
+
+
diff --git a/js-packages/search-frontend/src/App.tsx b/js-packages/search-frontend/src/App.tsx
index db6b9152e..7c11e0115 100644
--- a/js-packages/search-frontend/src/App.tsx
+++ b/js-packages/search-frontend/src/App.tsx
@@ -590,7 +590,14 @@ export function App() {
openk9.updateConfiguration({ results: element })}
+ ref={(element) =>
+ openk9.updateConfiguration({
+ resultList: {
+ element,
+ changeOnOver: false,
+ },
+ })
+ }
css={css`
grid-area: result;
margin-top: ${searchText !== undefined ? "20px" : "unset"};
diff --git a/js-packages/search-frontend/src/components/Result.tsx b/js-packages/search-frontend/src/components/Result.tsx
index 91b463d17..cff4c89f0 100644
--- a/js-packages/search-frontend/src/components/Result.tsx
+++ b/js-packages/search-frontend/src/components/Result.tsx
@@ -7,9 +7,11 @@ import { PdfResult } from "../renderers/openk9/pdf/PdfResult";
import { Renderers } from "./useRenderers";
import { MobileLogoSvg } from "../svgElement/MobileLogoSvg";
import { useTranslation } from "react-i18next";
+import { TemplatesProps } from "../embeddable/entry";
type ResultProps
= {
renderers: Renderers;
+ templateCustom?: TemplatesProps | null;
result: GenericResultItem;
onDetail(result: GenericResultItem | null): void;
isMobile: boolean;
@@ -22,15 +24,35 @@ type ResultProps = {
| undefined
| null;
};
+
function Result(props: ResultProps) {
const result = props.result as any;
- const { onDetail, renderers } = props;
- const isMobile = props.isMobile;
- const setIdPreview = props.setIdPreview;
- const setDetailMobile = props.setDetailMobile;
- const viewButton = props.viewButton;
- const overChangeCard = props.overChangeCard;
- const setViewButtonDetail = props.setViewButtonDetail;
+ const {
+ onDetail,
+ renderers,
+ isMobile,
+ setIdPreview,
+ setDetailMobile,
+ viewButton,
+ overChangeCard,
+ setViewButtonDetail,
+ templateCustom,
+ } = props;
+
+ const classContainer = result?.source?.documentTypes
+ .map((element: string) => "openk9-card-" + element)
+ .join(" ", "");
+
+ const getCustomTemplate = () => {
+ if (!templateCustom || templateCustom.length === 0) return null;
+
+ const matchedTemplate = templateCustom.find((template) =>
+ result.source.documentTypes.includes(template.source),
+ );
+
+ return matchedTemplate?.Template ?? null;
+ };
+
return (
(props: ResultProps
) {
`}
>
{(() => {
+ const CustomTemplate = getCustomTemplate();
+
+ if (CustomTemplate) {
+ return (
+
+
+ {isMobile && (
+
+ )}
+
+ );
+ }
+
const Renderer: React.FC> =
result.source.documentTypes
.map((k: string) => renderers?.resultRenderers[k])
.find(Boolean);
- if (Renderer) {
+
+ if (Renderer && typeof Renderer === "function") {
return (
- {isMobile &&
- CreateButton({
- setIdPreview,
- setDetailMobile,
- result,
- })}
- {viewButton &&
- !isMobile &&
- ButtonDetail({
- result,
- onDetail,
- setIdPreview,
- setViewButtonDetail,
- })}
+ {isMobile && (
+
+ )}
+ {viewButton && !isMobile && (
+
+ )}
);
}
+
if (result.source.documentTypes.includes("pdf")) {
return (
- {isMobile &&
- CreateButton({
- setIdPreview,
- setDetailMobile,
- result,
- })}
- {viewButton &&
- !isMobile &&
- ButtonDetail({
- result,
- onDetail,
- setIdPreview,
- setViewButtonDetail,
- })}
+ {isMobile && (
+
+ )}
);
}
+
if (result.source.documentTypes.includes("document")) {
return (
- {isMobile &&
- CreateButton({
- setIdPreview,
- setDetailMobile,
- result,
- })}
- {viewButton &&
- !isMobile &&
- ButtonDetail({
- result,
- onDetail,
- setIdPreview,
- setViewButtonDetail,
- })}
+ {isMobile && (
+
+ )}
+ {viewButton && !isMobile && (
+
+ )}
);
}
+
if (result.source.documentTypes.includes("web")) {
return (
- {isMobile &&
- CreateButton({
- setIdPreview,
- setDetailMobile,
- result,
- })}
- {viewButton &&
- !isMobile &&
- ButtonDetail({
- result,
- onDetail,
- setIdPreview,
- setViewButtonDetail,
- })}
+ {isMobile && (
+
+ )}
+ {viewButton && !isMobile && (
+
+ )}
);
}
+
return (
(props: ResultProps) {
);
}
+
function CreateButton({
setDetailMobile,
result,
@@ -201,7 +242,7 @@ function CreateButton({
setDetailMobile(result);
}}
>
- {t("preview")}
+ {t("preview")}
@@ -263,7 +304,7 @@ function ButtonDetail
({
if (recoveryButton) recoveryButton.focus();
}}
>
- {t("preview")}
+ {t("preview")}
diff --git a/js-packages/search-frontend/src/components/ResultList.tsx b/js-packages/search-frontend/src/components/ResultList.tsx
index 48f03e3e0..0d2b51966 100644
--- a/js-packages/search-frontend/src/components/ResultList.tsx
+++ b/js-packages/search-frontend/src/components/ResultList.tsx
@@ -13,6 +13,7 @@ import { ResultSvg } from "../svgElement/ResultSvg";
import { useTranslation } from "react-i18next";
import { result } from "lodash";
import { Options, setSortResultsType } from "./SortResults";
+import { TemplatesProps } from "../embeddable/entry";
const OverlayScrollbarsComponentDockerFix = OverlayScrollbarsComponent as any; // for some reason this component breaks build inside docker
export type ResultsDisplayMode =
@@ -40,7 +41,9 @@ type ResultsProps
= {
selectOptions: Options;
classNameLabel?: string | undefined;
viewButton: boolean;
- NoResultsCustom?: React.ReactNode;
+ templateCustom: TemplatesProps | null;
+ NoResultsCustom?: any | undefined | null;
+ BoxTitle?: any | undefined | null;
setViewButtonDetail: React.Dispatch>;
selectedSort: any;
setSelectedSort: setSortResultsType;
@@ -74,6 +77,8 @@ function Results({
selectedSort,
setSelectedSort,
setViewButtonDetail,
+ BoxTitle,
+ templateCustom,
}: ResultsProps) {
const renderers = useRenderers();
@@ -130,6 +135,7 @@ function Results({
setViewButtonDetail={setViewButtonDetail}
noResultsCustom={NoResultsCustom}
setSelectedSort={setSelectedSort}
+ templateCustom={templateCustom}
/>
);
case "virtual":
@@ -376,6 +382,7 @@ export function FiniteResults({
>
{results.data?.pages[0].total}
+
{results.data?.pages[0].result.map((result, index) => {
return (
@@ -415,6 +422,7 @@ type InfiniteResultsProps = ResulListProps & {
viewButton: boolean;
noResultsCustom: React.ReactNode;
setSelectedSort: setSortResultsType;
+ templateCustom?: TemplatesProps | null;
};
export function InfiniteResults({
renderers,
@@ -438,6 +446,7 @@ export function InfiniteResults({
memoryResults,
noResultsCustom,
viewButton,
+ templateCustom,
setViewButtonDetail,
}: InfiniteResultsProps) {
const results = useInfiniteResults(
@@ -544,6 +553,7 @@ export function InfiniteResults({
setIdPreview={setIdPreview}
viewButton={viewButton}
setViewButtonDetail={setViewButtonDetail}
+ templateCustom={templateCustom}
/>
);
diff --git a/js-packages/search-frontend/src/embeddable/Main.tsx b/js-packages/search-frontend/src/embeddable/Main.tsx
index 056b3f4d2..29e717ce8 100644
--- a/js-packages/search-frontend/src/embeddable/Main.tsx
+++ b/js-packages/search-frontend/src/embeddable/Main.tsx
@@ -246,29 +246,26 @@ export function Main({
)}
{renderPortal(
- {isSearchLoading ? null : (
-
- )}
+
,
configuration.searchConfigurable
? configuration.searchConfigurable.element
@@ -515,6 +512,7 @@ export function Main({
classNameLabel={classNameLabelSort}
memoryResults={memoryResults}
viewButton={viewButton}
+ templateCustom={configuration.template}
setViewButtonDetail={setViewButtonDetail}
selectedSort={selectedSort}
setSelectedSort={setSelectedSort}
@@ -584,6 +582,7 @@ export function Main({
viewButton={viewButton}
setViewButtonDetail={setViewButtonDetail}
NoResultsCustom={configuration.resultList?.noResultsCustom}
+ templateCustom={configuration.template}
/>
)}
,
diff --git a/js-packages/search-frontend/src/embeddable/entry.tsx b/js-packages/search-frontend/src/embeddable/entry.tsx
index 1655c7d14..b0d65f74d 100644
--- a/js-packages/search-frontend/src/embeddable/entry.tsx
+++ b/js-packages/search-frontend/src/embeddable/entry.tsx
@@ -319,6 +319,8 @@ type searchWithSuggestionsProps =
| null
| undefined;
+export type TemplatesProps = Array<{ source: string; Template: React.FC }>;
+
export type Configuration = {
// simple types
debounceTimeSearch: number | null | undefined;
@@ -385,6 +387,7 @@ export type Configuration = {
sortResultConfigurable: SortResultConfigurableProps | null;
sortResultListCustom: SortResultListCustomProps | null;
tabsConfigurable: TabsProps | null;
+ template: TemplatesProps | null;
totalResultConfigurable: totalResultProps | null;
// functions
changeSortResult: (
@@ -445,6 +448,7 @@ const defaultConfiguration: Configuration = {
skeletonTabsCustom: null,
tabs: null,
tabsConfigurable: null,
+ template: null,
tenant: null,
token: null,
totalResult: null,