Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomstore templates and thesauri #6788

Merged
merged 1 commit into from
May 21, 2024
Merged
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
81 changes: 9 additions & 72 deletions app/react/App/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -1867,10 +1867,6 @@ input[type="range"]::-ms-fill-lower {
height: 3.5rem;
}

.h-2 {
height: 0.5rem;
}

.h-3 {
height: 0.75rem;
}
Expand Down Expand Up @@ -1924,10 +1920,6 @@ input[type="range"]::-ms-fill-lower {
height: 100%;
}

.h-\[36px\] {
height: 36px;
}

.max-h-16 {
max-height: 4rem;
}
Expand Down Expand Up @@ -2143,14 +2135,6 @@ input[type="range"]::-ms-fill-lower {
width: max-content;
}

.w-\[36px\] {
width: 36px;
}

.w-\[35px\] {
width: 35px;
}

.min-w-20 {
min-width: 5rem;
}
Expand Down Expand Up @@ -2211,6 +2195,10 @@ input[type="range"]::-ms-fill-lower {
max-width: 120px;
}

.max-w-\[188px\] {
max-width: 188px;
}

.max-w-lg {
max-width: 32rem;
}
Expand All @@ -2231,38 +2219,6 @@ input[type="range"]::-ms-fill-lower {
max-width: 20rem;
}

.max-w-\[400px\] {
max-width: 400px;
}

.max-w-\[200px\] {
max-width: 200px;
}

.max-w-\[220px\] {
max-width: 220px;
}

.max-w-\[180px\] {
max-width: 180px;
}

.max-w-\[175px\] {
max-width: 175px;
}

.max-w-\[172px\] {
max-width: 172px;
}

.max-w-\[182px\] {
max-width: 182px;
}

.max-w-\[188px\] {
max-width: 188px;
}

.flex-1 {
flex: 1 1 0%;
}
Expand Down Expand Up @@ -2736,6 +2692,11 @@ input[type="range"]::-ms-fill-lower {
border-color: rgb(157 23 77 / var(--tw-border-opacity));
}

.border-gray-100 {
--tw-border-opacity: 1;
border-color: rgb(243 244 246 / var(--tw-border-opacity));
}

.border-gray-200 {
--tw-border-opacity: 1;
border-color: rgb(229 231 235 / var(--tw-border-opacity));
Expand Down Expand Up @@ -2800,11 +2761,6 @@ input[type="range"]::-ms-fill-lower {
border-color: rgb(253 224 71 / var(--tw-border-opacity));
}

.border-gray-100 {
--tw-border-opacity: 1;
border-color: rgb(243 244 246 / var(--tw-border-opacity));
}

.border-t-gray-200 {
--tw-border-opacity: 1;
border-top-color: rgb(229 231 235 / var(--tw-border-opacity));
Expand Down Expand Up @@ -2983,10 +2939,6 @@ input[type="range"]::-ms-fill-lower {
background-color: rgb(253 246 178 / var(--tw-bg-opacity));
}

.bg-\[color\] {
background-color: color;
}

.bg-opacity-50 {
--tw-bg-opacity: 0.5;
}
Expand Down Expand Up @@ -3892,21 +3844,6 @@ input[type="range"]::-ms-fill-lower {
--tw-ring-color: rgb(187 247 208 / var(--tw-ring-opacity));
}

.focus-visible\:border-error-900:focus-visible {
--tw-border-opacity: 1;
border-color: rgb(131 24 67 / var(--tw-border-opacity));
}

.focus-visible\:border-error-300:focus-visible {
--tw-border-opacity: 1;
border-color: rgb(249 168 212 / var(--tw-border-opacity));
}

.focus-visible\:border-gray-300:focus-visible {
--tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity));
}

