jomarko commented on code in PR #2108:
URL:
https://github.com/apache/incubator-kie-tools/pull/2108#discussion_r1442607281
##########
packages/scesim-editor/src/table/TestScenarioTable.tsx:
##########
@@ -81,11 +88,48 @@ function TestScenarioTable({
const { i18n } = useTestScenarioEditorI18n();
- const tableScrollableElementRef = useRef<{ current: HTMLDivElement | null
}>({ current: null });
+ /** BACKGROUND TABLE MANAGMENT */
- useEffect(() => {
- tableScrollableElementRef.current.current =
document.querySelector(".kie-scesim-editor--table-container") ?? null;
- }, []);
+ const isBackground = useMemo(() => {
+ return "BackgroundData" in tableData.scesimData;
+ }, [tableData]);
+
+ const columnIndexStart = useMemo(() => {
+ return isBackground ? 0 : 1;
+ }, [isBackground]);
+
+ const retrieveRowsData = useCallback(
+ (rowData: SceSim__backgroundDatasType | SceSim__scenariosType) => {
+ if (isBackground) {
+ return (rowData as SceSim__backgroundDatasType).BackgroundData;
+ } else {
+ return (rowData as SceSim__scenariosType).Scenario;
+ }
+ },
+ [isBackground]
+ );
Review Comment:
@yesamer thank you for the PR. Just out of interest, could you please
explain the need of both `SceSim__backgroundDatasType` and
`SceSim__scenariosType`?
They seems to be the same in xsd:
```
<xsd:complexType name="ScenarioType">
<xsd:sequence>
<xsd:element type="factMappingValuesType" name="factMappingValues" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BackgroundDataType">
<xsd:sequence>
<xsd:element type="factMappingValuesType" name="factMappingValues" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="scenariosType">
<xsd:sequence>
<xsd:element type="ScenarioType" name="Scenario" maxOccurs="unbounded"
minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="backgroundDatasType">
<xsd:sequence>
<xsd:element type="BackgroundDataType" name="BackgroundData"
maxOccurs="unbounded"
minOccurs="0" />
</xsd:sequence>
```
And most of the code (pseudocode) seems to use `isbackground` that is
implemented without the need of `SceSim__backgroundDatasType` or
`SceSim__scenariosType`.
I mean we do most the time:
```
if (isBackground) {
// do something
}
```
We do not do:
```
if (is SceSim__backgroundDatasType) {do sth}
else if (is SceSim__scenariosType) {do sth else}
```
Just trying to understand code better. I am not saying the current version
is wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]