Compare commits
No commits in common. "2cd80343ab85d97a0e441566a2e37e0e9f598c78" and "2cc53b6846996cced858aed59021deac2d1a2849" have entirely different histories.
2cd80343ab
...
2cc53b6846
@ -2,11 +2,8 @@
|
|||||||
import { useEffect, useRef, useLayoutEffect, useState } from 'react';
|
import { useEffect, useRef, useLayoutEffect, useState } from 'react';
|
||||||
import { isFormula, extractFormula, calculateFormula, formatNumber } from '../../utils/formulaUtils';
|
import { isFormula, extractFormula, calculateFormula, formatNumber } from '../../utils/formulaUtils';
|
||||||
import { saveToStorage, loadFromStorage } from '../../utils/localStorageUtils';
|
import { saveToStorage, loadFromStorage } from '../../utils/localStorageUtils';
|
||||||
import { useRealtime } from '../../contexts/RealtimeContext';
|
|
||||||
|
|
||||||
const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }) => {
|
|
||||||
const { endEditing: contextEndEditing } = useRealtime();
|
|
||||||
|
|
||||||
|
const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId }) => {
|
||||||
const [curValue, setCurValue] = useState(value);
|
const [curValue, setCurValue] = useState(value);
|
||||||
const [displayValue, setDisplayValue] = useState(value);
|
const [displayValue, setDisplayValue] = useState(value);
|
||||||
const [isFormulaMode, setIsFormulaMode] = useState(false);
|
const [isFormulaMode, setIsFormulaMode] = useState(false);
|
||||||
@ -111,29 +108,6 @@ const EditCell = ({ refCell, onChange, disabled, value, tableId, cellId, table }
|
|||||||
return displayValue;
|
return displayValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const finishEditing = () => {
|
|
||||||
const editingCell = table.getState().editingCell || null;
|
|
||||||
if (editingCell) {
|
|
||||||
contextEndEditing?.(editingCell.row, editingCell.column);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleClickOutside = (event) => {
|
|
||||||
// Проверяем, был ли клик внутри элемента редактирования
|
|
||||||
const editElement = ref.current;
|
|
||||||
if (editElement && !editElement.contains(event.target)) {
|
|
||||||
finishEditing();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener('mousedown', handleClickOutside);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener('mousedown', handleClickOutside);
|
|
||||||
};
|
|
||||||
}, [ref]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@ -177,7 +177,6 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
|
|||||||
measureElement: (el) => el?.offsetHeight || TABLE_ROW_HEIGHT,
|
measureElement: (el) => el?.offsetHeight || TABLE_ROW_HEIGHT,
|
||||||
},
|
},
|
||||||
onEditingCellChange: (cell) => {
|
onEditingCellChange: (cell) => {
|
||||||
console.log(cell, editingCell);
|
|
||||||
if (cell) {
|
if (cell) {
|
||||||
if (editingCell) return;
|
if (editingCell) return;
|
||||||
contextStartEditing?.(cell.row, cell.column);
|
contextStartEditing?.(cell.row, cell.column);
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { createPortal } from 'react-dom';
|
|||||||
import { columns as mockColumns } from '../../mocks/mockTable';
|
import { columns as mockColumns } from '../../mocks/mockTable';
|
||||||
import { config } from './constants/FORM_2/AHR';
|
import { config } from './constants/FORM_2/AHR';
|
||||||
import { useParams } from 'react-router';
|
import { useParams } from 'react-router';
|
||||||
import { useRealtime } from './contexts/RealtimeContext';
|
|
||||||
|
|
||||||
function EditCellPortal({
|
function EditCellPortal({
|
||||||
cell,
|
cell,
|
||||||
@ -21,8 +20,6 @@ function EditCellPortal({
|
|||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const isDisabled = false;
|
const isDisabled = false;
|
||||||
|
|
||||||
const { endEditing: contextEndEditing } = useRealtime();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
const tbodyRef = ref.current.offsetParent?.offsetParent?.offsetParent;
|
const tbodyRef = ref.current.offsetParent?.offsetParent?.offsetParent;
|
||||||
@ -71,7 +68,6 @@ function EditCellPortal({
|
|||||||
disabled={!isEditable}
|
disabled={!isEditable}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
tableId={tableKey}
|
tableId={tableKey}
|
||||||
table={table}
|
|
||||||
cellId={cell.row.id + '_' + cell.column.id}
|
cellId={cell.row.id + '_' + cell.column.id}
|
||||||
/>,
|
/>,
|
||||||
refTbody,
|
refTbody,
|
||||||
|
|||||||
@ -21,6 +21,7 @@ export const EVENT_CONFIGS = {
|
|||||||
branch_name: 'Региональный филиал ',
|
branch_name: 'Региональный филиал ',
|
||||||
closed_at: 'Дата закрытия ВСП',
|
closed_at: 'Дата закрытия ВСП',
|
||||||
user_email: 'Почта пользователя',
|
user_email: 'Почта пользователя',
|
||||||
|
staff_count: 'Кол-во работников',
|
||||||
is_active: 'Активный',
|
is_active: 'Активный',
|
||||||
},
|
},
|
||||||
VSP_UPDATE: {
|
VSP_UPDATE: {
|
||||||
@ -39,6 +40,7 @@ export const EVENT_CONFIGS = {
|
|||||||
'changes.branch_name': 'Региональный филиал ',
|
'changes.branch_name': 'Региональный филиал ',
|
||||||
closed_at: 'Дата закрытия ВСП',
|
closed_at: 'Дата закрытия ВСП',
|
||||||
user_email: 'Почта пользователя',
|
user_email: 'Почта пользователя',
|
||||||
|
staff_count: 'Кол-во работников',
|
||||||
is_active: 'Активный',
|
is_active: 'Активный',
|
||||||
},
|
},
|
||||||
USER_ACCESS_GRANTED: {
|
USER_ACCESS_GRANTED: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user