.focus-visible\:outline-none:focus-visible {
outline: 2px solid transparent;
outline-offset: 2px;
Expand Down
13 changes: 6 additions & 7 deletions app/react/V2/Routes/Settings/IX/components/PDFSidepanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import * as filesAPI from 'V2/api/files';
import * as entitiesAPI from 'V2/api/entities';
import { secondsToISODate } from 'V2/shared/dateHelpers';
import { Button, Sidepanel } from 'V2/Components/UI';
import { InputField } from 'V2/Components/Forms';
import { InputField, MultiselectList } from 'V2/Components/Forms';
import { PDF, selectionHandlers } from 'V2/Components/PDFViewer';
import { notificationAtom, thesaurisAtom } from 'V2/atoms';
import { MultiselectList } from 'V2/Components/Forms';
import { notificationAtom, thesauriAtom } from 'V2/atoms';
import { Highlights } from '../types';

interface PDFSidepanelProps {
Expand Down Expand Up @@ -147,7 +146,7 @@ const PDFSidepanel = ({
const [entity, setEntity] = useState<ClientEntitySchema>();
const [thesaurus, setThesaurus] = useState<any>();
const setNotifications = useSetAtom(notificationAtom);
const thesauris = useAtomValue(thesaurisAtom);
const thesauris = useAtomValue(thesauriAtom);

const templateId = suggestion?.entityTemplateId;
const propertyValue = getFormValue(suggestion, entity, property?.type);
Expand Down Expand Up @@ -404,7 +403,7 @@ const PDFSidepanel = ({
<Sidepanel.Body>
<form
id="ixpdfform"
className="flex flex-col h-full gap-4 pb-0"
className="flex flex-col gap-4 pb-0 h-full"
onSubmit={handleSubmit(onSubmit)}
>
<div ref={pdfContainerRef} className="md:m-auto md:w-[95%] grow">
Expand All @@ -430,7 +429,7 @@ const PDFSidepanel = ({
</div>
</form>{' '}
</Sidepanel.Body>
<Sidepanel.Footer className="py-0 border border-b-0 border-l-0 border-r-0 border-gray-200 border-t-1">
<Sidepanel.Footer className="py-0 border border-r-0 border-b-0 border-l-0 border-gray-200 border-t-1">
<div className="flex px-4 py-2">
<p className={selectionError ? 'text-pink-600 grow' : 'grow'}>
<Translate className="uppercase" context={templateId}>
Expand All @@ -443,7 +442,7 @@ const PDFSidepanel = ({
</span>
</div>
{labelInputIsOpen && renderLabel()}
<div className="flex justify-end gap-2 px-4 py-2 border border-b-0 border-l-0 border-r-0 border-gray-200 border-t-1">
<div className="flex gap-2 justify-end px-4 py-2 border border-r-0 border-b-0 border-l-0 border-gray-200 border-t-1">
<Button
type="button"
styling="outline"
Expand Down
4 changes: 2 additions & 2 deletions app/react/V2/Routes/Settings/IX/components/SuggestedValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { secondsToDate } from 'app/V2/shared/dateHelpers';
import { EntitySuggestionType } from 'shared/types/suggestionType';
import { ClientTemplateSchema } from 'app/istore';
import { Translate } from 'app/I18N';
import { thesaurisAtom } from 'app/V2/atoms';
import { thesauriAtom } from 'V2/atoms';

const SuggestedValue = ({
value,
Expand All @@ -28,7 +28,7 @@ const SuggestedValue = ({
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
});
const [popoverOpen, setPopoverOpen] = useState(false);
const thesauris = useAtomValue(thesaurisAtom);
const thesauris = useAtomValue(thesauriAtom);

let colorClass = '';
if (!suggestion || suggestion.suggestedValue === '') {
Expand Down
2 changes: 1 addition & 1 deletion app/react/V2/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { notificationAtom } from './notificationAtom';
export { settingsAtom } from './settingsAtom';
export { templatesAtom } from './templatesAtom';
export { translationsAtom } from './translationsAtom';
export { thesaurisAtom } from './thesaurisAtom';
export { thesauriAtom } from './thesauriAtom';
export { globalMatomoAtom } from './globalMatomoAtom';
export { userAtom } from './userAtom';
export type { AtomStoreData } from './store';
Expand Down
10 changes: 8 additions & 2 deletions app/react/V2/atoms/store.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { createStore } from 'jotai';
import { isClient } from 'app/utils';
import { store } from 'app/store';
import { ClientSettings, ClientUserSchema } from 'app/apiResponseTypes';
import { ClientSettings, ClientThesaurus, ClientUserSchema } from 'app/apiResponseTypes';
import { ClientTemplateSchema } from 'app/istore';
import { globalMatomoAtom } from './globalMatomoAtom';
import { relationshipTypesAtom } from './relationshipTypes';
import { settingsAtom } from './settingsAtom';
import { templatesAtom } from './templatesAtom';
import { translationsAtom } from './translationsAtom';
import { userAtom } from './userAtom';
import { thesauriAtom } from './thesauriAtom';

type AtomStoreData = {
globalMatomo?: { url: string; id: string };
locale?: string;
settings?: ClientSettings;
thesauri?: ClientThesaurus[];
templates?: ClientTemplateSchema[];
user?: ClientUserSchema;
};

Expand All @@ -25,10 +29,12 @@ declare global {
const atomStore = createStore();

if (isClient && window.__atomStoreData__) {
const { globalMatomo, locale, settings, user } = window.__atomStoreData__;
const { globalMatomo, locale, settings, thesauri, templates, user } = window.__atomStoreData__;

if (globalMatomo) atomStore.set(globalMatomoAtom, { ...globalMatomo });
if (settings) atomStore.set(settingsAtom, settings);
if (thesauri) atomStore.set(thesauriAtom, thesauri);
if (templates) atomStore.set(templatesAtom, templates);
atomStore.set(userAtom, user);
atomStore.set(translationsAtom, { locale: locale || 'en' });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from 'jotai';
import { ClientThesaurus } from 'app/apiResponseTypes';

const thesaurisAtom = atom([] as ClientThesaurus[]);
const thesauriAtom = atom([] as ClientThesaurus[]);

export { thesaurisAtom };
export { thesauriAtom };
2 changes: 2 additions & 0 deletions app/react/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ const prepareStores = async (req: ExpressRequest, settings: ClientSettings, lang
atomStoreData: {
locale,
settings: settingsApiResponse.json,
thesauri: thesaurisApiResponse.json.rows,
templates: templatesApiResponse.json.rows,
user: userApiResponse.json,
},
};
Expand Down
Loading