Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix label for root project element. #240

Merged
merged 2 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ export default function CadView({
setupLookupAndParentLinks(rootElt, elementsById)
setDoubleClickListener()
initSearch(model, rootElt)
// The spatial structure doesn't contain properties. NavTree uses
// the callback for onElementSelect in this class to fill out
// details for the rest of the tree items, so just root needs
// special handling.
// TODO(pablo): not sure if this is expected or a problem with the
// IFC API. Could also try to get the initial root elt load to
// use shared logic with setSelectedElement.
const rootProps = await viewer.getProperties(0, rootElt.expressID)
rootElt.Name = rootProps.Name
rootElt.LongName = rootProps.LongName
setRootElement(rootElt)
setShowNavPanel(true)
}
Expand Down Expand Up @@ -342,6 +352,7 @@ export default function CadView({
}
selectItems([id])
const props = await viewer.getProperties(0, elt.expressID)
console.log('props: ', props)
pablo-mayrgundter marked this conversation as resolved.
Show resolved Hide resolved
setSelectedElement(props)

// TODO(pablo): just found out this method is getting called a lot
Expand Down
16 changes: 16 additions & 0 deletions src/utils/Ifc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
deref,
getType,
isTypeValue,
reifyName,
} from './Ifc'


Expand Down Expand Up @@ -71,3 +72,18 @@ test('deref reference typeVal', async () => {
},
}), 0, (e) => e.value)).toEqual(label)
})


test('reifyName with custom name', async () => {
const name = 'Custom Element Name'
const model = new MockModel({})
const elt = {
children: [],
expressID: 1,
Name: {
type: 1,
value: name,
},
}
expect(await reifyName(model, elt)).toBe(name)
})