Closed birchamp closed 2 years ago
On uw-tsv-parser...
At the end, there are two lines that can be changed to fix things up...
Usage:
Note! the usage below is taken from the master branch.
In tc-create, this parser is used in these places:
src/core/onOpenValidations.js
src/core/contentValidate.js
const datatable = useMemo(() => {
_config.rowHeader = rowHeader;
return (
<DataTable
sourceFile={sourceFile.content}
targetFile={targetFile.content}
onSave={onSave}
onEdit={onEdit}
onValidate={onValidate}
onContentIsDirty={onContentIsDirty}
delimiters={delimiters}
config={_config}
generateRowId={generateRowId}
options={options}
parser={parser}
/>
);
}, [sourceFile.content, targetFile.content, onSave, onEdit, onValidate, onContentIsDirty, generateRowId, options, rowHeader]);
NOTE: the parser is not present in the refactored code
Then in datatable-translatable, it shows first in the properties for
src/components/datatable/DataTable.context.js
export function DataTableContextProvider({
children,
sourceFile,
targetFile,
delimiters,
parser,
config: {
compositeKeyIndices,
columnsFilter,
},
})
Thru out the above file, the existence of the parser is checked for and is used when present. Here is just one example of many:
// parse sourceFile when updated
useEffect(() => {
if (parser && parser.tsvStringToTable) {
console.log("DataTable.context() using tsv parser for source")
const { data: rows } = parser.tsvStringToTable(sourceFile);
setSourceRows(rows);
} else {
if (delimiters) {
const { rows } = parseDataTable({ table: sourceFile, delimiters });
setSourceRows(rows);
}
}
}, [sourceFile, delimiters, parser]);
To update refactored code
Add this import back into TranslatableTSV.js:
import * as parser from 'uw-tsv-parser';
Add this property to <DataTable />
parser={parser}
@mandolyte Just implemented and works like a charm!!! Thanks!!
OBS row header/toolbars now display!
bumped minor version to v1.5.0
Refactor TODOs
Things to prioritize:
IN PROGRESS:
Cypress tests
Other issues noted:
includes SupportReference by default. Default should only be the Note column(will be handled by persistence of column selection)LATER:
Confusing Naming conventions
Console Errors
Borrow, Bend, Break, Begat, Build
Dependency updates
DONE:
Consistent Functional Design patterns
Confusing Naming conventions
KISS: Keep It Stupid Simple
Performance bottleneck:
Shorten files <125 lines to reduce cognitive load
DRY: Don't Repeat Yourself
Bugs to Address
Stepper
Validation
Must use the uw-tsv-parser package to parse TSV files; these cases noted:
The row toolbar is missing.