From 578a482626a73ddb13eb7061cba23ab4e1b06722 Mon Sep 17 00:00:00 2001
From: Weiyi Feng
Date: Thu, 31 Mar 2022 21:57:59 +0800
Subject: [PATCH] configurator: fix displayed scenario path
fix displayed scenario path
Tracked-On: #6691
Signed-off-by: Weiyi Feng
---
.../CreateNewOrImportAnExistingScenario.jsx | 26 ++++++++++++-------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/misc/config_tools/configurator/src/pages/Config/CreateNewOrImportAnExistingScenario/CreateNewOrImportAnExistingScenario.jsx b/misc/config_tools/configurator/src/pages/Config/CreateNewOrImportAnExistingScenario/CreateNewOrImportAnExistingScenario.jsx
index 997b94929..b020ff2c4 100644
--- a/misc/config_tools/configurator/src/pages/Config/CreateNewOrImportAnExistingScenario/CreateNewOrImportAnExistingScenario.jsx
+++ b/misc/config_tools/configurator/src/pages/Config/CreateNewOrImportAnExistingScenario/CreateNewOrImportAnExistingScenario.jsx
@@ -66,15 +66,12 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
let {configurator} = this.context
return configurator.programLayer.loadScenario(this.scenarioXMLSelect.current.value)
.then(() => {
- let printPath = configurator.WorkingFolder;
- if (_.endsWith(configurator.WorkingFolder, "/") || _.endsWith(configurator.WorkingFolder, "\\")) {
- printPath = printPath + 'scenario.xml'
- } else {
- printPath = printPath + (configurator.WorkingFolder[1] === ":" ? "\\" : '/') + 'scenario.xml'
- }
- this.setState({selected: printPath})
+ this.setState({selected: this.getScenarioPath()})
}).then(() => {
- document.querySelectorAll(".accordion-button")[2].click()
+ let tabButton = document.querySelectorAll(".accordion-button")[2];
+ if (tabButton.className.indexOf('collapsed') >= 0) {
+ tabButton.click()
+ }
})
.catch((reason) => {
console.log(reason)
@@ -82,6 +79,17 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
})
};
+ getScenarioPath = () => {
+ let {configurator} = this.context
+ let printPath = configurator.WorkingFolder;
+ if (_.endsWith("/", configurator.WorkingFolder) || _.endsWith("\\", configurator.WorkingFolder)) {
+ printPath = printPath + 'scenario.xml'
+ } else {
+ printPath = printPath + (configurator.WorkingFolder[1] === ":" ? "\\" : '/') + 'scenario.xml'
+ }
+ return printPath;
+ }
+
render = () => {
let {configurator} = this.context
let scenarioHistorySelect = this.state.scenarioConfigFiles.map((optionValue, index) => {
@@ -101,7 +109,7 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
{this.state.selected ? this.state.selected : "none selected"}
{
- this.setState({selected: configurator.WorkingFolder + '/scenario.xml'})
+ this.setState({selected: this.getScenarioPath()})
}}/>