premier noms only et pas de tooltip si pas de nom

This commit is contained in:
Gabriel Dehame 2023-03-06 12:01:05 +01:00
parent 1ab7f7654e
commit a3cf560714

View File

@ -164,19 +164,6 @@ function floorList(connectedFloors, callbackChangeFloor) {
return htmlFloorList;
}
function roomNameList(nameList) {
// Returns under html format a list of room names
// (without bullet points) listed in nameList
// Auxiliary function used when creating a Room component
let htmlNameList = [];
for (const ind in nameList) {
htmlNameList = [...htmlNameList, <div key={ind}>
{nameList[ind]}
</div>];
}
return htmlNameList;
}
function newPolygon(element, positions, selectedRoom, callbackRoomSelected, callbackChangeFloor) {
// Auxiliary function to return the appropriate polygon depending
// on wether it is a room (R), a lift (L), a staircase (S), toilets (T) or corridor (C)
@ -210,14 +197,17 @@ function newPolygon(element, positions, selectedRoom, callbackRoomSelected, call
} else if (element['type'] === 'T') { // Toilets
content = <Toilet position={polygonCenter(positions)} size={logoSize(positions)} />
}
var tooltip = null;
if (element["names"][0] != null) {
tooltip = <Tooltip>{element["names"][0]}</Tooltip>;
}
return <Polygon
positions={positions}
key={element["id"] + color}
color={color}
eventHandlers={{ click: () => callbackRoomSelected(element["id"]) }}
>
<Tooltip>{roomNameList(element["names"])}</Tooltip>
{tooltip}
{content}
</Polygon>
}