From 09c95cb81f47e77845baaea4fbed3ce4bc6af617 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:46:52 +0300 Subject: [PATCH] Fix regexp filtering errors --- rsconcept/frontend/src/models/library.ts | 12 +++----- rsconcept/frontend/src/models/rsform.ts | 12 ++++---- rsconcept/frontend/src/models/rslang.ts | 1 + .../src/pages/RSFormPage/DlgCreateCst.tsx | 1 + .../src/pages/RSFormPage/DlgEditWordForms.tsx | 6 ++-- .../elements/ViewSideConstituents.tsx | 9 +++--- rsconcept/frontend/src/utils/labels.ts | 2 ++ rsconcept/frontend/src/utils/utils.tsx | 30 ++++++++++++++++++- 8 files changed, 52 insertions(+), 21 deletions(-) diff --git a/rsconcept/frontend/src/models/library.ts b/rsconcept/frontend/src/models/library.ts index d18a025c..3cd6684e 100644 --- a/rsconcept/frontend/src/models/library.ts +++ b/rsconcept/frontend/src/models/library.ts @@ -1,5 +1,7 @@ // Module: Schema library models. +import { TextMatcher } from '../utils/utils' + // ========= Users =========== export interface IUser { id: number | null @@ -53,13 +55,7 @@ export interface ILibraryUpdateData // ============= API =============== export function matchLibraryItem(query: string, target: ILibraryItem): boolean { - const queryI = query.toUpperCase() - if (target.alias.toUpperCase().match(queryI)) { - return true - } else if (target.title.toUpperCase().match(queryI)) { - return true - } else { - return false - } + const matcher = new TextMatcher(query); + return matcher.test(target.alias) || matcher.test(target.title); } diff --git a/rsconcept/frontend/src/models/rsform.ts b/rsconcept/frontend/src/models/rsform.ts index 5a9a29b7..df27fd61 100644 --- a/rsconcept/frontend/src/models/rsform.ts +++ b/rsconcept/frontend/src/models/rsform.ts @@ -1,4 +1,5 @@ import { Graph } from '../utils/Graph' +import { TextMatcher } from '../utils/utils' import { ILibraryUpdateData } from './library' import { ILibraryItem } from './library' import { CstMatchMode } from './miscelanious' @@ -215,21 +216,22 @@ export function loadRSFormData(schema: IRSFormData): IRSForm { return result; } -export function matchConstituenta(query: string, target: IConstituenta, mode: CstMatchMode) { +export function matchConstituenta(query: string, target: IConstituenta, mode: CstMatchMode): boolean { + const matcher = new TextMatcher(query); if ((mode === CstMatchMode.ALL || mode === CstMatchMode.NAME) && - target.alias.match(query)) { + matcher.test(target.alias)) { return true; } if ((mode === CstMatchMode.ALL || mode === CstMatchMode.TERM) && - target.term_resolved.match(query)) { + matcher.test(target.term_resolved)) { return true; } if ((mode === CstMatchMode.ALL || mode === CstMatchMode.EXPR) && - target.definition_formal.match(query)) { + matcher.test(target.definition_formal)) { return true; } if ((mode === CstMatchMode.ALL || mode === CstMatchMode.TEXT)) { - return (target.definition_resolved.match(query) || target.convention.match(query)); + return (matcher.test(target.definition_resolved) || matcher.test(target.convention)); } return false; } diff --git a/rsconcept/frontend/src/models/rslang.ts b/rsconcept/frontend/src/models/rslang.ts index 79bfb581..b9ff5d7a 100644 --- a/rsconcept/frontend/src/models/rslang.ts +++ b/rsconcept/frontend/src/models/rslang.ts @@ -166,6 +166,7 @@ export enum TokenID { } export enum RSErrorType { + unknownSymbol = 33283, syntax = 33792, missingParanthesis = 33798, missingCurlyBrace = 33799, diff --git a/rsconcept/frontend/src/pages/RSFormPage/DlgCreateCst.tsx b/rsconcept/frontend/src/pages/RSFormPage/DlgCreateCst.tsx index b9a0a2d4..a3a1f22c 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/DlgCreateCst.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/DlgCreateCst.tsx @@ -74,6 +74,7 @@ function DlgCreateCst({ hideWindow, initial, onCreate }: DlgCreateCstProps) { onChange={event => setTerm(event.target.value)} /> -
+
Параметры словоформы
@@ -283,7 +283,7 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps) />
-
+
-
+
Заданные вручную словоформы: [{forms.length}]
matchConstituenta(filterText, cst, filterMatch)); } setFilteredData(filtered); @@ -141,9 +142,9 @@ function ViewSideConstituents({ expression, baseHeight, activeID, onOpenEdit }: columnHelper.accessor(cst => describeConstituenta(cst), { id: 'description', header: 'Описание', - size: 500, + size: 1000, minSize: 350, - maxSize: 500, + maxSize: 1000, cell: props =>