diff --git a/src/react/components/common/tagInput/tableTagConfig.scss b/src/react/components/common/tagInput/tableTagConfig.scss index d86bd57c..71dac849 100644 --- a/src/react/components/common/tagInput/tableTagConfig.scss +++ b/src/react/components/common/tagInput/tableTagConfig.scss @@ -78,7 +78,7 @@ } .column_header { min-width: 130px; - background-color: $lighter-4; + background-color: $lighter-3; border: 2px solid grey; text-align: center; padding: .125rem .25rem; @@ -86,14 +86,14 @@ } .row_header { min-width: 130px; - background-color: $lighter-2; + background-color: $lighter-3; border: 2px solid grey; text-align: center; padding: .125rem .5rem; } .empty_header { border: 2px solid grey; - background-color: $lighter-1; + background-color: $lighter-3; } .table-cell { text-align: center; diff --git a/src/react/components/common/tagInput/tableTagConfig.tsx b/src/react/components/common/tagInput/tableTagConfig.tsx index 18d75d62..735f47a6 100644 --- a/src/react/components/common/tagInput/tableTagConfig.tsx +++ b/src/react/components/common/tagInput/tableTagConfig.tsx @@ -5,7 +5,7 @@ import { useSelector } from 'react-redux'; import { Customizer, ICustomizations, ChoiceGroup, IChoiceGroupOption, PrimaryButton, DetailsList, IColumn, TextField, Dropdown, SelectionMode, DetailsListLayoutMode, FontIcon, CheckboxVisibility, IContextualMenuItem, CommandBar, Selection, Separator } from "@fluentui/react"; import { getPrimaryGreyTheme, getPrimaryGreenTheme, getRightPaneDefaultButtonTheme, getGreenWithWhiteBackgroundTheme, getPrimaryBlueTheme, getDefaultTheme } from '../../../../common/themes'; -import { FieldFormat, FieldType, IApplicationState, TagInputMode } from '../../../../models/applicationState'; +import { FieldFormat, FieldType, IApplicationState, ITableTag, TagInputMode } from '../../../../models/applicationState'; import { filterFormat } from "../../../../common/utils"; import { toast } from "react-toastify"; import "./tableTagConfig.scss"; @@ -33,6 +33,8 @@ interface ITableTagConfigProps { setTagInputMode: (addTableMode: TagInputMode) => void; addTableTag: (table: any) => void; splitPaneWidth: number; + tableTag?: ITableTag; + reconfigureTableConfirm?: () => void; } @@ -41,6 +43,7 @@ interface ITableTagConfigState { columns: any[], name: string, format: string, + headerTypeAndFormat: string; } interface ITableConfigItem { name: string, @@ -110,12 +113,22 @@ const typeOptions = () => { export default function TableTagConfig(props: ITableTagConfigProps) { const { setTagInputMode = null, addTableTag = null, splitPaneWidth = null } = props; - const table: ITableTagConfigState = { - name: "", - format: "fixed", - rows: [{ name: "", type: FieldType.String, format: FieldFormat.NotSpecified }], - columns: [{ name: "", type: FieldType.String, format: FieldFormat.NotSpecified }], - }; + let table: ITableTagConfigState; + if (props.tableTag) { + table = { name: props.tableTag.name + " ", + format: "fixed", + rows: props.tableTag.rowKeys.map((row) => {return { name: row.fieldKey, type: row.fieldType, format: row.fieldFormat }}), + columns: props.tableTag.columnKeys.map((col) => {return { name: col.fieldKey, type: col.fieldType, format: col.fieldFormat }}), + headerTypeAndFormat: "columns", + }; + } else { + table = { name: "", + format: "fixed", + rows: [{ name: "", type: FieldType.String, format: FieldFormat.NotSpecified }], + columns: [{ name: "", type: FieldType.String, format: FieldFormat.NotSpecified }], + headerTypeAndFormat: "columns", + }; + } const tags = useSelector((state: IApplicationState) => { return state.currentProject.tags }); @@ -128,6 +141,7 @@ export default function TableTagConfig(props: ITableTagConfigProps) { const [headersFormatAndType, setHeadersFormatAndType] = useState("columns"); const [selectedColumn, setSelectedColumn] = useState(undefined); const [selectedRow, setSelectedRow] = useState(undefined); + const [headerTypeAndFormat, setHeaderTypeAndFormat] = useState(table.headerTypeAndFormat); function selectColumnType(idx: number, type: string) { setColumns(columns.map((col, currIdx) => idx === currIdx ? { ...col, type, format: FieldFormat.NotSpecified } : col @@ -588,7 +602,7 @@ export default function TableTagConfig(props: ITableTagConfigProps) { return (
-

Configure table tag

+

{props.tableTag ? "Reconfigure table tag" : "Configure table tag"}

Name:
-
Format:
- { - setFormat(option.key) - if (option.key === "rowDynamic") { - setHeadersFormatAndType("columns"); + {!props.tableTag && + <> +
Format:
+ { + setFormat(option.key) + if (option.key === "rowDynamic") { + setHeadersFormatAndType("columns"); + } + }} + defaultSelectedKey="fixed" + options={tableFormatOptions} + theme={getRightPaneDefaultButtonTheme()} + /> + {format === "fixed" && <> +
Configure type and format for:
+ setHeadersFormatAndType(option.key)} + required={false} /> + } - }} - defaultSelectedKey="fixed" - options={tableFormatOptions} - theme={getRightPaneDefaultButtonTheme()} - /> - {format === "fixed" && <> -
Configure type and format for:
- setHeadersFormatAndType(option.key)} - required={false} /> - + }
Column headers:
@@ -688,7 +706,7 @@ export default function TableTagConfig(props: ITableTagConfigProps) {
} { - tableChanged && + (tableChanged || props.tableTag) &&
Preview:
@@ -709,8 +727,13 @@ export default function TableTagConfig(props: ITableTagConfigProps) { - validateInputAndSave() + onClick={() => { + if (props.tableTag) { + props.reconfigureTableConfirm(); + } else { + validateInputAndSave() + } + } }>Save
diff --git a/src/react/components/common/tagInput/tableTagLabeling.scss b/src/react/components/common/tagInput/tableTagLabeling.scss index d346bd2a..03625cb8 100644 --- a/src/react/components/common/tagInput/tableTagLabeling.scss +++ b/src/react/components/common/tagInput/tableTagLabeling.scss @@ -18,7 +18,7 @@ .column_header { min-width: 130px; max-width: 200px; - background-color: $lighter-4; + background-color: $lighter-3; border: 2px solid grey; text-align: center; padding: .125rem .25rem; @@ -27,20 +27,29 @@ min-width: 130px; max-width: 200px; border: 2px solid grey; - background-color: $lighter-2; + background-color: $lighter-3; text-align: center; padding: .125rem .5rem; } .empty_header { border: 2px solid grey; - background-color: $lighter-1; + background-color: $lighter-3; } .table-cell { text-align: center; background-color: $darker-3; color: rgba(255, 255, 255, 0.75); + &:hover { + background-color: $lighter-1; + } + &:active { + background-color: $lighter-2; + + } } + + } } .buttons-container { diff --git a/src/react/components/common/tagInput/tableTagLabeling.tsx b/src/react/components/common/tagInput/tableTagLabeling.tsx index 33c8f98c..9036e4d0 100644 --- a/src/react/components/common/tagInput/tableTagLabeling.tsx +++ b/src/react/components/common/tagInput/tableTagLabeling.tsx @@ -61,7 +61,11 @@ export default class TableTagLabeling extends React.Component

{strings.tags.regionTableTags.tableLabeling.title}

- {strings.tags.regionTableTags.tableLabeling.description} + To start labeling your table: +
    +
  1. Select the words on the document you want to label
  2. +
  3. Click the table cell you want to label selected words to
  4. +
@@ -82,8 +86,7 @@ export default class TableTagLabeling extends React.Component { }} - disabled={true} + onClick={() => { this.props.setTagInputMode(TagInputMode.ConfigureTable)}} >{strings.tags.regionTableTags.tableLabeling.buttons.reconfigureTable} @@ -112,7 +115,7 @@ export default class TableTagLabeling extends React.Component); } else { tableRow.push( - ); } diff --git a/src/react/components/common/tagInput/tagInput.tsx b/src/react/components/common/tagInput/tagInput.tsx index fd573398..04780abe 100644 --- a/src/react/components/common/tagInput/tagInput.tsx +++ b/src/react/components/common/tagInput/tagInput.tsx @@ -84,8 +84,9 @@ export interface ITagInputProps { setTagInputMode?: (tagInputMode: TagInputMode) => void; tagInputMode: TagInputMode; - selectedTableTagToLabel: ITag; + selectedTableTagToLabel: ITableTag; handleLabelTable: (tagInputMode: TagInputMode, selectedTableTagToLabel) => void; + reconfigureTableConfirm: () => void; handleTableCellClick: (iTableCellIndex, jTableCellIndex) => void; selectedTableTagBody: ITableRegion[][][]; splitPaneWidth: number; @@ -167,6 +168,8 @@ export class TagInput extends React.Component { setTagInputMode={this.props.setTagInputMode} addTableTag={this.addTableTag} splitPaneWidth={this.props.splitPaneWidth} + tableTag={this.props.selectedTableTagToLabel} + reconfigureTableConfirm={this.props.reconfigureTableConfirm} /> diff --git a/src/react/components/pages/editorPage/editorPage.tsx b/src/react/components/pages/editorPage/editorPage.tsx index 5802a1a0..12882c5f 100644 --- a/src/react/components/pages/editorPage/editorPage.tsx +++ b/src/react/components/pages/editorPage/editorPage.tsx @@ -35,11 +35,12 @@ import { throttle } from "../../../../common/utils"; import { constants } from "../../../../common/constants"; import PreventLeaving from "../../common/preventLeaving/preventLeaving"; import { Spinner, SpinnerSize } from "@fluentui/react/lib/Spinner"; -import { getPrimaryGreenTheme, getPrimaryRedTheme } from "../../../../common/themes"; +import { getPrimaryBlueTheme, getPrimaryGreenTheme, getPrimaryRedTheme } from "../../../../common/themes"; import { toast } from "react-toastify"; import { PredictService } from "../../../../services/predictService"; import { AssetService } from "../../../../services/assetService"; import clone from "rfdc"; +import { Tag } from "reactstrap"; /** * Properties for Editor Page @@ -100,6 +101,7 @@ export interface IEditorPageState { selectedTableTagToLabel: ITableTag; selectedTableTagBody: ITableRegion[][][]; rightSplitPaneWidth?: number; + reconfigureTableConfirm?: boolean; } function mapStateToProps(state: IApplicationState) { @@ -150,6 +152,8 @@ export default class EditorPage extends React.Component void; private deleteTagConfirm: React.RefObject = React.createRef(); private deleteDocumentConfirm: React.RefObject = React.createRef(); + private reconfigTableConfirm: React.RefObject = React.createRef(); + private isUnmount: boolean = false; constructor(props) { @@ -332,6 +336,7 @@ export default class EditorPage extends React.Component } + + {this.setState({tagInputMode: TagInputMode.LabelTable}, () => this.resizeCanvas()); this.resizeCanvas(); }} + /> + @@ -787,6 +801,12 @@ export default class EditorPage extends React.Component { + this.setState({reconfigureTableConfirm: true}) + this.reconfigTableConfirm.current.open(); + + } + private loadProjectAssets = async (): Promise => { if (this.loadingProjectAssets) { return; diff --git a/tslint.json b/tslint.json index 975ad8c7..cdab5226 100644 --- a/tslint.json +++ b/tslint.json @@ -13,7 +13,7 @@ "no-string-literal": false, "no-bitwise": false, "function-constructor": false, - "linebreak-style": [true, "CRLF"] + "linebreak-style": [true, "LF"] }, "rulesDirectory": [] } \ No newline at end of file
this.handleCellClick(i-1, j-1)} key={j}> + this.handleCellClick(i-1, j-1)} key={j}> {this.props.selectedTableTagBody[i-1][j-1]?.map((tableRegion) => tableRegion.value).join(" ")}