Skip to content

Commit 787abbb

Browse files
committed
Start each new tab with a new default scenario
1 parent 4dc31e5 commit 787abbb

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

frontend/src/App.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const initialJson = {
3030
weight: 100,
3131
id: "main_tabset",
3232
children: [
33-
{ type: "tab", name: "KFZ-Zulassung Szenario 1", component: "placeholder" }
33+
{ type: "tab", name: "Szenario 1", component: "placeholder" }
3434
]
3535
}
3636
]
@@ -298,17 +298,17 @@ function ScenarioCanvas() {
298298
export default function App() {
299299
const [model] = useState(() => Model.fromJson(initialJson))
300300
const [, setTick] = useState(0)
301-
const nextTabId = useRef(1)
301+
const nextTabId = useRef(2)
302302

303303
useEffect(() => {
304304
const listener = () => setTick(t => t + 1)
305305
model.addChangeListener(listener)
306306
return () => model.removeChangeListener(listener)
307307
}, [model])
308308

309-
const addTab = (name, targetId, location) => {
309+
const addTab = (targetId, location) => {
310310
model.doAction(Actions.addNode(
311-
{type: "tab", component: "placeholder", name: `${name} ${nextTabId.current++}`},
311+
{ type: "tab", component: "placeholder", name: `Szenario ${nextTabId.current++}` },
312312
targetId, location, location === DockLocation.CENTER ? -1 : 0
313313
))
314314
}
@@ -317,7 +317,7 @@ export default function App() {
317317
if (node.getType() !== "tabset") return
318318
renderValues.stickyButtons.push(
319319
<button key="add-button" title="Add New Tab" className="flexlayout__tab_toolbar_button-custom"
320-
onClick={() => addTab("New Tab", node.getId(), DockLocation.CENTER)}>
320+
onClick={() => addTab(node.getId(), DockLocation.CENTER)}>
321321
+
322322
</button>
323323
)
@@ -326,10 +326,7 @@ export default function App() {
326326
const factory = (node) => {
327327
const component = node.getComponent()
328328
if (component === "placeholder") {
329-
if (node.getName() === "KFZ-Zulassung Szenario 1") {
330-
return <ScenarioCanvas />
331-
}
332-
return <div className="placeholder">{node.getName()}</div>
329+
return <ScenarioCanvas />
333330
}
334331
if (component === "menu") {
335332
const activeTabset = model.getActiveTabset()
@@ -339,16 +336,19 @@ export default function App() {
339336
// {activeTabset ? `Target: ${activeTabset.getName() || activeTabset.getId()}` : "Select a tabset first"}
340337
return (
341338
<div>
342-
<button disabled={disabled} onClick={() => addTab("Row Tab", targetId, DockLocation.BOTTOM)}>
339+
<div>Use Case:</div>
340+
<strong>KFZ-Zulassung</strong>
341+
<br/><br/>
342+
<button disabled={disabled} onClick={() => addTab(targetId, DockLocation.BOTTOM)}>
343343
split selected row
344344
</button>
345-
<button disabled={disabled} onClick={() => addTab("Column Tab", targetId, DockLocation.RIGHT)}>
345+
<button disabled={disabled} onClick={() => addTab(targetId, DockLocation.RIGHT)}>
346346
split selected column
347347
</button>
348-
<button onClick={() => addTab("Global Row", rootId, DockLocation.BOTTOM)}>
348+
<button onClick={() => addTab(rootId, DockLocation.BOTTOM)}>
349349
add new row
350350
</button>
351-
<button onClick={() => addTab("Global Column", rootId, DockLocation.RIGHT)}>
351+
<button onClick={() => addTab(rootId, DockLocation.RIGHT)}>
352352
add new column
353353
</button>
354354
</div>

frontend/src/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#root {
22
height: 100%;
3+
font-family: Arial, serif;
34
}
45

56
.placeholder {
6-
font-family: Arial, serif;
77
height: 100%;
88
display: flex;
99
justify-content: center;

0 commit comments

Comments
 (0)