From 1a4b810180eddca0e92c5c90b1cd72c2353bc5b7 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Wed, 25 Oct 2023 17:09:59 +0300 Subject: [PATCH] Count missed words and hide dashes (#1049) * fix styles dnd * fix dnd * fix dnd and styles * blob.values.dedash * fix shortcut * fix * Fixed "dedash" * Tuned frontend * Minor * Count missed words --------- Co-authored-by: nataliauvarova Co-authored-by: nataliauvarova <90451645+nataliauvarova@users.noreply.github.com> --- src/components/CorporaView/Row.js | 14 +++---- src/components/CorporaView/index.js | 5 ++- src/components/CorporaView/styles.scss | 11 ++++++ src/components/LexicalEntry/Text.js | 5 ++- src/components/LexicalEntryCorp/Text.js | 47 ++++++++---------------- src/components/LexicalEntryCorp/index.js | 12 +++--- src/pages/CorpImport/ColumnMapper.js | 11 ++---- src/pages/CorpImport/Linker.js | 11 +++++- src/pages/CorpImport/api.js | 11 ++---- src/pages/CorpImport/index.js | 9 +++-- src/pages/DictImport/styles.scss | 6 +-- src/styles/main.scss | 26 +++++++++++++ 12 files changed, 98 insertions(+), 70 deletions(-) create mode 100644 src/components/CorporaView/styles.scss diff --git a/src/components/CorporaView/Row.js b/src/components/CorporaView/Row.js index 309a54bf..da530a14 100644 --- a/src/components/CorporaView/Row.js +++ b/src/components/CorporaView/Row.js @@ -40,7 +40,6 @@ const Row = ({ id, /* new!!!!! */ moveListItem, /* new!!!!! */ dragAndDropEntries, /* new!!!!! */ - entries /* new!!!!! */ /* eslint-enable react/prop-types */ }) => { @@ -100,8 +99,9 @@ const Row = ({ return; } // Determine rectangle on screen - //const hoverBoundingRect = ref.current?.getBoundingClientRect(); - const hoverBoundingRect = ref.current.parentElement.parentElement?.getBoundingClientRect(); // fix!!!!! + const hoverBoundingRect = ref.current?.getBoundingClientRect(); + //const hoverBoundingRect = ref.current.parentElement.parentElement?.getBoundingClientRect(); // fix!!!!! + // Get vertical middle const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2; // Determine mouse position @@ -137,8 +137,6 @@ const Row = ({ const dragDropRef = dragRef(dropRef(ref)); - /*const opacity = isDragging ? 0 : 1;*/ - /* /new!!!!!! */ const entry_id_str = id2str(entry.id); @@ -154,7 +152,9 @@ const Row = ({ {/* new!!!!! */}
-
{/* /new!!!!! */} @@ -298,6 +298,6 @@ export default onlyUpdateForKeys([ "columns", "id", /* ????? new!!!!! */ "index", /* ????? new!!!!! */ - "moveListItem", /* new!!!!! */ + /*"moveListItem",*/ /* new!!!!! */ "entries" /* new!!!!! */ ])(Row); diff --git a/src/components/CorporaView/index.js b/src/components/CorporaView/index.js index 592035fa..6139572d 100644 --- a/src/components/CorporaView/index.js +++ b/src/components/CorporaView/index.js @@ -32,6 +32,8 @@ import smoothScroll from "utils/smoothscroll"; import TableBody from "./TableBody"; import TableHeader from "./TableHeader"; +import "./styles.scss"; + const ROWS_PER_PAGE = 20; const ModalContentWrapper = styled("div")` @@ -992,7 +994,8 @@ class P extends React.Component { onSortModeChange={(fieldId, order) => setSort(fieldId, order)} onSortModeReset={() => resetSort()} selectEntries={mode === "edit"} - entries={items} + /*entries={items}*/ + entries={this.state.cards.length && this.state.cards || items} /* new!!!!! */ checkEntries={isTableLanguagesPublish} selectedRows={selectedRows} selectedColumns={selectedColumns} diff --git a/src/components/CorporaView/styles.scss b/src/components/CorporaView/styles.scss new file mode 100644 index 00000000..fb138e9b --- /dev/null +++ b/src/components/CorporaView/styles.scss @@ -0,0 +1,11 @@ +/* parallel corpora */ +.lingvo-scrolling-content { + padding-bottom: 20px !important; + + & .lingvo-scrolling-tab { + @media only screen and (max-device-width: 1000px), only screen and (max-width: 1000px) { + margin-bottom: 0 !important; + } + } +} +/* /parallel corpora */ \ No newline at end of file diff --git a/src/components/LexicalEntry/Text.js b/src/components/LexicalEntry/Text.js index 56074e08..496dbbea 100644 --- a/src/components/LexicalEntry/Text.js +++ b/src/components/LexicalEntry/Text.js @@ -101,13 +101,16 @@ class TextEntityContent extends React.Component { const pg = /\[\d+[ab]?\]/; const ln = /\(\d+\)/; const snt = /\/{2}/; + const missed = /[/]missed text[/]/; // TODO: change 'number' to something meaningful const metatext = number ? new RegExp( pg_ln.source + "|" + pg.source + "|" + ln.source + "|" + - snt.source) + snt.source + "|" + + missed.source + ) : new RegExp(); switch (mode) { diff --git a/src/components/LexicalEntryCorp/Text.js b/src/components/LexicalEntryCorp/Text.js index 1083de92..27a6874e 100644 --- a/src/components/LexicalEntryCorp/Text.js +++ b/src/components/LexicalEntryCorp/Text.js @@ -1,7 +1,7 @@ import React, { useCallback, useState } from "react"; import { useDrag } from "react-dnd"; import TextareaAutosize from 'react-textarea-autosize'; -import { Button, Checkbox, Input } from "semantic-ui-react"; +import { Button, Checkbox } from "semantic-ui-react"; import { find, isEqual } from "lodash"; import PropTypes from "prop-types"; import { onlyUpdateForKeys } from "recompose"; @@ -31,8 +31,6 @@ const TextEntityContent = ({ id /* new!!!!!! */ }) => { - /*console.log('render TextEntityContent!!!!!');*/ - const [edit, setEdit] = useState(false); const [content, setContent] = useState(entity.content); @@ -53,13 +51,9 @@ const TextEntityContent = ({ const onKeyDown = useCallback((event) => { - console.log('event====='); - console.log(event); - breakdown(event, parentEntity, entity); - }, []); - /* /new!!!!! */ + }, []); // useDrag - the list item is draggable const [{ isDragging}, dragRef, preview] = useDrag({ @@ -75,6 +69,8 @@ const TextEntityContent = ({ } }); + /* /new!!!!! */ + if (checkEntries) { if (checkedAll) { if (checkedAll.checkedAll) { @@ -120,9 +116,9 @@ const TextEntityContent = ({ switch (mode) { case "edit": return !dropped ? ( -
+
{!(is_being_updated || edit) && ( - {content} {isDragging && 'Oops'} + {content} )} {(is_being_updated || edit) && ( /* new!!!!!! */ @@ -136,9 +132,8 @@ const TextEntityContent = ({ )} {/* new!!!!! */} -
-
{/* new!!!!! */}
+ { !index && ( + onUpdateColumn("sentence", value === "dash" ? "dedash" : "dash", value)} + checked={value === "dedash"} /> + ) ||
}
); } diff --git a/src/pages/CorpImport/api.js b/src/pages/CorpImport/api.js index a942a677..2626f135 100644 --- a/src/pages/CorpImport/api.js +++ b/src/pages/CorpImport/api.js @@ -23,16 +23,13 @@ export function corpusInfo({ linking, languages, licenses }) { function blobExport(blob, columnType) { const blob_id = blob.get("id").toArray(); - const values = blob.get("values", new Map()); - - const field_map = { - column_name: values.get("sentence", "Sentence in transliteration"), - field_id: columnType.get("sentence", new Map()).toArray() - }; + const dedash = (blob.getIn(["values", "sentence"], "dash") === "dedash"); + const field_id = columnType.get("sentence", new Map()).toArray(); return { blob_id, - field_map + field_id, + dedash }; } diff --git a/src/pages/CorpImport/index.js b/src/pages/CorpImport/index.js index 7f32f437..f0689b10 100644 --- a/src/pages/CorpImport/index.js +++ b/src/pages/CorpImport/index.js @@ -120,10 +120,11 @@ class Info extends React.Component { } onSetColumnType(id) { - return column => (field, name) => { - this.props.setColumnType(id, column, field); - this.props.updateColumn(id, column, name, null); - }; + return column => field => this.props.setColumnType(id, column, field); + } + + onUpdateColumn(id) { + return (column, value, oldValue) => this.props.updateColumn(id, column, value, oldValue); } onUpdateColumn(id) { diff --git a/src/pages/DictImport/styles.scss b/src/pages/DictImport/styles.scss index fd154856..6b397a96 100644 --- a/src/pages/DictImport/styles.scss +++ b/src/pages/DictImport/styles.scss @@ -13,7 +13,7 @@ display: grid; padding: 0.5em 0; width: 100%; - grid-template-columns: 200px 1fr 20px; + grid-template-columns: 200px 1fr 40px; grid-template-rows: auto; grid-template-areas: "name columns checkbox"; @@ -22,8 +22,7 @@ margin-bottom: 0.5em; &_corp { - grid-template-columns: 200px 1fr; - grid-template-areas: "name columns"; + grid-template-columns: 200px 150px 200px; } .blob-name { @@ -36,6 +35,7 @@ display: flex; grid-area: columns; overflow: auto; + margin-left: 1em; .column-field-type { display: flex; diff --git a/src/styles/main.scss b/src/styles/main.scss index b69c09df..17c4ecc2 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -3928,10 +3928,23 @@ body { } } } + } } + &.ui.basic.buttons &__drag:first-child .button { + max-height: 34px !important; + + &:hover, + &:active, + &:focus { + -webkit-box-shadow: none !important; + box-shadow: none !important; + border-radius: 10px 0 0 10px !important; + } + } + &__text.button { flex: 0 1 auto !important; white-space: nowrap !important; @@ -4033,6 +4046,14 @@ body { } /* /lingvo input action */ +/* lingvo-drop-here */ +.lingvo-drop-here { + font-size: 14px !important; + color: #5d54cd; + padding: 0 0 2px 6px; +} +/* /lingvo-drop-here */ + /* lingvo input buttons group */ .lingvo-input-buttons-group { display: flex; @@ -4059,6 +4080,11 @@ body { } } } + + &_drag { + opacity: 0.3 !important; + } + } /* /lingvo input buttons group */