From cf2ae21f7e13854cb32ca00db8bdd9486b2026ac Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Wed, 20 Dec 2023 20:01:36 +0300 Subject: [PATCH 1/2] fix --- src/components/LexicalEntryCorp/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/LexicalEntryCorp/index.js b/src/components/LexicalEntryCorp/index.js index f138b4b8..6cd92037 100644 --- a/src/components/LexicalEntryCorp/index.js +++ b/src/components/LexicalEntryCorp/index.js @@ -129,6 +129,7 @@ const getComponent = dataType => Markup, Link, Image, + Ordering: Text, "Grouping Tag": GroupingTag, "Directed Link": Link }[dataType] || Unknown); From 8cacea78f82d7b30d9f779c57ef3f4976ad80498 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Thu, 21 Dec 2023 16:42:36 +0300 Subject: [PATCH 2/2] Ordering component --- src/components/LexicalEntryCorp/Ordering.js | 434 ++++++++++++++++++++ src/components/LexicalEntryCorp/index.js | 3 +- 2 files changed, 436 insertions(+), 1 deletion(-) create mode 100644 src/components/LexicalEntryCorp/Ordering.js diff --git a/src/components/LexicalEntryCorp/Ordering.js b/src/components/LexicalEntryCorp/Ordering.js new file mode 100644 index 00000000..aaa2b4b1 --- /dev/null +++ b/src/components/LexicalEntryCorp/Ordering.js @@ -0,0 +1,434 @@ +import React, { useCallback, useState } from "react"; +import { useDrag } from "react-dnd"; +import { RegExpMarker } from "react-mark.js"; +import TextareaAutosize from "react-textarea-autosize"; +import { Button, Checkbox } from "semantic-ui-react"; +import { find, isEqual } from "lodash"; +import PropTypes from "prop-types"; +import { onlyUpdateForKeys } from "recompose"; + +import Entities from "./index"; + +const TextEntityContent = ({ + entry, + entity, + mode, + //parentEntity, + publish, + //column, + accept, + //remove, + //breakdown, + //is_being_removed, + //is_being_updated, + checkEntries, + checkedRow, + resetCheckedRow, + checkedColumn, + resetCheckedColumn, + checkedAll, + resetCheckedAll, + number, + //update, + id +}) => { + + //const is_order_column = (number && column.english_translation === "Order"); + //const [read_only, setReadOnly] = useState(is_order_column); + //const [is_number, setIsNumber] = useState(is_order_column); + //const [edit, setEdit] = useState(false); + + const [content, setContent] = useState(entity.content); + const [dropped, setDropped] = useState(null); + + /* + const onEdit = useCallback(() => { + if (!edit) { + setEdit(true); + } else { + update(entity, content); + setEdit(false); + } + }, [edit, content]); + + const onKeyDown = useCallback((event) => { + + breakdown(event, parentEntity, entity); + + if (event.code === "Enter" && !event.ctrlKey) { + onEdit(); + } + + }, [edit, content]); + */ + + // useDrag - the list item is draggable + const [{ isDragging}, dragRef, preview] = useDrag({ + type: 'entity', + item: { id, content }, + collect: (monitor) => ({ + isDragging: monitor.isDragging() + }), + end: (item, monitor) => { + if (monitor.didDrop()) { + setDropped(item); + remove(item, entry.id); + } + } + }); + + const text = number; + + if (checkEntries) { + if (checkedAll) { + if (checkedAll.checkedAll) { + if (!entity.published) { + publish(entity, true); + } + } else { + if (entity.published) { + publish(entity, false); + } + } + } + + if (checkedRow) { + if (JSON.stringify(checkedRow.id) === JSON.stringify(entity.parent_id)) { + if (checkedRow.checkedRow) { + if (!entity.published) { + publish(entity, true); + } + } else { + if (entity.published) { + publish(entity, false); + } + } + } + } + + if (checkedColumn) { + if (JSON.stringify(checkedColumn.id) === JSON.stringify(entity.field_id)) { + if (checkedColumn.checkedColumn) { + if (!entity.published) { + publish(entity, true); + } + } else { + if (entity.published) { + publish(entity, false); + } + } + } + } + } + + /* + const pg_ln = /\[\d+[ab]?:\d+\]/; + const pg = /\[\d+[ab]?\]/; + const ln = /\(\d+\)/; + const snt = /\u2260/; + const missed = /[/]missed text[/]/; + const metatext = new RegExp( + `${pg_ln.source }|${ + pg.source }|${ + ln.source }|${ + snt.source }|${ + missed.source}` + ); + */ + + switch (mode) { + case "edit": + return !dropped ? ( +
+ {text} + {/*!(is_being_updated || edit) && ( + {text} + )} + {(is_being_updated || edit) && ( + setContent(event.target.value)} + onKeyDown={onKeyDown} + className="lingvo-input-action lingvo-input-action_textarea" + /> + )} + { read_only || ( + +
+
+
+ ) : null; + case "publish": + return ( +
+ {/*column.english_translation && + column.english_translation === "Number of the languages" && + entity.id && + entity.parent_id ? ( + + + {text} + + + ) : ( + {text} + )*/} + {text} + { + publish(entity, checked); + + if (checkEntries) { + if (checkedRow) { + resetCheckedRow(); + } + if (checkedColumn) { + resetCheckedColumn(); + } + if (checkedAll) { + resetCheckedAll(); + } + } + }} + /> +
+ ); + + case "view": + return ( + {text} + ); + case "contributions": + return entity.accepted ? ( + {text} + ) : ( + +