diff --git a/rsconcept/frontend/.eslintrc.json b/rsconcept/frontend/.eslintrc.json index f3b0f326..aab18438 100644 --- a/rsconcept/frontend/.eslintrc.json +++ b/rsconcept/frontend/.eslintrc.json @@ -17,7 +17,10 @@ "react", "simple-import-sort" ], "rules": { - "simple-import-sort/imports": "error", + "simple-import-sort/imports": "warn", + "@typescript-eslint/no-unused-vars": "warn", + "no-trailing-spaces": "warn", + "no-multiple-empty-lines": "warn", "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/semi": "off", "@typescript-eslint/strict-boolean-expressions": "off", diff --git a/rsconcept/frontend/src/components/Common/Button.tsx b/rsconcept/frontend/src/components/Common/Button.tsx index 4ef6f6bb..9e7a5d54 100644 --- a/rsconcept/frontend/src/components/Common/Button.tsx +++ b/rsconcept/frontend/src/components/Common/Button.tsx @@ -1,17 +1,13 @@ -import { type MouseEventHandler } from 'react'; - -interface ButtonProps { - id?: string +interface ButtonProps +extends Omit, 'className' | 'children'> { text?: string icon?: React.ReactNode tooltip?: string - disabled?: boolean dense?: boolean loading?: boolean widthClass?: string borderClass?: string colorClass?: string - onClick?: MouseEventHandler | undefined } function Button({ @@ -26,7 +22,7 @@ function Button({ return ( @@ -158,18 +169,18 @@ function ConstituentEditor() { @@ -177,7 +188,7 @@ function ConstituentEditor() { placeholder='Схемный или предметный термин, обозначающий данное понятие или утверждение' rows={2} value={term} - disabled={!isEditable} + disabled={!isEnabled} spellCheck onChange={event => { setTerm(event.target.value); }} onFocus={() => { setEditMode(EditMode.TEXT); }} @@ -190,7 +201,7 @@ function ConstituentEditor() { { setEditMode(EditMode.RSLANG); }} onChange={event => { setExpression(event.target.value); }} @@ -201,7 +212,7 @@ function ConstituentEditor() { placeholder='Лингвистическая интерпретация формального выражения' rows={4} value={textDefinition} - disabled={!isEditable} + disabled={!isEnabled} spellCheck onChange={event => { setTextDefinition(event.target.value); }} onFocus={() => { setEditMode(EditMode.TEXT); }} @@ -210,7 +221,7 @@ function ConstituentEditor() { placeholder='Договоренность об интерпретации неопределяемого понятия Комментарий к производному понятию' rows={4} value={convention} - disabled={!isEditable} + disabled={!isEnabled} spellCheck onChange={event => { setConvention(event.target.value); }} onFocus={() => { setEditMode(EditMode.TEXT); }} @@ -218,7 +229,7 @@ function ConstituentEditor() {
} />
diff --git a/rsconcept/frontend/src/pages/RSFormPage/ConstituentsTable.tsx b/rsconcept/frontend/src/pages/RSFormPage/ConstituentsTable.tsx index 4993baa0..ef7df570 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/ConstituentsTable.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/ConstituentsTable.tsx @@ -257,7 +257,7 @@ function ConstituentsTable({ onOpenEdit }: ConstituentsTableProps) { return (<> { setShowCstModal(!showCstModal); }} + hideWindow={() => { setShowCstModal(false); }} onCreate={handleAddNew} />
diff --git a/rsconcept/frontend/src/pages/RSFormPage/CreateCstModal.tsx b/rsconcept/frontend/src/pages/RSFormPage/CreateCstModal.tsx index 57a09c0e..a4d5f1f5 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/CreateCstModal.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/CreateCstModal.tsx @@ -7,12 +7,12 @@ import { CstTypeSelector, getCstTypeLabel } from '../../utils/staticUI'; interface CreateCstModalProps { show: boolean - toggle: () => void + hideWindow: () => void defaultType?: CstType onCreate: (type: CstType) => void } -function CreateCstModal({ show, toggle, defaultType, onCreate }: CreateCstModalProps) { +function CreateCstModal({ show, hideWindow, defaultType, onCreate }: CreateCstModalProps) { const [validated, setValidated] = useState(false); const [selectedType, setSelectedType] = useState(undefined); @@ -33,7 +33,7 @@ function CreateCstModal({ show, toggle, defaultType, onCreate }: CreateCstModalP diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSFormCard.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSFormCard.tsx index 1baf09db..cb3cbd30 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSFormCard.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSFormCard.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useLayoutEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useNavigate } from 'react-router-dom'; import { toast } from 'react-toastify'; @@ -29,11 +29,28 @@ function RSFormCard() { const [comment, setComment] = useState(''); const [common, setCommon] = useState(false); - useEffect(() => { - setTitle(schema?.title ?? ''); - setAlias(schema?.alias ?? ''); - setComment(schema?.comment ?? ''); - setCommon(schema?.is_common ?? false); + const [isModified, setIsModified] = useState(true); + + useLayoutEffect(() => { + if (!schema) { + setIsModified(false); + return; + } + setIsModified( + schema.title !== title || + schema.alias !== alias || + schema.comment !== comment || + schema.is_common !== common + ); + }, [schema, title, alias, comment, common]); + + useLayoutEffect(() => { + if (schema) { + setTitle(schema.title); + setAlias(schema.alias); + setComment(schema.comment); + setCommon(schema.is_common); + } }, [schema]); const handleSubmit = (event: React.FormEvent) => { @@ -87,7 +104,7 @@ function RSFormCard() { } />
@@ -97,7 +114,6 @@ function RSFormCard() { onClick={shareCurrentURLProc} />