From dae3edea24ab5d0201c273c0414030ba78541ffb Mon Sep 17 00:00:00 2001 From: JoshuaD Date: Fri, 11 Oct 2024 04:14:01 +0200 Subject: [PATCH 1/8] multiselectlist blank state property --- .../V2/Components/Forms/MultiselectList.tsx | 11 +++++ .../Forms/specs/MultiselectList.cy.tsx | 43 +++++++++++++++++++ .../stories/Forms/MultiselectList.stories.tsx | 13 +++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/app/react/V2/Components/Forms/MultiselectList.tsx b/app/react/V2/Components/Forms/MultiselectList.tsx index 2fa881d010..d444924cc7 100644 --- a/app/react/V2/Components/Forms/MultiselectList.tsx +++ b/app/react/V2/Components/Forms/MultiselectList.tsx @@ -5,6 +5,7 @@ import React, { useEffect, useState, useRef } from 'react'; import { Translate } from 'app/I18N'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'; +import { isString } from 'lodash'; import { InputField, RadioSelect } from '.'; import { Pill } from '../UI/Pill'; import { Label } from './Label'; @@ -31,8 +32,12 @@ interface MultiselectListProps { startOnSelected?: boolean; search?: string; suggestions?: boolean; + blankState?: string | React.ReactNode; } +const renderChild = (child: string | React.ReactNode) => + isString(child) ? {child} : child; + const MultiselectList = ({ items, onChange, @@ -47,6 +52,7 @@ const MultiselectList = ({ startOnSelected = false, search = '', suggestions = false, + blankState = No items available, }: MultiselectListProps) => { const [selectedItems, setSelectedItems] = useState(value || []); const [showAll, setShowAll] = useState(!(startOnSelected && selectedItems.length)); @@ -345,6 +351,11 @@ const MultiselectList = ({ + {items.length === 0 && ( +
+ {renderChild(blankState)} +
+ )}
    {filteredItems.map(renderItem)}
