@trackunit/filters-asset-filter-definitions 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +127 -177
- package/index.esm.js +127 -177
- package/package.json +11 -11
package/index.cjs.js
CHANGED
|
@@ -1627,7 +1627,6 @@ const mapActivityToLabelId = (state) => {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
};
|
|
1629
1629
|
const ActivityFiltersView = ({ filterBarActions, filterDefinition, filterState, value, setValue, }) => {
|
|
1630
|
-
var _a;
|
|
1631
1630
|
const [t] = useTranslation();
|
|
1632
1631
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(filterState.values);
|
|
1633
1632
|
const { data, loading } = client.useQuery(GetFleetActivitySummaryDocument, {
|
|
@@ -1639,30 +1638,30 @@ const ActivityFiltersView = ({ filterBarActions, filterDefinition, filterState,
|
|
|
1639
1638
|
},
|
|
1640
1639
|
},
|
|
1641
1640
|
});
|
|
1642
|
-
const activity =
|
|
1641
|
+
const activity = data?.assetSummary?.activity;
|
|
1643
1642
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { filterBarActions: filterBarActions, filterDefinition: filterDefinition, filterState: filterState, loading: loading, options: [
|
|
1644
1643
|
{
|
|
1645
1644
|
key: exports.AssetActivityState.Working,
|
|
1646
1645
|
label: t("assetFilters.activityFilter.working"),
|
|
1647
|
-
count: activity
|
|
1646
|
+
count: activity?.working,
|
|
1648
1647
|
prefix: jsxRuntime.jsx(utilizationIndicator.ActivityIndicator, { state: exports.AssetActivityState.Working, withBackground: false, withLabel: false }),
|
|
1649
1648
|
},
|
|
1650
1649
|
{
|
|
1651
1650
|
key: exports.AssetActivityState.Idling,
|
|
1652
1651
|
label: t("assetFilters.activityFilter.idling"),
|
|
1653
|
-
count: activity
|
|
1652
|
+
count: activity?.idling,
|
|
1654
1653
|
prefix: jsxRuntime.jsx(utilizationIndicator.ActivityIndicator, { state: exports.AssetActivityState.Idling, withBackground: false, withLabel: false }),
|
|
1655
1654
|
},
|
|
1656
1655
|
{
|
|
1657
1656
|
key: exports.AssetActivityState.Stopped,
|
|
1658
1657
|
label: t("assetFilters.activityFilter.stopped"),
|
|
1659
|
-
count: activity
|
|
1658
|
+
count: activity?.stopped,
|
|
1660
1659
|
prefix: jsxRuntime.jsx(utilizationIndicator.ActivityIndicator, { state: exports.AssetActivityState.Stopped, withBackground: false, withLabel: false }),
|
|
1661
1660
|
},
|
|
1662
1661
|
{
|
|
1663
1662
|
key: exports.AssetActivityState.Unknown,
|
|
1664
1663
|
label: t("assetFilters.activityFilter.unknown"),
|
|
1665
|
-
count: activity
|
|
1664
|
+
count: activity?.unknown,
|
|
1666
1665
|
prefix: jsxRuntime.jsx(utilizationIndicator.ActivityIndicator, { state: exports.AssetActivityState.Unknown, withBackground: false, withLabel: false }),
|
|
1667
1666
|
},
|
|
1668
1667
|
], setValue: setValue, value: value }));
|
|
@@ -1747,19 +1746,18 @@ const useAreaSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY, m
|
|
|
1747
1746
|
variables: { search: debouncedSearchString },
|
|
1748
1747
|
skip: !debouncedSearchString || searchString.replace(/\s/g, "").length < MIN_LENGTH_SEARCH,
|
|
1749
1748
|
});
|
|
1750
|
-
const stableData = react.useMemo(() => data
|
|
1749
|
+
const stableData = react.useMemo(() => data ?? previousData, [data, previousData]);
|
|
1751
1750
|
const loadedAreas = react.useMemo(() => {
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
var _a, _b;
|
|
1751
|
+
return (stableData?.findPlaces
|
|
1752
|
+
?.map(place => {
|
|
1755
1753
|
const parsedBbox = geoJsonUtils.geoJsonBboxSchema.safeParse(place.bbox);
|
|
1756
|
-
const parsedGeometry = areaFilterInternalGeoJsonGeometrySchema.safeParse(
|
|
1754
|
+
const parsedGeometry = areaFilterInternalGeoJsonGeometrySchema.safeParse(place.geometry?.type
|
|
1757
1755
|
? {
|
|
1758
1756
|
type: stringTs.titleCase(place.geometry.type),
|
|
1759
1757
|
coordinates: place.geometry.coordinates,
|
|
1760
1758
|
}
|
|
1761
1759
|
: undefined);
|
|
1762
|
-
if (!parsedGeometry.success || !parsedBbox.success || !
|
|
1760
|
+
if (!parsedGeometry.success || !parsedBbox.success || !place.properties?.formattedAddress) {
|
|
1763
1761
|
return null;
|
|
1764
1762
|
}
|
|
1765
1763
|
return {
|
|
@@ -1767,7 +1765,8 @@ const useAreaSearch = ({ localStorageKey = SHARED_LOCATIONS_LOCAL_STORAGE_KEY, m
|
|
|
1767
1765
|
geometry: parsedGeometry.data,
|
|
1768
1766
|
properties: { formattedAddress: place.properties.formattedAddress },
|
|
1769
1767
|
};
|
|
1770
|
-
})
|
|
1768
|
+
})
|
|
1769
|
+
.filter(sharedUtils.nonNullable) ?? []);
|
|
1771
1770
|
}, [stableData]);
|
|
1772
1771
|
const areas = debouncedSearchString ? loadedAreas : recentAreas;
|
|
1773
1772
|
const hint = react.useMemo(() => {
|
|
@@ -1855,40 +1854,39 @@ const AreaView = (props) => {
|
|
|
1855
1854
|
// Aka if applied from outside the filter UI
|
|
1856
1855
|
...(placeholderOption && !selectedOption && !props.debouncedSearchString ? [placeholderOption] : []),
|
|
1857
1856
|
...props.areas,
|
|
1858
|
-
], children: filterResult => {
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
} })) : (jsxRuntime.jsx("p", { className: "py-2 text-center text-sm text-gray-400", children: props.hint })) }), props.debouncedSearchString.length === 0 ? (jsxRuntime.jsx(RecentSearchesFooter, { count: props.recentAreas.length, onClearAll: () => props.setRecentAreas([]) })) : null] }));
|
|
1857
|
+
], children: filterResult => (jsxRuntime.jsx(reactFormComponents.RadioGroup, { className: "m-1", id: "areaFilter", onChange: e => {
|
|
1858
|
+
const parsedResultLookup = areaFilterInternalSchema.safeParse(filterResult.find(result => result.properties.formattedAddress === e.currentTarget.value));
|
|
1859
|
+
if (!parsedResultLookup.success) {
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
const { properties, bBox, geometry, dateIsoString } = parsedResultLookup.data;
|
|
1863
|
+
logEvent("Filters Applied - V2", {
|
|
1864
|
+
type: "AreaFilter",
|
|
1865
|
+
value: properties.formattedAddress,
|
|
1866
|
+
additionalProperties: {
|
|
1867
|
+
geometryType: geometry.type,
|
|
1868
|
+
wasPreviousSearch: Boolean(dateIsoString),
|
|
1869
|
+
},
|
|
1870
|
+
});
|
|
1871
|
+
props.addRecentArea(parsedResultLookup.data);
|
|
1872
|
+
if (geometry.type === "Polygon") {
|
|
1873
|
+
// Polygons are stored directly
|
|
1874
|
+
props.filterBarActions.setArea(geometry);
|
|
1875
|
+
}
|
|
1876
|
+
else {
|
|
1877
|
+
// All other geometries are stored by the filter as a
|
|
1878
|
+
// polygon derived from the features bbox
|
|
1879
|
+
props.filterBarActions.setArea(geoJsonUtils.getPolygonFromBbox(bBox));
|
|
1880
|
+
}
|
|
1881
|
+
props.setSearchString(""); // Clear search input after selection
|
|
1882
|
+
}, value: selectedOption?.properties.formattedAddress ??
|
|
1883
|
+
placeholderOption?.properties.formattedAddress ?? // placeholder if no selected option
|
|
1884
|
+
"", children: filterResult.map(({ properties, dateIsoString }, index) => {
|
|
1885
|
+
const selected = selectedOption?.properties.formattedAddress === properties.formattedAddress;
|
|
1886
|
+
return (jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { label: properties.formattedAddress, selected: selected, suffix:
|
|
1887
|
+
// Only show clear button if not currently selected and previously searched
|
|
1888
|
+
!selected && dateIsoString ? (jsxRuntime.jsx(ClearItemButton, { onClick: () => props.setRecentAreas(prev => prev.filter(r => r.properties.formattedAddress !== properties.formattedAddress)) })) : null, value: properties.formattedAddress }, index));
|
|
1889
|
+
}) })) })) : (jsxRuntime.jsx("p", { className: "py-2 text-center text-sm text-gray-400", children: props.hint })) }), props.debouncedSearchString.length === 0 ? (jsxRuntime.jsx(RecentSearchesFooter, { count: props.recentAreas.length, onClearAll: () => props.setRecentAreas([]) })) : null] }));
|
|
1892
1890
|
};
|
|
1893
1891
|
/**
|
|
1894
1892
|
* Area filter definition
|
|
@@ -1912,10 +1910,9 @@ const useAreaFilter = ({ showWithSearch } = {
|
|
|
1912
1910
|
showInStarredMenu: () => showWithSearch(),
|
|
1913
1911
|
showInFilterBar: () => showWithSearch(),
|
|
1914
1912
|
valueAsText: value => {
|
|
1915
|
-
var _a;
|
|
1916
1913
|
const nameOfSelectedArea = getSelectedOption(value, areaSearch.recentAreas);
|
|
1917
1914
|
return showWithSearch()
|
|
1918
|
-
? (
|
|
1915
|
+
? (nameOfSelectedArea?.properties.formattedAddress ?? t("assetFilters.area.active"))
|
|
1919
1916
|
: t("assetFilters.boundingBoxFilter.value");
|
|
1920
1917
|
},
|
|
1921
1918
|
component: props => jsxRuntime.jsx(AreaView, { ...props, ...areaSearch, showWithSearch: showWithSearch() }),
|
|
@@ -1927,12 +1924,12 @@ const getSelectedOption = (value, options) => {
|
|
|
1927
1924
|
return options.find(option => {
|
|
1928
1925
|
// Polygons are compared by their coordinates directly
|
|
1929
1926
|
if (option.geometry.type === "Polygon" || option.geometry.type === "MultiPolygon") {
|
|
1930
|
-
return JSON.stringify(option.geometry.coordinates) === JSON.stringify(value
|
|
1927
|
+
return JSON.stringify(option.geometry.coordinates) === JSON.stringify(value?.coordinates);
|
|
1931
1928
|
}
|
|
1932
1929
|
// All other geometries are stored by the filter as a
|
|
1933
1930
|
// polygon derived from the features bbox
|
|
1934
1931
|
// therefore we need to compare by that here to reverse the conversion
|
|
1935
|
-
return JSON.stringify(geoJsonUtils.getPolygonFromBbox(option.bBox).coordinates) === JSON.stringify(value
|
|
1932
|
+
return JSON.stringify(geoJsonUtils.getPolygonFromBbox(option.bBox).coordinates) === JSON.stringify(value?.coordinates);
|
|
1936
1933
|
});
|
|
1937
1934
|
};
|
|
1938
1935
|
|
|
@@ -1972,7 +1969,6 @@ const assetTypeConst = {
|
|
|
1972
1969
|
};
|
|
1973
1970
|
const ALL_TYPES = sharedUtils.objectValues(assetTypeConst);
|
|
1974
1971
|
const AssetTypesFilterView = (props) => {
|
|
1975
|
-
var _a, _b;
|
|
1976
1972
|
const [t] = useTranslation();
|
|
1977
1973
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
1978
1974
|
const { data, loading } = client.useQuery(GetFleetAssetTypesSummaryDocument, {
|
|
@@ -1985,8 +1981,7 @@ const AssetTypesFilterView = (props) => {
|
|
|
1985
1981
|
},
|
|
1986
1982
|
});
|
|
1987
1983
|
const getCountForAssetType = react.useCallback((assetType) => {
|
|
1988
|
-
|
|
1989
|
-
const assetTypes = (_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.assetTypes) === null || _b === void 0 ? void 0 : _b.summary;
|
|
1984
|
+
const assetTypes = data?.assetSummary?.assetTypes?.summary;
|
|
1990
1985
|
switch (assetType) {
|
|
1991
1986
|
case "ATTACHMENT":
|
|
1992
1987
|
case "EQUIPMENT":
|
|
@@ -1995,11 +1990,11 @@ const AssetTypesFilterView = (props) => {
|
|
|
1995
1990
|
case "OTHER":
|
|
1996
1991
|
case "TOOL":
|
|
1997
1992
|
case "VEHICLE":
|
|
1998
|
-
return assetTypes
|
|
1993
|
+
return assetTypes?.[`${stringTs.lowerCase(assetType)}s`];
|
|
1999
1994
|
default:
|
|
2000
1995
|
throw new Error(`${assetType} is not known`);
|
|
2001
1996
|
}
|
|
2002
|
-
}, [
|
|
1997
|
+
}, [data?.assetSummary?.assetTypes?.summary]);
|
|
2003
1998
|
const options = react.useMemo(() => {
|
|
2004
1999
|
return props.showTypes
|
|
2005
2000
|
.map(type => ({
|
|
@@ -2034,7 +2029,6 @@ const useAssetTypeFilter = ({ showTypes } = { showTypes: ALL_TYPES }) => {
|
|
|
2034
2029
|
|
|
2035
2030
|
const FETCH_LIMIT$8 = 1000;
|
|
2036
2031
|
const BrandFilterView = (props) => {
|
|
2037
|
-
var _a, _b;
|
|
2038
2032
|
const { getMachineTypeTranslation } = translationsMachineType.useMachineTypeTranslations();
|
|
2039
2033
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2040
2034
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
@@ -2052,15 +2046,14 @@ const BrandFilterView = (props) => {
|
|
|
2052
2046
|
},
|
|
2053
2047
|
});
|
|
2054
2048
|
const options = react.useMemo(() => {
|
|
2055
|
-
|
|
2056
|
-
const result = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.brands) === null || _b === void 0 ? void 0 : _b.summary.map(brand => ({
|
|
2049
|
+
const result = data?.assetSummary?.brands?.summary.map(brand => ({
|
|
2057
2050
|
key: brand.key,
|
|
2058
2051
|
count: brand.count,
|
|
2059
2052
|
label: getMachineTypeTranslation(brand.key),
|
|
2060
|
-
}))
|
|
2053
|
+
})) ?? [];
|
|
2061
2054
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$8);
|
|
2062
2055
|
return result;
|
|
2063
|
-
}, [
|
|
2056
|
+
}, [data?.assetSummary?.brands?.summary, getMachineTypeTranslation]);
|
|
2064
2057
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2065
2058
|
};
|
|
2066
2059
|
/**
|
|
@@ -2106,7 +2099,6 @@ const mapCriticalityToLabelId = (state) => {
|
|
|
2106
2099
|
* @returns {StringArrayFilterDefinition} Criticality filter definition
|
|
2107
2100
|
*/
|
|
2108
2101
|
const CriticalityFiltersView = (props) => {
|
|
2109
|
-
var _a;
|
|
2110
2102
|
const [t] = useTranslation();
|
|
2111
2103
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2112
2104
|
const { data, loading } = client.useQuery(GetFleetCriticalitySummaryDocument, {
|
|
@@ -2118,24 +2110,24 @@ const CriticalityFiltersView = (props) => {
|
|
|
2118
2110
|
},
|
|
2119
2111
|
},
|
|
2120
2112
|
});
|
|
2121
|
-
const criticality =
|
|
2113
|
+
const criticality = data?.assetSummary?.criticality;
|
|
2122
2114
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, loading: loading, options: [
|
|
2123
2115
|
{
|
|
2124
2116
|
key: assetCriticalityState.CRITICAL,
|
|
2125
2117
|
label: t(mapCriticalityToLabelId(assetCriticalityState.CRITICAL)),
|
|
2126
|
-
count: criticality
|
|
2118
|
+
count: criticality?.critical,
|
|
2127
2119
|
prefix: (jsxRuntime.jsx(criticalityIndicator.CriticalityIndicator, { state: assetCriticalityState.CRITICAL, withBackground: false, withLabel: false })),
|
|
2128
2120
|
},
|
|
2129
2121
|
{
|
|
2130
2122
|
key: assetCriticalityState.LOW,
|
|
2131
2123
|
label: t(mapCriticalityToLabelId(assetCriticalityState.LOW)),
|
|
2132
|
-
count: criticality
|
|
2124
|
+
count: criticality?.low,
|
|
2133
2125
|
prefix: jsxRuntime.jsx(criticalityIndicator.CriticalityIndicator, { state: assetCriticalityState.LOW, withBackground: false, withLabel: false }),
|
|
2134
2126
|
},
|
|
2135
2127
|
{
|
|
2136
2128
|
key: assetCriticalityState.NONE,
|
|
2137
2129
|
label: t(mapCriticalityToLabelId(assetCriticalityState.NONE)),
|
|
2138
|
-
count: criticality
|
|
2130
|
+
count: criticality?.good,
|
|
2139
2131
|
prefix: jsxRuntime.jsx(criticalityIndicator.CriticalityIndicator, { state: assetCriticalityState.NONE, withBackground: false, withLabel: false }),
|
|
2140
2132
|
},
|
|
2141
2133
|
] }));
|
|
@@ -2163,7 +2155,6 @@ const useCriticalityFilter = () => {
|
|
|
2163
2155
|
|
|
2164
2156
|
const FETCH_LIMIT$7 = 1000;
|
|
2165
2157
|
const CustomerIdsFilterView = (props) => {
|
|
2166
|
-
var _a, _b;
|
|
2167
2158
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2168
2159
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
2169
2160
|
const [searchText, setSearchText] = react.useState("");
|
|
@@ -2180,18 +2171,14 @@ const CustomerIdsFilterView = (props) => {
|
|
|
2180
2171
|
},
|
|
2181
2172
|
});
|
|
2182
2173
|
const options = react.useMemo(() => {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
count: customerEdge.count || 0,
|
|
2189
|
-
label: ((_b = customerEdge.customer) === null || _b === void 0 ? void 0 : _b.name) || "Unknown",
|
|
2190
|
-
});
|
|
2191
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
2174
|
+
const result = data?.assetSummary?.customers?.summary.map(customerEdge => ({
|
|
2175
|
+
key: customerEdge.customer?.customerId || "unknown",
|
|
2176
|
+
count: customerEdge.count || 0,
|
|
2177
|
+
label: customerEdge.customer?.name || "Unknown",
|
|
2178
|
+
})) ?? [];
|
|
2192
2179
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$7);
|
|
2193
2180
|
return result;
|
|
2194
|
-
}, [
|
|
2181
|
+
}, [data?.assetSummary?.customers?.summary]);
|
|
2195
2182
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2196
2183
|
};
|
|
2197
2184
|
/**
|
|
@@ -2219,7 +2206,6 @@ const useCustomerIdsFilter = ({ showInStarredMenu, showInFilterBar, defaultValue
|
|
|
2219
2206
|
};
|
|
2220
2207
|
|
|
2221
2208
|
const FollowedFiltersView = (props) => {
|
|
2222
|
-
var _a;
|
|
2223
2209
|
const [t] = useTranslation();
|
|
2224
2210
|
const { logEvent } = reactCoreHooks.useAnalytics(filtersFilterBar.FilterEvents);
|
|
2225
2211
|
const handleChange = (newValue) => {
|
|
@@ -2229,7 +2215,7 @@ const FollowedFiltersView = (props) => {
|
|
|
2229
2215
|
});
|
|
2230
2216
|
props.setValue(prev => newValue);
|
|
2231
2217
|
};
|
|
2232
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "followed", label: "", onChange: e => handleChange(e.currentTarget.value), value:
|
|
2218
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "followed", label: "", onChange: e => handleChange(e.currentTarget.value), value: props.value ?? "ALL", children: [jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("filtersBar.defaultAssetFilters.followedFilter.allLabel"), value: "ALL" }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("filtersBar.defaultAssetFilters.followedFilter.followedOnlyLabel"), value: "FOLLOWED" })] }) })] }));
|
|
2233
2219
|
};
|
|
2234
2220
|
/**
|
|
2235
2221
|
*
|
|
@@ -2259,7 +2245,6 @@ const useFollowedFilter = () => {
|
|
|
2259
2245
|
|
|
2260
2246
|
const FETCH_LIMIT$6 = 1000;
|
|
2261
2247
|
const GroupIdsFilterView = (props) => {
|
|
2262
|
-
var _a;
|
|
2263
2248
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2264
2249
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
2265
2250
|
const [searchText, setSearchText] = react.useState("");
|
|
@@ -2276,17 +2261,13 @@ const GroupIdsFilterView = (props) => {
|
|
|
2276
2261
|
},
|
|
2277
2262
|
});
|
|
2278
2263
|
const options = react.useMemo(() => {
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
count: edge.count || 0,
|
|
2285
|
-
label: ((_b = edge.group) === null || _b === void 0 ? void 0 : _b.name) || "Unknown",
|
|
2286
|
-
});
|
|
2287
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
2264
|
+
const result = data?.assetSummary?.groups?.summary.map(edge => ({
|
|
2265
|
+
key: edge.group?.groupId || "unknown",
|
|
2266
|
+
count: edge.count || 0,
|
|
2267
|
+
label: edge.group?.name || "Unknown",
|
|
2268
|
+
})) ?? [];
|
|
2288
2269
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$6);
|
|
2289
|
-
if (
|
|
2270
|
+
if (data?.assetSummary?.groups?.missing && data.assetSummary.groups.missing > 0) {
|
|
2290
2271
|
result.push({
|
|
2291
2272
|
key: "UNDEFINED",
|
|
2292
2273
|
count: data.assetSummary.groups.missing,
|
|
@@ -2294,7 +2275,7 @@ const GroupIdsFilterView = (props) => {
|
|
|
2294
2275
|
});
|
|
2295
2276
|
}
|
|
2296
2277
|
return result;
|
|
2297
|
-
}, [
|
|
2278
|
+
}, [data?.assetSummary?.groups]);
|
|
2298
2279
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2299
2280
|
};
|
|
2300
2281
|
/**
|
|
@@ -2353,7 +2334,6 @@ exports.AssetLastSeen = void 0;
|
|
|
2353
2334
|
AssetLastSeen["OlderThan_30Days"] = "OLDER_THAN_30_DAYS";
|
|
2354
2335
|
})(exports.AssetLastSeen || (exports.AssetLastSeen = {}));
|
|
2355
2336
|
const LastSeenFiltersView = (props) => {
|
|
2356
|
-
var _a;
|
|
2357
2337
|
const [t] = useTranslation();
|
|
2358
2338
|
const { logEvent } = reactCoreHooks.useAnalytics(filtersFilterBar.FilterEvents);
|
|
2359
2339
|
const handleChange = (value) => {
|
|
@@ -2363,7 +2343,7 @@ const LastSeenFiltersView = (props) => {
|
|
|
2363
2343
|
});
|
|
2364
2344
|
props.setValue(prev => value);
|
|
2365
2345
|
};
|
|
2366
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "lastSeen", label: "", onChange: val => handleChange(val.currentTarget.value), value:
|
|
2346
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "lastSeen", label: "", onChange: val => handleChange(val.currentTarget.value), value: props.value ?? "ALL", children: [jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.anytime"), value: "ALL" }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.lastHour"), value: exports.AssetLastSeen.LastHour }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.last24Hours"), value: exports.AssetLastSeen.Last_24Hours }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.last7Days"), value: exports.AssetLastSeen.Last_7Days }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.last30Days"), value: exports.AssetLastSeen.Last_30Days }), jsxRuntime.jsx(reactFormComponents.RadioItem, { label: t("assetFilters.lastSeenFilter.olderThan30Days"), value: exports.AssetLastSeen.OlderThan_30Days })] }) })] }));
|
|
2367
2347
|
};
|
|
2368
2348
|
/**
|
|
2369
2349
|
*
|
|
@@ -2427,7 +2407,6 @@ const mapMetadataCompletenessToLabelId = (type) => {
|
|
|
2427
2407
|
}
|
|
2428
2408
|
};
|
|
2429
2409
|
const MetadataCompletenessFilterView = (props) => {
|
|
2430
|
-
var _a, _b, _c, _d;
|
|
2431
2410
|
const [t] = useTranslation();
|
|
2432
2411
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2433
2412
|
const { data, loading } = client.useQuery(GetMetadataCompletenessSummaryDocument, {
|
|
@@ -2439,28 +2418,24 @@ const MetadataCompletenessFilterView = (props) => {
|
|
|
2439
2418
|
},
|
|
2440
2419
|
});
|
|
2441
2420
|
const getCountForMetadataCompleteness = react.useCallback((type) => {
|
|
2442
|
-
|
|
2443
|
-
const summary = ((_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.metadataCompletenesses) === null || _b === void 0 ? void 0 : _b.summary) || [];
|
|
2421
|
+
const summary = data?.assetSummary?.metadataCompletenesses?.summary || [];
|
|
2444
2422
|
switch (type) {
|
|
2445
2423
|
case "COMPLETE":
|
|
2446
|
-
return
|
|
2424
|
+
return summary.find(item => item.metadataCompleteness === "COMPLETE")?.count || 0;
|
|
2447
2425
|
case "PARTIAL":
|
|
2448
|
-
return
|
|
2426
|
+
return summary.find(item => item.metadataCompleteness === "PARTIAL")?.count || 0;
|
|
2449
2427
|
case "ALL":
|
|
2450
|
-
return
|
|
2428
|
+
return data?.assetSummary?.metadataCompletenesses?.total;
|
|
2451
2429
|
default:
|
|
2452
2430
|
throw new Error("Unrecognized metadataCompleteness type");
|
|
2453
2431
|
}
|
|
2454
|
-
}, [
|
|
2432
|
+
}, [data?.assetSummary?.metadataCompletenesses?.summary, data?.assetSummary?.metadataCompletenesses?.total]);
|
|
2455
2433
|
const options = react.useMemo(() => {
|
|
2456
|
-
return metadataCompletenessOptions.map(type => {
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
label: t(mapMetadataCompletenessToLabelId(type)),
|
|
2462
|
-
});
|
|
2463
|
-
});
|
|
2434
|
+
return metadataCompletenessOptions.map(type => ({
|
|
2435
|
+
key: type,
|
|
2436
|
+
count: getCountForMetadataCompleteness(type) ?? undefined,
|
|
2437
|
+
label: t(mapMetadataCompletenessToLabelId(type)),
|
|
2438
|
+
}));
|
|
2464
2439
|
}, [getCountForMetadataCompleteness, t]);
|
|
2465
2440
|
return jsxRuntime.jsx(filtersFilterBar.DefaultRadioFilter, { ...props, loading: loading, options: options });
|
|
2466
2441
|
};
|
|
@@ -2485,7 +2460,6 @@ const useMetadataCompletenessFilter = ({ isDefault } = {}) => {
|
|
|
2485
2460
|
|
|
2486
2461
|
const FETCH_LIMIT$5 = 1000;
|
|
2487
2462
|
const ModelsFilterView = (props) => {
|
|
2488
|
-
var _a, _b;
|
|
2489
2463
|
const { getMachineTypeTranslation } = translationsMachineType.useMachineTypeTranslations();
|
|
2490
2464
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2491
2465
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
@@ -2503,15 +2477,14 @@ const ModelsFilterView = (props) => {
|
|
|
2503
2477
|
},
|
|
2504
2478
|
});
|
|
2505
2479
|
const options = react.useMemo(() => {
|
|
2506
|
-
|
|
2507
|
-
const result = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.models) === null || _b === void 0 ? void 0 : _b.summary.map(model => ({
|
|
2480
|
+
const result = data?.assetSummary?.models?.summary.map(model => ({
|
|
2508
2481
|
key: model.key,
|
|
2509
2482
|
count: model.count,
|
|
2510
2483
|
label: getMachineTypeTranslation(model.key),
|
|
2511
|
-
}))
|
|
2484
|
+
})) ?? [];
|
|
2512
2485
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$5);
|
|
2513
2486
|
return result;
|
|
2514
|
-
}, [
|
|
2487
|
+
}, [data?.assetSummary?.models?.summary, getMachineTypeTranslation]);
|
|
2515
2488
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2516
2489
|
};
|
|
2517
2490
|
/**
|
|
@@ -2538,7 +2511,6 @@ const useModelsFilter = () => {
|
|
|
2538
2511
|
|
|
2539
2512
|
const FETCH_LIMIT$4 = 1000;
|
|
2540
2513
|
const OwnerAccountIdsFilterView = (props) => {
|
|
2541
|
-
var _a, _b;
|
|
2542
2514
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2543
2515
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
2544
2516
|
const [searchText, setSearchText] = react.useState("");
|
|
@@ -2555,18 +2527,14 @@ const OwnerAccountIdsFilterView = (props) => {
|
|
|
2555
2527
|
},
|
|
2556
2528
|
});
|
|
2557
2529
|
const options = react.useMemo(() => {
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
count: edge.count || 0,
|
|
2564
|
-
label: ((_b = edge.ownerAccount) === null || _b === void 0 ? void 0 : _b.name) || "Unknown",
|
|
2565
|
-
});
|
|
2566
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
2530
|
+
const result = data?.assetSummary?.ownerAccounts?.summary.map(edge => ({
|
|
2531
|
+
key: edge.ownerAccount?.accountId || "unknown",
|
|
2532
|
+
count: edge.count || 0,
|
|
2533
|
+
label: edge.ownerAccount?.name || "Unknown",
|
|
2534
|
+
})) ?? [];
|
|
2567
2535
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$4);
|
|
2568
2536
|
return result;
|
|
2569
|
-
}, [
|
|
2537
|
+
}, [data?.assetSummary?.ownerAccounts?.summary]);
|
|
2570
2538
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2571
2539
|
};
|
|
2572
2540
|
/**
|
|
@@ -2641,7 +2609,6 @@ const usePeriodFilter = () => {
|
|
|
2641
2609
|
|
|
2642
2610
|
const FETCH_LIMIT$3 = 1000;
|
|
2643
2611
|
const ProductionYearFilterView = ({ filterDefinition, filterState, filterBarActions, ...props }) => {
|
|
2644
|
-
var _a, _b;
|
|
2645
2612
|
const [t] = useTranslation();
|
|
2646
2613
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(filterState.values);
|
|
2647
2614
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
@@ -2659,14 +2626,13 @@ const ProductionYearFilterView = ({ filterDefinition, filterState, filterBarActi
|
|
|
2659
2626
|
fetchPolicy: "cache-first",
|
|
2660
2627
|
});
|
|
2661
2628
|
const options = react.useMemo(() => {
|
|
2662
|
-
|
|
2663
|
-
const result = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.productionYears) === null || _b === void 0 ? void 0 : _b.summary.map(productionYear => ({
|
|
2629
|
+
const result = data?.assetSummary?.productionYears?.summary.map(productionYear => ({
|
|
2664
2630
|
...productionYear,
|
|
2665
2631
|
label: productionYear.key.toUpperCase() === "UNDEFINED" ? t(`machine.types.Unknown`) : productionYear.key,
|
|
2666
|
-
}))
|
|
2632
|
+
})) ?? [];
|
|
2667
2633
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$3);
|
|
2668
2634
|
return result;
|
|
2669
|
-
}, [
|
|
2635
|
+
}, [data?.assetSummary?.productionYears?.summary, t]);
|
|
2670
2636
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, filterBarActions: filterBarActions, filterDefinition: filterDefinition, filterState: filterState, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2671
2637
|
};
|
|
2672
2638
|
/**
|
|
@@ -2698,8 +2664,8 @@ const SearchFilterInline = ({ filterBarActions, filterState, filterDefinition, l
|
|
|
2698
2664
|
const [t] = useTranslation();
|
|
2699
2665
|
const searchElementRef = react.useRef(null);
|
|
2700
2666
|
const geometry = reactComponents.useGeometry(searchElementRef);
|
|
2701
|
-
const filterValue =
|
|
2702
|
-
const [searchString, setSearchString] = react.useState(filterValue
|
|
2667
|
+
const filterValue = filterDefinition?.filterKey ? String(filterState.values[filterDefinition.filterKey]) : undefined;
|
|
2668
|
+
const [searchString, setSearchString] = react.useState(filterValue ?? "");
|
|
2703
2669
|
const previousFilterValue = reactCoreHooks.usePrevious(filterValue);
|
|
2704
2670
|
reactComponents.useDebounce(searchString, 500, "both", debouncedSearchString => {
|
|
2705
2671
|
if (filterValue === debouncedSearchString) {
|
|
@@ -2716,7 +2682,7 @@ const SearchFilterInline = ({ filterBarActions, filterState, filterDefinition, l
|
|
|
2716
2682
|
}, [filterValue, previousFilterValue, searchString]);
|
|
2717
2683
|
const [recentSearches, setRecentSearches] = reactCoreHooks.useLocalStorage({
|
|
2718
2684
|
defaultState: [],
|
|
2719
|
-
key: `${localStorageKey}-${filterDefinition
|
|
2685
|
+
key: `${localStorageKey}-${filterDefinition?.filterKey}-free-text-filter-recent-searches`,
|
|
2720
2686
|
schema: zod.z.array(zod.z.string()),
|
|
2721
2687
|
});
|
|
2722
2688
|
const apply = react.useCallback(({ value, wasPreviousSearch = false, setRecent = true }) => {
|
|
@@ -2734,8 +2700,8 @@ const SearchFilterInline = ({ filterBarActions, filterState, filterDefinition, l
|
|
|
2734
2700
|
wasPreviousSearch: Boolean(wasPreviousSearch),
|
|
2735
2701
|
},
|
|
2736
2702
|
});
|
|
2737
|
-
|
|
2738
|
-
}, [filterDefinition
|
|
2703
|
+
filterDefinition?.filterKey && filterBarActions.setStringValue(filterDefinition.filterKey, value);
|
|
2704
|
+
}, [filterDefinition?.filterKey, filterBarActions, logEvent, setRecentSearches]);
|
|
2739
2705
|
return (jsxRuntime.jsxs(reactComponents.Popover, { activation: defaultActivation => ({ ...defaultActivation, keyboardHandlers: false }), dataTestId: dataTestId ? `${dataTestId}-popover` : undefined, placement: "bottom-start", children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx(reactFormComponents.Search
|
|
2740
2706
|
//TODO: [Buss] remove height restriction once baseinput sizes matches buttons
|
|
2741
2707
|
, {
|
|
@@ -2811,7 +2777,6 @@ const mapServicePlansStatusToLabelId = (servicePlan) => {
|
|
|
2811
2777
|
* @returns {StringArrayFilterDefinition} Service plan status filter definition
|
|
2812
2778
|
*/
|
|
2813
2779
|
const ServicePanStatusesFiltersView = (props) => {
|
|
2814
|
-
var _a;
|
|
2815
2780
|
const [t] = useTranslation();
|
|
2816
2781
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2817
2782
|
const { data, loading } = client.useQuery(GetFleetServicePlanStatusesSummaryDocument, {
|
|
@@ -2828,15 +2793,15 @@ const ServicePanStatusesFiltersView = (props) => {
|
|
|
2828
2793
|
},
|
|
2829
2794
|
},
|
|
2830
2795
|
});
|
|
2831
|
-
const servicePlanStatusData =
|
|
2796
|
+
const servicePlanStatusData = data?.assetSummary?.servicePlanStatuses;
|
|
2832
2797
|
const getCountForAssetType = react.useCallback((type) => {
|
|
2833
2798
|
switch (type) {
|
|
2834
2799
|
case servicePlanStatus.OVERDUE:
|
|
2835
|
-
return servicePlanStatusData
|
|
2800
|
+
return servicePlanStatusData?.overdue;
|
|
2836
2801
|
case servicePlanStatus.PLANNED:
|
|
2837
|
-
return servicePlanStatusData
|
|
2802
|
+
return servicePlanStatusData?.planned;
|
|
2838
2803
|
case servicePlanStatus.UPCOMING:
|
|
2839
|
-
return servicePlanStatusData
|
|
2804
|
+
return servicePlanStatusData?.upcoming;
|
|
2840
2805
|
default:
|
|
2841
2806
|
throw new Error("Unrecognized service plan status");
|
|
2842
2807
|
}
|
|
@@ -2877,7 +2842,6 @@ const useServicePlanStatusFilter = ({ showInStarredMenu, showInFilterBar, servic
|
|
|
2877
2842
|
|
|
2878
2843
|
const FETCH_LIMIT$2 = 1000;
|
|
2879
2844
|
const SiteIdsFilterView = (props) => {
|
|
2880
|
-
var _a, _b;
|
|
2881
2845
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
2882
2846
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
2883
2847
|
const [searchText, setSearchText] = react.useState("");
|
|
@@ -2894,18 +2858,14 @@ const SiteIdsFilterView = (props) => {
|
|
|
2894
2858
|
},
|
|
2895
2859
|
});
|
|
2896
2860
|
const options = react.useMemo(() => {
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
count: siteEdge.count || 0,
|
|
2903
|
-
label: ((_b = siteEdge.site) === null || _b === void 0 ? void 0 : _b.name) || "Unknown",
|
|
2904
|
-
});
|
|
2905
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
2861
|
+
const result = data?.assetSummary?.sites?.summary.map(siteEdge => ({
|
|
2862
|
+
key: siteEdge.site?.siteId || "unknown",
|
|
2863
|
+
count: siteEdge.count || 0,
|
|
2864
|
+
label: siteEdge.site?.name || "Unknown",
|
|
2865
|
+
})) ?? [];
|
|
2906
2866
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$2);
|
|
2907
2867
|
return result;
|
|
2908
|
-
}, [
|
|
2868
|
+
}, [data?.assetSummary?.sites?.summary]);
|
|
2909
2869
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
2910
2870
|
};
|
|
2911
2871
|
/**
|
|
@@ -3021,7 +2981,6 @@ const sortSiteTypeSummary = (arr) => {
|
|
|
3021
2981
|
});
|
|
3022
2982
|
};
|
|
3023
2983
|
const SiteTypesFilterView = (props) => {
|
|
3024
|
-
var _a;
|
|
3025
2984
|
const [t] = useTranslation();
|
|
3026
2985
|
const { assetQueryVariables } = filtersGraphqlHook.useAssetQueryFilters({ filters: props.filterState.values });
|
|
3027
2986
|
const { data, loading } = client.useQuery(GetFleetSiteTypeSummaryDocument, {
|
|
@@ -3035,9 +2994,8 @@ const SiteTypesFilterView = (props) => {
|
|
|
3035
2994
|
},
|
|
3036
2995
|
});
|
|
3037
2996
|
const siteTypeData = react.useMemo(() => {
|
|
3038
|
-
var _a;
|
|
3039
2997
|
const output = [];
|
|
3040
|
-
|
|
2998
|
+
data?.assetSummary?.siteTypes.summary.forEach(summary => {
|
|
3041
2999
|
const key = summary.siteType;
|
|
3042
3000
|
if (key) {
|
|
3043
3001
|
output.push({
|
|
@@ -3050,7 +3008,7 @@ const SiteTypesFilterView = (props) => {
|
|
|
3050
3008
|
return output.filter(SortSiteTypeSummary => SortSiteTypeSummary.key !== exports.SiteTypeSFS.NotOnSite);
|
|
3051
3009
|
}
|
|
3052
3010
|
return output;
|
|
3053
|
-
}, [
|
|
3011
|
+
}, [data?.assetSummary?.siteTypes.summary, props.filterBarActions]);
|
|
3054
3012
|
const siteTypeOptions = sortSiteTypeSummary(siteTypeData)
|
|
3055
3013
|
.map(type => ({
|
|
3056
3014
|
key: type.key,
|
|
@@ -3104,7 +3062,6 @@ const mapSiteTypeToLabelId = (type) => {
|
|
|
3104
3062
|
};
|
|
3105
3063
|
|
|
3106
3064
|
const TelematicsConnectedFiltersView = (props) => {
|
|
3107
|
-
var _a, _b, _c, _d, _e;
|
|
3108
3065
|
const [t] = useTranslation();
|
|
3109
3066
|
const { logEvent } = reactCoreHooks.useAnalytics(filtersFilterBar.FilterEvents);
|
|
3110
3067
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
@@ -3117,7 +3074,7 @@ const TelematicsConnectedFiltersView = (props) => {
|
|
|
3117
3074
|
},
|
|
3118
3075
|
},
|
|
3119
3076
|
});
|
|
3120
|
-
const summaries =
|
|
3077
|
+
const summaries = data?.assetSummary?.assetTelematicsDeviceConnected?.summary ?? [];
|
|
3121
3078
|
const handleChange = (newValue) => {
|
|
3122
3079
|
logEvent("Filters Applied - V2", {
|
|
3123
3080
|
type: "TelematicsConnected",
|
|
@@ -3130,7 +3087,7 @@ const TelematicsConnectedFiltersView = (props) => {
|
|
|
3130
3087
|
return newValue === "true" ? { booleanValue: true } : { booleanValue: false };
|
|
3131
3088
|
});
|
|
3132
3089
|
};
|
|
3133
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions, loading: loading }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "followed", label: "", onChange: e => handleChange(e.currentTarget.value), value: props.value ? props.value.booleanValue + "" : "", children: [jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { itemCount:
|
|
3090
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...props.filterDefinition, ...props.filterBarActions, loading: loading }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: jsxRuntime.jsxs(reactFormComponents.RadioGroup, { className: "pl-2 pr-2", id: "followed", label: "", onChange: e => handleChange(e.currentTarget.value), value: props.value ? props.value.booleanValue + "" : "", children: [jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { itemCount: summaries.find(item => item.key === "numberOfAssetsConnectedWithTelematicsDevice")?.count, label: t("filtersBar.defaultAssetFilters.telematicsConnectedFilter.connected"), value: "true" }), jsxRuntime.jsx(reactFilterComponents.RadioFilterItem, { itemCount: summaries.find(item => item.key === "numberOfAssetsNotConnectedWithTelematicsDevice")?.count, label: t("filtersBar.defaultAssetFilters.telematicsConnectedFilter.notConnected"), value: "false" })] }) })] }));
|
|
3134
3091
|
};
|
|
3135
3092
|
/**
|
|
3136
3093
|
*
|
|
@@ -3162,7 +3119,6 @@ const useTelematicsConnectedFilter = () => {
|
|
|
3162
3119
|
|
|
3163
3120
|
const FETCH_LIMIT$1 = 1000;
|
|
3164
3121
|
const TypesFilterView = (props) => {
|
|
3165
|
-
var _a, _b;
|
|
3166
3122
|
const { getMachineTypeTranslation } = translationsMachineType.useMachineTypeTranslations();
|
|
3167
3123
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
3168
3124
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
@@ -3180,15 +3136,14 @@ const TypesFilterView = (props) => {
|
|
|
3180
3136
|
},
|
|
3181
3137
|
});
|
|
3182
3138
|
const options = react.useMemo(() => {
|
|
3183
|
-
|
|
3184
|
-
const result = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.assetSummary) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.summary.map(type => ({
|
|
3139
|
+
const result = data?.assetSummary?.types?.summary.map(type => ({
|
|
3185
3140
|
key: type.key,
|
|
3186
3141
|
count: type.count,
|
|
3187
3142
|
label: getMachineTypeTranslation(type.key),
|
|
3188
|
-
}))
|
|
3143
|
+
})) ?? [];
|
|
3189
3144
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT$1);
|
|
3190
3145
|
return result;
|
|
3191
|
-
}, [
|
|
3146
|
+
}, [data?.assetSummary?.types?.summary, getMachineTypeTranslation]);
|
|
3192
3147
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
3193
3148
|
};
|
|
3194
3149
|
/**
|
|
@@ -3214,7 +3169,7 @@ const useTypesFilter = () => {
|
|
|
3214
3169
|
};
|
|
3215
3170
|
|
|
3216
3171
|
const PartnerFilterView = ({ filterDefinition, value, filterBarActions }) => {
|
|
3217
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...filterDefinition, ...filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: value
|
|
3172
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(filtersFilterBar.FilterHeader, { ...filterDefinition, ...filterBarActions }), jsxRuntime.jsx(reactFilterComponents.FilterBody, { limitSize: true, children: value?.map(vn => vn.name).join(",") })] }));
|
|
3218
3173
|
};
|
|
3219
3174
|
/**
|
|
3220
3175
|
* Partner filter definition
|
|
@@ -3238,7 +3193,6 @@ const usePartnerFilter = () => {
|
|
|
3238
3193
|
|
|
3239
3194
|
const FETCH_LIMIT = 1000;
|
|
3240
3195
|
const SiteDepotOwnershipIdsFilterView = (props) => {
|
|
3241
|
-
var _a, _b;
|
|
3242
3196
|
const [t] = useTranslation();
|
|
3243
3197
|
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
3244
3198
|
const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
|
|
@@ -3256,20 +3210,16 @@ const SiteDepotOwnershipIdsFilterView = (props) => {
|
|
|
3256
3210
|
},
|
|
3257
3211
|
});
|
|
3258
3212
|
const options = react.useMemo(() => {
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
? t("siteOwningDepot.notOwned")
|
|
3267
|
-
: ((_c = owningDepotEdge.site) === null || _c === void 0 ? void 0 : _c.name) || t("siteOwningDepot.unknown"),
|
|
3268
|
-
});
|
|
3269
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
3213
|
+
const result = data?.assetSummary?.owningDepots?.summary.map(owningDepotEdge => ({
|
|
3214
|
+
key: owningDepotEdge.site?.siteId ? owningDepotEdge.site.siteId || "unknown" : "UNDEFINED",
|
|
3215
|
+
count: owningDepotEdge.count || 0,
|
|
3216
|
+
label: owningDepotEdge.site?.name === "UNDEFINED"
|
|
3217
|
+
? t("siteOwningDepot.notOwned")
|
|
3218
|
+
: owningDepotEdge.site?.name || t("siteOwningDepot.unknown"),
|
|
3219
|
+
})) ?? [];
|
|
3270
3220
|
setShowRequestMoreUseSearch(result.length === FETCH_LIMIT);
|
|
3271
3221
|
return result;
|
|
3272
|
-
}, [
|
|
3222
|
+
}, [data?.assetSummary?.owningDepots?.summary, t]);
|
|
3273
3223
|
return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
|
|
3274
3224
|
};
|
|
3275
3225
|
/**
|
|
@@ -3330,7 +3280,7 @@ const useDefaultAssetFilterBarDefinition = ({ sitesEnabled, owningDepotEnabled,
|
|
|
3330
3280
|
const ownerAccountIds = useOwnerAccountIdsFilter();
|
|
3331
3281
|
const search = useSearchFilter({ localStorageKey: "assetSearch" });
|
|
3332
3282
|
const area = useAreaFilter({
|
|
3333
|
-
showWithSearch: () => areaShowWithSearch
|
|
3283
|
+
showWithSearch: () => areaShowWithSearch ?? false,
|
|
3334
3284
|
});
|
|
3335
3285
|
const productionYears = useProductionYearFilter();
|
|
3336
3286
|
const partner = usePartnerFilter();
|