Skip to content

Commit

Permalink
[HOTFIX] Thesauri issues (#6698)
Browse files Browse the repository at this point in the history
* stop removing id

* sort imports

* upped version
  • Loading branch information
Zasa-san authored Apr 23, 2024
1 parent 02f2fae commit 7620525
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
38 changes: 19 additions & 19 deletions app/react/V2/Routes/Settings/Thesauri/ThesaurusForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import { Row } from '@tanstack/react-table';
import { Translate } from 'app/I18N';
import { SettingsContent } from 'app/V2/Components/Layouts/SettingsContent';
import { Button, Table } from 'app/V2/Components/UI';
import { columns, TableThesaurusValue } from './components/TableComponents';
import { ConfirmNavigationModal, InputField } from 'app/V2/Components/Forms';
import { Link, LoaderFunction, useBlocker, useLoaderData, useNavigate } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import {
ThesauriValueFormSidepanel,
FormThesauriValue,
} from './components/ThesauriValueFormSidepanel';
import { ThesauriGroupFormSidepanel } from './components/ThesauriGroupFormSidepanel';
import { ClientThesaurusValue, ClientThesaurus } from 'app/apiResponseTypes';
import { sanitizeThesaurusValues } from './helpers';
import { notificationAtom } from 'app/V2/atoms/notificationAtom';
import ThesauriAPI from 'app/V2/api/thesauri';
import { SubmitHandler, useForm } from 'react-hook-form';
import { ImportButton } from './components/ImportButton';
import uniqueID from 'shared/uniqueID';
import { ThesaurusSchema } from 'shared/types/thesaurusType';
import { ImportButton } from './components/ImportButton';
import { sanitizeThesaurusValues } from './helpers';
import { ThesauriGroupFormSidepanel } from './components/ThesauriGroupFormSidepanel';
import {
ThesauriValueFormSidepanel,
FormThesauriValue,
} from './components/ThesauriValueFormSidepanel';
import { columns, TableThesaurusValue } from './components/TableComponents';

const editTheasaurusLoader =
(headers?: IncomingHttpHeaders): LoaderFunction =>
Expand Down Expand Up @@ -123,17 +123,17 @@ const ThesaurusForm = () => {
};

const deleteSelected = () => {
const parentsDeleted = thesaurusValues.filter(currentValue => {
return !selectedThesaurusValue.find(selected => selected.original._id === currentValue._id);
});
const parentsDeleted = thesaurusValues.filter(
currentValue =>
!selectedThesaurusValue.find(selected => selected.original._id === currentValue._id)
);

const childrenDeleted = parentsDeleted.map(singleThesaurus => {
if (singleThesaurus.values) {
const newValues = singleThesaurus.values?.filter(currentGroupItem => {
return !selectedThesaurusValue.find(
selected => selected.original.label === currentGroupItem.label
);
});
const newValues = singleThesaurus.values?.filter(
currentGroupItem =>
!selectedThesaurusValue.find(selected => selected.original._id === currentGroupItem._id)
);
singleThesaurus.values = newValues;
}
return singleThesaurus;
Expand Down Expand Up @@ -245,7 +245,7 @@ const ThesaurusForm = () => {
/>
<SettingsContent.Body>
<form onSubmit={handleSubmit(formSubmit)} id="edit-thesaurus">
<div data-testid="thesauri" className="border rounded-md shadow-sm border-gray-50">
<div data-testid="thesauri" className="rounded-md border border-gray-50 shadow-sm">
<div className="p-4">
<InputField
clearFieldAction={() => {}}
Expand All @@ -271,7 +271,7 @@ const ThesaurusForm = () => {
</SettingsContent.Body>
<SettingsContent.Footer className="bottom-0 bg-indigo-50">
{selectedThesaurusValue.length ? (
<div className="flex items-center gap-2">
<div className="flex gap-2 items-center">
<Button
type="button"
onClick={deleteSelected}
Expand Down Expand Up @@ -310,7 +310,7 @@ const ThesaurusForm = () => {
text: <Translate>Error adding thesauri.</Translate>,
});
}}
></ImportButton>
/>
</div>
<div className="flex gap-2">
<Link to="/settings/thesauri">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ThesauriGroupFormSidepanel = ({

submit({
_id: tValue._id,
...(tValue?.id && { id: tValue.id }),
label: tValue.label,
values: filteredValues,
});
Expand Down Expand Up @@ -108,8 +109,8 @@ const ThesauriGroupFormSidepanel = ({
>
<Sidepanel.Body>
{value && value.label === '' && (
<div className="p-4 mb-4 border rounded-md shadow-sm border-gray-50 bg-primary-100 text-primary-700">
<div className="flex items-center w-full gap-1 text-base font-semibold">
<div className="p-4 mb-4 rounded-md border border-gray-50 shadow-sm bg-primary-100 text-primary-700">
<div className="flex gap-1 items-center w-full text-base font-semibold">
<div className="w-5 h-5 text-sm">
<CheckCircleIcon />
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/react/V2/Routes/Settings/Thesauri/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const sanitizeThesaurusValues = (
values: ClientThesaurusValue[]
): ThesaurusSchema => {
const sanitizedThesaurus = { ...thesaurus, values };
// @ts-ignore
sanitizedThesaurus.values =
values?.map(sValue => {
delete sValue.id;
// @ts-ignore
delete sValue.groupId;
// @ts-ignore
delete sValue._id;
if (sValue.values) {
sValue.values = sValue.values.map((ssValue: any) => {
delete ssValue._id;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.163.0",
"version": "1.163.1",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit 7620525

Please sign in to comment.