diff --git a/app/react/V2/Components/Forms/specs/MultiselectList.cy.tsx b/app/react/V2/Components/Forms/specs/MultiselectList.cy.tsx index 30473fa02f..05071b64d7 100644 --- a/app/react/V2/Components/Forms/specs/MultiselectList.cy.tsx +++ b/app/react/V2/Components/Forms/specs/MultiselectList.cy.tsx @@ -223,4 +223,47 @@ describe('MultiselectList.cy.tsx', () => { cy.contains('Pepperoni').should('be.visible'); }); }); + + // add blank state test + describe('blank state property', () => { + it('should show blank state property if there is no items passed to the component', () => { + cy.viewport(450, 650); + mount( + +
+ {}} items={[]} /> +
+
+ ); + cy.contains('No items available').should('be.visible'); + }); + + it('should accept a blank state string', () => { + cy.viewport(450, 650); + mount( + +
+ {}} items={[]} blankState="nada" /> +
+
+ ); + cy.contains('nada').should('be.visible'); + }); + + it('should accept a blank state component', () => { + cy.viewport(450, 650); + mount( + +
+ {}} + items={[]} + blankState={
no items string
} + /> +
+
+ ); + cy.contains('no items string').should('be.visible'); + }); + }); }); diff --git a/app/react/stories/Forms/MultiselectList.stories.tsx b/app/react/stories/Forms/MultiselectList.stories.tsx index 7d2b4ab684..6d3554a620 100644 --- a/app/react/stories/Forms/MultiselectList.stories.tsx +++ b/app/react/stories/Forms/MultiselectList.stories.tsx @@ -18,7 +18,7 @@ const StoryComponent = ({ args }: any) => { <>
-
+
{}, + items: [], + }, +}; + +export { Basic, WithError, WithGroups, InitialState, BlankState }; export default meta; From 08eac77c9bbfa4a34bb5d1f8daf6473a4cac0adf Mon Sep 17 00:00:00 2001 From: JoshuaD Date: Fri, 11 Oct 2024 05:05:48 +0200 Subject: [PATCH 2/8] create/update modal for paragraph extractor --- app/react/App/styles/globals.css | 12 ++ .../ParagraphExtraction.tsx | 45 +++-- .../components/ExtractorModal.tsx | 165 ++++++++++++++++++ .../ParagraphExtraction/components/List.tsx | 1 - .../components/NoQualifiedTemplate.tsx | 15 ++ .../components/TableElements.tsx | 3 +- .../Settings/ParagraphExtraction/types.ts | 9 +- .../V2/api/paragraphExtractor/extractors.ts | 44 +++-- contents/ui-translations/ar.csv | 5 + contents/ui-translations/en.csv | 5 + contents/ui-translations/es.csv | 5 + contents/ui-translations/fr.csv | 5 + contents/ui-translations/ko.csv | 5 + contents/ui-translations/my.csv | 5 + contents/ui-translations/ru.csv | 5 + contents/ui-translations/th.csv | 5 + contents/ui-translations/tr.csv | 5 + 17 files changed, 304 insertions(+), 35 deletions(-) create mode 100644 app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx create mode 100644 app/react/V2/Routes/Settings/ParagraphExtraction/components/NoQualifiedTemplate.tsx diff --git a/app/react/App/styles/globals.css b/app/react/App/styles/globals.css index 503dc0a90c..960970b326 100644 --- a/app/react/App/styles/globals.css +++ b/app/react/App/styles/globals.css @@ -1824,6 +1824,10 @@ input[type="range"]::-ms-fill-lower { margin-top: 1rem; } +.mt-5 { + margin-top: 1.25rem; +} + .mt-6 { margin-top: 1.5rem; } @@ -1981,6 +1985,14 @@ input[type="range"]::-ms-fill-lower { max-height: 100svh; } +.min-h-\[300px\] { + min-height: 300px; +} + +.min-h-\[327px\] { + min-height: 327px; +} + .min-h-fit { min-height: -moz-fit-content; min-height: fit-content; diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx index b7a2b434ed..8deca72bde 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx @@ -13,6 +13,7 @@ import { notificationAtom } from 'V2/atoms'; import { extractorsTableColumns } from './components/TableElements'; import { TableExtractor, Extractor } from './types'; import { List } from './components/List'; +import { ExtractorModal } from './components/ExtractorModal'; const getTemplateName = (templates: ClientTemplateSchema[], targetId: string) => { const foundTemplate = templates.find(template => template._id === targetId); @@ -23,24 +24,31 @@ const formatExtractors = ( extractors: Extractor[], templates: ClientTemplateSchema[] ): TableExtractor[] => - (extractors || []).map(extractor => { + extractors.map(extractor => { const targetTemplateName = getTemplateName(templates, extractor.templateTo); - const originTemplateNames = extractor.templateFrom.map(templateFrom => + const originTemplateNames = (extractor.templatesFrom || []).map(templateFrom => getTemplateName(templates, templateFrom) ); - return { ...extractor, rowId: extractor._id, originTemplateNames, targetTemplateName }; + return { + ...extractor, + rowId: extractor._id || '', + originTemplateNames, + targetTemplateName, + }; }); const ParagraphExtractorDashboard = () => { const { extractors = [], templates } = useLoaderData() as { - extractors: TableExtractor[]; + extractors: Extractor[]; templates: ClientTemplateSchema[]; }; - const [isSaving, setIsSaving] = useState(false); + const revalidator = useRevalidator(); + const [isSaving, setIsSaving] = useState(false); const [selected, setSelected] = useState([]); const [confirmModal, setConfirmModal] = useState(false); + const [extractorModal, setExtractorModal] = useState(false); const setNotifications = useSetAtom(notificationAtom); const deleteExtractors = async () => { @@ -64,7 +72,15 @@ const ParagraphExtractorDashboard = () => { setIsSaving(false); } }; - // const handleSave = async (extractor: IXExtractorInfo) => {}; + + const handleSave = async () => { + revalidator.revalidate(); + setNotifications({ + type: 'success', + text: Paragraph Extractor added, + }); + }; + const paragraphExtractorData = useMemo( () => formatExtractors(extractors, templates), [extractors, templates] @@ -73,14 +89,13 @@ const ParagraphExtractorDashboard = () => { return (
- {/* should create a component for empty data? */} { {selected?.length === 1 ? ( - ) : undefined} @@ -115,7 +130,7 @@ const ParagraphExtractorDashboard = () => { Delete ) : ( - )} @@ -136,6 +151,16 @@ const ParagraphExtractorDashboard = () => { dangerStyle /> )} + + {extractorModal && ( + setExtractorModal(false)} + onAccept={handleSave} + templates={templates} + extractor={selected?.length ? selected[0] : undefined} + /> + )} ); }; diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx new file mode 100644 index 0000000000..77004a1eb5 --- /dev/null +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx @@ -0,0 +1,165 @@ +/* eslint-disable max-lines */ +/* eslint-disable max-statements */ +import React, { useState } from 'react'; +import * as extractorsAPI from 'app/V2/api/paragraphExtractor/extractors'; +import { ArrowRightIcon } from '@heroicons/react/20/solid'; +import { Modal, Button, MultiselectList } from 'V2/Components/UI'; +import { Translate } from 'app/I18N'; +import { ClientTemplateSchema } from 'app/istore'; +import { ParagraphExtractorValues } from '../types'; +import { NoQualifiedTemplatesMessage } from './NoQualifiedTemplate'; + +interface ExtractorModalProps { + setShowModal: React.Dispatch>; + onClose: () => void; + onAccept: () => void; + templates: ClientTemplateSchema[]; + extractor?: ParagraphExtractorValues; +} + +const formatOptions = (templates: ClientTemplateSchema[]) => + templates.map(template => { + const option = { + label: template.name, + id: template._id, + searchLabel: template.name, + value: template._id, + properties: template.properties, + }; + return option; + }); + +const templatesWithParagraph = (template: ClientTemplateSchema) => + template.properties.some(({ name }) => name === 'rich_text'); + +const isActiveStepClassName = (isActive: boolean) => (isActive ? 'bg-indigo-700' : 'bg-gray-200'); + +const ExtractorModal = ({ + setShowModal, + onClose, + onAccept, + templates, + extractor, +}: ExtractorModalProps) => { + const [step, setStep] = useState(1); + console.log(extractor); + const [templatesFrom, setTemplatesFrom] = useState(extractor?.templatesFrom || []); + const [templateTo, setTemplateTo] = useState( + extractor?.templateTo ? [extractor?.templateTo] : [] + ); + + const [templateFromOptions] = useState(formatOptions(templates)); + const [templateToOptions] = useState(formatOptions(templates.filter(templatesWithParagraph))); + + const handleClose = () => { + // setValues([]); + onClose(); + }; + + const handleSubmit = async () => { + try { + const values = { + ...extractor, + templatesFrom, + templateTo: templateTo[0], + }; + await extractorsAPI.save(values); + handleClose(); + onAccept(); + } catch (e) { + console.error('Error saving extractor:', e); + } + }; + + return ( + + +

+ {extractor ? ( + Edit Extractor + ) : ( + (step === 1 && Target template) || + (step === 2 && Paragraph extractor) + )} +

+ setShowModal(false)} /> +
+ + +
+ { + setTemplateTo(selected); + }} + singleSelect + startOnSelected={templateTo?.length > 0} + className="min-h-[327px]" + blankState={} + /> +
+
+
+ 0} + startOnSelected={templatesFrom.length > 0} + className="min-h-[327px]" + /> +
+
+ +
+
+ {/* duplicate structure, can be a function */} +
+
+
+ {templateToOptions.length !== 0 && step === 1 && ( + + Templates meeting required criteria + + )} +
+ + + +
+
+ {step === 1 ? ( + <> + + + + ) : ( + <> + + + + )} +
+
+
+ + ); +}; + +export { ExtractorModal, formatOptions }; diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx index 550e16ed69..4d5d8e024e 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx @@ -4,7 +4,6 @@ import { TableExtractor } from '../types'; const List = ({ items }: { items: TableExtractor[] }) => (
    - {/* what should be displayed on the confirm modal? */} {items.map(item => (
  • Templates: diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/NoQualifiedTemplate.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/NoQualifiedTemplate.tsx new file mode 100644 index 0000000000..088d9b3d9e --- /dev/null +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/NoQualifiedTemplate.tsx @@ -0,0 +1,15 @@ +import { Translate } from 'app/I18N'; +import React from 'react'; + +const NoQualifiedTemplatesMessage = () => ( +
    +

    + No valid target template available +

    +

    + Qualified templates should have "Rich Text" property +

    +
    +); + +export { NoQualifiedTemplatesMessage }; diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx index 0014e25255..6319138f1c 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx @@ -32,7 +32,7 @@ const TemplatesCell = ({ cell }: CellContext) => ( +}: CellContext) => (
    {cell.getValue().map(value => (
    @@ -50,7 +50,6 @@ const LinkButton = ({ cell }: CellContext ); -// todo: fix width of each column const extractorsTableColumns = [ extractorColumnHelper.accessor('originTemplateNames', { header: TemplateFromHeader, diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/types.ts b/app/react/V2/Routes/Settings/ParagraphExtraction/types.ts index 0bea4b7641..e6bb34699e 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/types.ts +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/types.ts @@ -1,7 +1,10 @@ -export type Extractor = { - _id: string; - templateFrom: string[]; +export type ParagraphExtractorValues = { + _id?: string; + templatesFrom: string[]; templateTo: string; +}; + +export type Extractor = ParagraphExtractorValues & { documents: number; generatedEntities: number; }; diff --git a/app/react/V2/api/paragraphExtractor/extractors.ts b/app/react/V2/api/paragraphExtractor/extractors.ts index 75b9bebbb5..3011929e5f 100644 --- a/app/react/V2/api/paragraphExtractor/extractors.ts +++ b/app/react/V2/api/paragraphExtractor/extractors.ts @@ -1,28 +1,27 @@ import { IncomingHttpHeaders } from 'http'; import api from 'app/utils/api'; import { RequestParams } from 'app/utils/RequestParams'; -import { IXExtractorInfo } from 'V2/shared/types'; +import { + Extractor, + ParagraphExtractorValues, +} from 'app/V2/Routes/Settings/ParagraphExtraction/types'; let dummyData = [ { _id: '1', - templateFrom: ['66fbe4f28542cc5545e05a46', '66fbe4d28542cc5545e0599c'], - templateTo: '5bfbb1a0471dd0fc16ada146', + templatesFrom: ['66fbe4f28542cc5545e05a46', '66fbe4d28542cc5545e0599c'], + templateTo: '66ffac5860f7ab062d87d13e', documents: 831, generatedEntities: 12000, - rowId: '1', - status: '', }, { _id: '2', - templateFrom: ['66fbe4d28542cc5545e0599c', 'Judge Documents'], - templateTo: '66fbe4f28542cc5545e05a46', + templatesFrom: ['66fbe4d28542cc5545e0599c', 'Judge Documents'], + templateTo: '66ffac5860f7ab062d87d13e', documents: 500, generatedEntities: 12001, - rowId: '1', - status: '', }, -]; +] as Extractor[]; const apiEndpoint = 'paragraph-extractor'; @@ -41,15 +40,22 @@ const getById = async (extractorId: string, headers?: IncomingHttpHeaders) => { } }; -const save = async (extractor: IXExtractorInfo) => { - const requestParams = new RequestParams(extractor); - let response: IXExtractorInfo[]; - if (extractor._id) { - response = await api.put(apiEndpoint, requestParams); - } else { - response = await api.post(apiEndpoint, requestParams); - } - return response; +const save = async (extractorValues: ParagraphExtractorValues): Promise => { + const requestParams = new RequestParams(extractorValues); + + const dummyEntry = { + ...extractorValues, + documents: Math.floor(Math.random() * 1000), + generatedEntities: Math.floor(Math.random() * 1000), + _id: extractorValues?._id ?? Math.floor(Math.random() * 100).toString(), + }; + + dummyData.push(dummyEntry); + console.log(dummyData); + + return new Promise(resolve => { + resolve(dummyEntry); + }); }; const remove = async (ids: string[]) => { diff --git a/contents/ui-translations/ar.csv b/contents/ui-translations/ar.csv index 81a3284fce..be35eeecc7 100644 --- a/contents/ui-translations/ar.csv +++ b/contents/ui-translations/ar.csv @@ -527,6 +527,7 @@ No Documents found,لم يعثر على مستندات no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,لا توجد أيقونة/ علامة +No items available,No items available No Label,لا تسمية No options,No options No options found,لم يتم العثور على خيارات @@ -579,6 +580,7 @@ out of,خارج Page,صفحة Pages,الصفحات Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,كلمه المرور Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -669,6 +671,7 @@ Renamed attachment,Renamed attachment Repeat Password,إعادة كلمة المرور Request id #,طلب المعرف # Request token,Request token +required criteria,required criteria Required property,الخاصية المطلوبة Reset,إعادة ضبط Reset 2FA,إعادة تعيين المصادقة الثنائية @@ -796,6 +799,7 @@ Table of Contents,جدول المحتويات Table of contents,جدول المحتويات Table view,معاينة الجدول Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,قالب Template conflict,Template conflict @@ -804,6 +808,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,قوالب +Templates meeting,Templates meeting Templates:,Templates: Text,نص Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/en.csv b/contents/ui-translations/en.csv index 7079ed7b5b..a315a1e119 100644 --- a/contents/ui-translations/en.csv +++ b/contents/ui-translations/en.csv @@ -530,6 +530,7 @@ No Documents found,No Documents found no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,No icon / flag +No items available,No items available No Label,No Label No options,No options No options found,No options found @@ -582,6 +583,7 @@ out of,out of Page,Page Pages,Pages Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,Password Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -672,6 +674,7 @@ Renamed attachment,Renamed attachment Repeat Password,Repeat Password Request id #,Request id # Request token,Request token +required criteria,required criteria Required property,Required property Reset,Reset Reset 2FA,Reset 2FA @@ -799,6 +802,7 @@ Table of Contents,Table of Contents Table of contents,Table of contents Table view,Table view Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,Template Template conflict,Template conflict @@ -807,6 +811,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,Templates +Templates meeting,Templates meeting Templates:,Templates: Text,Text Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/es.csv b/contents/ui-translations/es.csv index 48bcc94ae5..5006045a17 100644 --- a/contents/ui-translations/es.csv +++ b/contents/ui-translations/es.csv @@ -526,6 +526,7 @@ No Documents found,No se encontraron documentos no filters for templates,La combinación de tipos de entidades no tiene filtros en común. No Group,No Group No icon / flag,Sin icono / bandera +No items available,No items available No Label,No existe etiqueta No options,No options No options found,Opciones no encontradas @@ -578,6 +579,7 @@ out of,fuera de Page,Página Pages,Páginas Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,Contraseña Password + 2fa,Password + 2fa Password changed success,Contraseña cambiada exitosamente @@ -668,6 +670,7 @@ Renamed attachment,Archivo adjunto eliminado Repeat Password,Repite la contraseña Request id #,Solicitar id # Request token,Solicitud de token +required criteria,required criteria Required property,Propiedad requerida Reset,Reiniciar Reset 2FA,Resetear 2FA @@ -795,6 +798,7 @@ Table of Contents,Tabla de Contenidos Table of contents,Tabla de Contenidos Table view,Vista de Tabla Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,Plantilla Template conflict,Conflicto de plantilla @@ -802,6 +806,7 @@ Template name,Nombre de plantilla Template with a long number of entities,"La plantilla ha cambiado y las entidades asociadas se volverán a indexar, este proceso puede tardar varios minutos, ¿quieres continuar?" Template(s),Template(s) Templates,Plantillas +Templates meeting,Templates meeting Templates:,Templates: Text,Texto Text references limit warning,Las referencias de texto están temporalmente limitadas a un máximo de 300. Actualmente estamos trabajando en una solución para este problema. diff --git a/contents/ui-translations/fr.csv b/contents/ui-translations/fr.csv index 233d560768..f9f435514f 100644 --- a/contents/ui-translations/fr.csv +++ b/contents/ui-translations/fr.csv @@ -527,6 +527,7 @@ No Documents found,No Documents found no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,No icon / flag +No items available,No items available No Label,Aucune étiquettes No options,No options No options found,Aucune option trouvée @@ -579,6 +580,7 @@ out of,hors de Page,Page Pages,Pages Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,Mot de passe Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -669,6 +671,7 @@ Renamed attachment,Renamed attachment Repeat Password,Répéter Mot de passe Request id #,Numéro d'identification de la demande Request token,Request token +required criteria,required criteria Required property,Propriété requise Reset,Réinitialiser Reset 2FA,Réinitialiser 2FA @@ -796,6 +799,7 @@ Table of Contents,Table des matières Table of contents,Table des matières Table view,Vue tabulaire Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,Modèle Template conflict,Template conflict @@ -804,6 +808,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,Modèles +Templates meeting,Templates meeting Templates:,Templates: Text,Texte Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/ko.csv b/contents/ui-translations/ko.csv index 65d1dc0460..cb1d966d05 100644 --- a/contents/ui-translations/ko.csv +++ b/contents/ui-translations/ko.csv @@ -528,6 +528,7 @@ No Documents found,문서를 찾지 못했습니다. no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,아이콘/플래그 없음 +No items available,No items available No Label,라벨 없음 No options,No options No options found,검색된 옵션 없음 @@ -580,6 +581,7 @@ out of,out of Page,페이지 Pages,페이지 Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,비밀번호 Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -670,6 +672,7 @@ Renamed attachment,Renamed attachment Repeat Password,암호를 재입력하십시오. Request id #,아이디 요청 # Request token,Request token +required criteria,required criteria Required property,필수 속성 Reset,초기화 Reset 2FA,이중 인증 절차 재설정 @@ -797,6 +800,7 @@ Table of Contents,목차 Table of contents,목차 Table view,테이블 뷰 Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,템플릿 Template conflict,Template conflict @@ -805,6 +809,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,템플릿 +Templates meeting,Templates meeting Templates:,Templates: Text,텍스트 Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/my.csv b/contents/ui-translations/my.csv index 84bccd67ed..9ffcf65412 100644 --- a/contents/ui-translations/my.csv +++ b/contents/ui-translations/my.csv @@ -528,6 +528,7 @@ No Documents found,စာရွက်စာတမ်း ရှာမတွေ့ no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,အိုင်ကွန် / အလံ မရှိပါ +No items available,No items available No Label,တံဆိပ် မရှိပါ No options,No options No options found,ရွေးချယ်စရာ မရှိပါ @@ -580,6 +581,7 @@ out of,မှ Page,စာမျက်နှာ Pages,စာမျက်နှာများ Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,စကားဝှက် Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -670,6 +672,7 @@ Renamed attachment,Renamed attachment Repeat Password,စကားဝှက် ပြန်ရေးရန် Request id #,ငြင်းပယ်ရန် Request token,Request token +required criteria,required criteria Required property,လိုအပ်သော ထူးခြားချက် Reset,ပြန်လည်သတ်မှတ်ရန် Reset 2FA,2FA ကို ပြန်လည်သတ်မှတ်ရန် @@ -797,6 +800,7 @@ Table of Contents,မာတိကာ Table of contents,မာတိကာ Table view,ဇယားမြင်ကွင်း Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,ပုံစံပြား Template conflict,Template conflict @@ -805,6 +809,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,ပုံစံပြားများ +Templates meeting,Templates meeting Templates:,Templates: Text,စာသား Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/ru.csv b/contents/ui-translations/ru.csv index 7c460ed573..b8a255c3b8 100644 --- a/contents/ui-translations/ru.csv +++ b/contents/ui-translations/ru.csv @@ -525,6 +525,7 @@ No Documents found,Документы не найдены no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,Нет иконки/флажка +No items available,No items available No Label,Нет метки No options,No options No options found,Варианты не найдены @@ -577,6 +578,7 @@ out of,из Page,Страница Pages,Страницы Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,Пароль Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -667,6 +669,7 @@ Renamed attachment,Renamed attachment Repeat Password,Повторите пароль Request id #,Запрос ID # Request token,Request token +required criteria,required criteria Required property,Необходимое свойство Reset,Сброс Reset 2FA,Сбросить 2FA @@ -794,6 +797,7 @@ Table of Contents,Содержание Table of contents,Содержание Table view,Табличный вид Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,Шаблон Template conflict,Template conflict @@ -802,6 +806,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,Шаблоны +Templates meeting,Templates meeting Templates:,Templates: Text,Текст Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/th.csv b/contents/ui-translations/th.csv index 46701e1c5e..9f91de16a0 100644 --- a/contents/ui-translations/th.csv +++ b/contents/ui-translations/th.csv @@ -528,6 +528,7 @@ No Documents found,ไม่พบเอกสาร no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,ไม่พบ ไอค่อน / สิ่งที่ถูกคั่นหน้า +No items available,No items available No Label,ไม่มีลาเบล No options,No options No options found,ไม่พบตัวเลือก @@ -580,6 +581,7 @@ out of,ออกไปจาก Page,หน้า Pages,หน้า Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,รหัสผ่าน Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -670,6 +672,7 @@ Renamed attachment,Renamed attachment Repeat Password,ใส่รหัสผ่านอีกครั้ง Request id #,ขอรหัส # Request token,Request token +required criteria,required criteria Required property,คุณสมบัติที่จำเป็น Reset,รีเซ็ต Reset 2FA,สร้าง 2FA ใหม่ @@ -797,6 +800,7 @@ Table of Contents,สารบัญ Table of contents,สารบัญ Table view,มุมมองตาราง Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,แม่แบบ Template conflict,Template conflict @@ -805,6 +809,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,แม่แบบ +Templates meeting,Templates meeting Templates:,Templates: Text,ข้อความ Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. diff --git a/contents/ui-translations/tr.csv b/contents/ui-translations/tr.csv index 343953d7e5..1b1eceaedc 100644 --- a/contents/ui-translations/tr.csv +++ b/contents/ui-translations/tr.csv @@ -528,6 +528,7 @@ No Documents found,Belge bulunamadı no filters for templates,The combination of entity types doesn't have any filters in common. No Group,No Group No icon / flag,Simge/İşaret yok +No items available,No items available No Label,Etiket yok No options,No options No options found,Seçenek bulunamadı @@ -580,6 +581,7 @@ out of,dışında Page,Sayfa Pages,Sayfalar Paragraph Extraction,Paragraph Extraction +Paragraph extractor,Paragraph extractor Password,Parola Password + 2fa,Password + 2fa Password changed success,Password changed success @@ -670,6 +672,7 @@ Renamed attachment,Renamed attachment Repeat Password,Parolayı yinele Request id #,Kimlik numarası iste # Request token,Request token +required criteria,required criteria Required property,Gerekli özellik Reset,Sıfırla Reset 2FA,İki Adımlı Doğrulama'yı sıfırla @@ -797,6 +800,7 @@ Table of Contents,İçindekiler Table of contents,İçindekiler Table view,Tablo görünümü Target Template,Target Template +Target template,Target template Target Template:,Target Template: Template,Şablon Template conflict,Template conflict @@ -805,6 +809,7 @@ Template with a long number of entities,"The template has changed and the associ this process may take several minutes, do you want to continue?" Template(s),Template(s) Templates,Şablonlar +Templates meeting,Templates meeting Templates:,Templates: Text,Metin Text references limit warning,Text references are temporarily limited to a maximum of 300. We are currently working on a fix for this issue. From 9dbabe3bdf52aa865d962e86778ced188f4e9272 Mon Sep 17 00:00:00 2001 From: JoshuaD Date: Fri, 11 Oct 2024 09:51:48 +0200 Subject: [PATCH 3/8] filter templateTo from templatesFrom list --- .../ParagraphExtraction.tsx | 10 +++---- .../components/ExtractorModal.tsx | 28 +++++++++++-------- .../ParagraphExtraction/components/List.tsx | 4 +-- .../components/TableElements.tsx | 18 +++++++----- .../Settings/ParagraphExtraction/types.ts | 6 ++-- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx index 8deca72bde..053d6302a0 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction.tsx @@ -11,7 +11,7 @@ import { Translate } from 'app/I18N'; import { useSetAtom } from 'jotai'; import { notificationAtom } from 'V2/atoms'; import { extractorsTableColumns } from './components/TableElements'; -import { TableExtractor, Extractor } from './types'; +import { TableParagraphExtractor, ParagraphExtractorApiResponse } from './types'; import { List } from './components/List'; import { ExtractorModal } from './components/ExtractorModal'; @@ -21,9 +21,9 @@ const getTemplateName = (templates: ClientTemplateSchema[], targetId: string) => }; const formatExtractors = ( - extractors: Extractor[], + extractors: ParagraphExtractorApiResponse[], templates: ClientTemplateSchema[] -): TableExtractor[] => +): TableParagraphExtractor[] => extractors.map(extractor => { const targetTemplateName = getTemplateName(templates, extractor.templateTo); const originTemplateNames = (extractor.templatesFrom || []).map(templateFrom => @@ -40,13 +40,13 @@ const formatExtractors = ( const ParagraphExtractorDashboard = () => { const { extractors = [], templates } = useLoaderData() as { - extractors: Extractor[]; + extractors: ParagraphExtractorApiResponse[]; templates: ClientTemplateSchema[]; }; const revalidator = useRevalidator(); const [isSaving, setIsSaving] = useState(false); - const [selected, setSelected] = useState([]); + const [selected, setSelected] = useState([]); const [confirmModal, setConfirmModal] = useState(false); const [extractorModal, setExtractorModal] = useState(false); const setNotifications = useSetAtom(notificationAtom); diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx index 77004a1eb5..ad54daf8c6 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/ExtractorModal.tsx @@ -1,12 +1,12 @@ /* eslint-disable max-lines */ /* eslint-disable max-statements */ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import * as extractorsAPI from 'app/V2/api/paragraphExtractor/extractors'; import { ArrowRightIcon } from '@heroicons/react/20/solid'; import { Modal, Button, MultiselectList } from 'V2/Components/UI'; import { Translate } from 'app/I18N'; import { ClientTemplateSchema } from 'app/istore'; -import { ParagraphExtractorValues } from '../types'; +import { ParagraphExtractorApiPayload } from '../types'; import { NoQualifiedTemplatesMessage } from './NoQualifiedTemplate'; interface ExtractorModalProps { @@ -14,7 +14,7 @@ interface ExtractorModalProps { onClose: () => void; onAccept: () => void; templates: ClientTemplateSchema[]; - extractor?: ParagraphExtractorValues; + extractor?: ParagraphExtractorApiPayload; } const formatOptions = (templates: ClientTemplateSchema[]) => @@ -42,17 +42,21 @@ const ExtractorModal = ({ extractor, }: ExtractorModalProps) => { const [step, setStep] = useState(1); - console.log(extractor); const [templatesFrom, setTemplatesFrom] = useState(extractor?.templatesFrom || []); - const [templateTo, setTemplateTo] = useState( - extractor?.templateTo ? [extractor?.templateTo] : [] - ); + const [templateTo, setTemplateTo] = useState(extractor?.templateTo ?? ''); - const [templateFromOptions] = useState(formatOptions(templates)); const [templateToOptions] = useState(formatOptions(templates.filter(templatesWithParagraph))); + const [templateFromOptions, setTemplateFromOptions] = useState( + formatOptions(templates.filter(template => template._id !== templateTo)) + ); + + useEffect(() => { + setTemplateFromOptions( + formatOptions(templates.filter(template => template._id !== templateTo)) + ); + }, [templateTo, templates]); const handleClose = () => { - // setValues([]); onClose(); }; @@ -61,7 +65,7 @@ const ExtractorModal = ({ const values = { ...extractor, templatesFrom, - templateTo: templateTo[0], + templateTo, }; await extractorsAPI.save(values); handleClose(); @@ -88,10 +92,10 @@ const ExtractorModal = ({
    { - setTemplateTo(selected); + setTemplateTo(selected[0]); }} singleSelect startOnSelected={templateTo?.length > 0} diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx index 4d5d8e024e..f81526ba0b 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/List.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Translate } from 'app/I18N'; -import { TableExtractor } from '../types'; +import { TableParagraphExtractor } from '../types'; -const List = ({ items }: { items: TableExtractor[] }) => ( +const List = ({ items }: { items: TableParagraphExtractor[] }) => (
      {items.map(item => (
    • diff --git a/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx b/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx index 6319138f1c..1a1df4d762 100644 --- a/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx +++ b/app/react/V2/Routes/Settings/ParagraphExtraction/components/TableElements.tsx @@ -5,9 +5,9 @@ import { CellContext, createColumnHelper } from '@tanstack/react-table'; import { Link } from 'react-router-dom'; import { Translate } from 'app/I18N'; import { Button, Pill } from 'V2/Components/UI'; -import { TableExtractor } from '../types'; +import { TableParagraphExtractor } from '../types'; -const extractorColumnHelper = createColumnHelper(); +const extractorColumnHelper = createColumnHelper(); const TemplateFromHeader = () => Template; const TemplateToHeader = () => Target Template; @@ -18,11 +18,13 @@ const ActionHeader = () => Action; const NumericCell = ({ cell, }: CellContext< - TableExtractor, - TableExtractor['documents'] | TableExtractor['generatedEntities'] + TableParagraphExtractor, + TableParagraphExtractor['documents'] | TableParagraphExtractor['generatedEntities'] >) => {cell.getValue()}; -const TemplatesCell = ({ cell }: CellContext) => ( +const TemplatesCell = ({ + cell, +}: CellContext) => (
      {cell.getValue()} @@ -32,7 +34,7 @@ const TemplatesCell = ({ cell }: CellContext) => ( +}: CellContext) => (
      {cell.getValue().map(value => (
      @@ -42,7 +44,9 @@ const TemplateFromCell = ({
      ); -const LinkButton = ({ cell }: CellContext) => ( +const LinkButton = ({ + cell, +}: CellContext) => ( -
      ); diff --git a/contents/ui-translations/ar.csv b/contents/ui-translations/ar.csv index 14be5a32ab..0e1dfd6608 100644 --- a/contents/ui-translations/ar.csv +++ b/contents/ui-translations/ar.csv @@ -646,7 +646,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,انشر Published,منشور QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,استعلام Quick labeling for,تسمية سريعة لـ RAW,RAW diff --git a/contents/ui-translations/en.csv b/contents/ui-translations/en.csv index a6e17be85b..9f39892291 100644 --- a/contents/ui-translations/en.csv +++ b/contents/ui-translations/en.csv @@ -649,7 +649,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,Publish Published,Published QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,Query Quick labeling for,Quick labeling for RAW,RAW diff --git a/contents/ui-translations/es.csv b/contents/ui-translations/es.csv index 787b50e3d9..6ba6d9beac 100644 --- a/contents/ui-translations/es.csv +++ b/contents/ui-translations/es.csv @@ -645,7 +645,7 @@ Public form whitelist description,"Si deseas incluir formularios públicos en tu Publish,Publicar Published,Publicado QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,Consulta Quick labeling for,Etiquetado rápido para RAW,SIN FORMATO diff --git a/contents/ui-translations/fr.csv b/contents/ui-translations/fr.csv index a04c9235ae..550f8525a9 100644 --- a/contents/ui-translations/fr.csv +++ b/contents/ui-translations/fr.csv @@ -646,7 +646,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,Publier Published,Publié QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,Requête Quick labeling for,Étiquetage rapide pour RAW,RAW diff --git a/contents/ui-translations/ko.csv b/contents/ui-translations/ko.csv index d1a4966f52..4f3b372d3e 100644 --- a/contents/ui-translations/ko.csv +++ b/contents/ui-translations/ko.csv @@ -647,7 +647,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,게시 Published,공개 게시물 QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,검사 Quick labeling for,빠른 라벨링 RAW,RAW diff --git a/contents/ui-translations/my.csv b/contents/ui-translations/my.csv index c11711b806..2add7198d2 100644 --- a/contents/ui-translations/my.csv +++ b/contents/ui-translations/my.csv @@ -647,7 +647,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,ထုတ်ဝေရန် Published,ထုတ်ဝေပြီး QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,မေးခွန်း Quick labeling for,အမြန် တံဆိပ်တပ်အမှတ်အသားပြုခြင်း RAW,RAW diff --git a/contents/ui-translations/ru.csv b/contents/ui-translations/ru.csv index 5ca3e6c837..ddc4b7a716 100644 --- a/contents/ui-translations/ru.csv +++ b/contents/ui-translations/ru.csv @@ -644,7 +644,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,Опубликовать Published,В открытом доступе QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,Запрос Quick labeling for,Быстрая маркировка для RAW,RAW diff --git a/contents/ui-translations/th.csv b/contents/ui-translations/th.csv index aa4be1a8eb..370829a7e5 100644 --- a/contents/ui-translations/th.csv +++ b/contents/ui-translations/th.csv @@ -647,7 +647,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,เผยแพร่ Published,ตีพิมพ์แล้ว QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,สืบค้น Quick labeling for,จัดประเภททันที RAW,RAW diff --git a/contents/ui-translations/tr.csv b/contents/ui-translations/tr.csv index 645bcdb162..8839cbc6a7 100644 --- a/contents/ui-translations/tr.csv +++ b/contents/ui-translations/tr.csv @@ -647,7 +647,7 @@ Public form whitelist description,"If you wish to include Public Forms on your p Publish,Yayınla Published,Yayınlanan QR Code,QR Code -"Qualified templates should have ""Rich Text"" property","Qualified templates should have ""Rich Text"" property" +Qualified templates should have Rich Text property,Qualified templates should have Rich Text property Query,Sorgulama Quick labeling for,Hızlı etiketleme RAW,RAW