diff options
author | Anton Tananaev <anton@traccar.org> | 2022-09-07 18:13:05 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-09-07 18:13:05 -0700 |
commit | 53567243ea2bdda876c9dfa9d1a8ac8e64e5feaa (patch) | |
tree | 27accdade454c1cdf0fdb02280bdead884d5bfdb /modern | |
parent | 6691ae65db37165fe61fd14ec8047052bf10ccae (diff) | |
download | trackermap-web-53567243ea2bdda876c9dfa9d1a8ac8e64e5feaa.tar.gz trackermap-web-53567243ea2bdda876c9dfa9d1a8ac8e64e5feaa.tar.bz2 trackermap-web-53567243ea2bdda876c9dfa9d1a8ac8e64e5feaa.zip |
Fix group filtering (fix #1026)
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/main/MainPage.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js index 2d0671ae..3669dd50 100644 --- a/modern/src/main/MainPage.js +++ b/modern/src/main/MainPage.js @@ -191,10 +191,20 @@ const MainPage = () => { dispatch(devicesActions.select(deviceId)); }, [dispatch]); + const deviceGroups = (device) => { + const groupIds = []; + let { groupId } = device; + while (groupId) { + groupIds.push(groupId); + groupId = groups[groupId].groupId; + } + return groupIds; + }; + useEffect(() => { const filtered = Object.values(devices) .filter((device) => !filterStatuses.length || filterStatuses.includes(device.status)) - .filter((device) => !filterGroups.length || filterGroups.includes(device.groupId)) + .filter((device) => !filterGroups.length || deviceGroups(device).some((id) => filterGroups.includes(id))) .filter((device) => { const keyword = filterKeyword.toLowerCase(); return [device.name, device.uniqueId, device.phone, device.model, device.contact].some((s) => s && s.toLowerCase().includes(keyword)); |