add-columns-spod-4-form #176

Merged
PotapovaA merged 2 commits from add-columns-spod-4-form into test 2026-09-24 15:11:47 +03:00
4 changed files with 5470 additions and 5256 deletions
Showing only changes of commit 15ac95f7d7 - Show all commits

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,14 @@ const RealtimeConnectionContext = createContext(null);
const RealtimeVspOptionsContext = createContext(null);
const LockedCellsStoreContext = createContext(null);
const getColumnRequestKey = (column) => {
const columnKey = column?.columnDef?.id ?? column?.id;
if (columnKey === null || columnKey === undefined) return '';
const normalizedColumnKey = String(columnKey);
return normalizedColumnKey.startsWith('data.') ? normalizedColumnKey.slice(5) : normalizedColumnKey;
};
const useRequiredContext = (context, hookName) => {
const value = useContext(context);
if (value === null) {
@ -238,21 +246,19 @@ export const RealtimeProvider = ({ children, formId, sheetName, direction, year,
// Функция для начала редактирования ячейки
const startEditing = useCallback(
(row, column) => {
const columnId = column.id;
if (!isConnectedRef.current) {
onErrorRef.current?.('WebSocket не подключен');
return false;
}
const lineId = row.id || null;
const colId = columnId.slice(5); // убираем префикс "data."
const columnKey = getColumnRequestKey(column);
const message = {
event: 'cell_edit_start',
data: {
line_id: lineId,
column: colId,
column: columnKey,
},
};
@ -269,21 +275,19 @@ export const RealtimeProvider = ({ children, formId, sheetName, direction, year,
// Функция для завершения редактирования ячейки
const endEditing = useCallback(
(row, column) => {
const columnId = column.id;
if (!isConnectedRef.current) {
onErrorRef.current?.('WebSocket не подключен');
return false;
}
const lineId = row.id || null;
const colId = columnId.slice(5);
const columnKey = getColumnRequestKey(column);
const message = {
event: 'cell_edit_end',
data: {
line_id: lineId,
column: colId,
column: columnKey,
},
};
@ -299,20 +303,19 @@ export const RealtimeProvider = ({ children, formId, sheetName, direction, year,
const updateCell = useCallback(
(row, column, value) => {
const columnId = column.id;
if (!isConnectedRef.current) {
onErrorRef.current?.('WebSocket не подключен');
return false;
}
const lineId = getRowId(row);
const colId = columnId.slice(5);
const columnKey = getColumnRequestKey(column);
const message = {
event: 'cell_updated',
data: {
line_id: lineId,
line_id_code: row.id,
column: colId,
column: columnKey,
value: value,
},
};