@trackunit/filters-asset-filter-definitions 2.7.17 → 2.7.19
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 +458 -0
- package/index.esm.js +451 -2
- package/package.json +15 -15
- package/src/defaultFilters/defaults/InspectionTemplateAssignedFilter.d.ts +22 -0
- package/src/defaultFilters/defaults/LastInspectionResultFilter.d.ts +24 -0
- package/src/defaultFilters/defaults/LastPerformedInspectionFilter.d.ts +23 -0
- package/src/generated/graphql-api/gql.d.ts +2 -2
- package/src/generated/graphql-api/graphql.d.ts +39 -0
- package/src/generated/graphql-api/mock.d.ts +6 -0
- package/src/hooks/useDefaultAssetFilterBarDefinition.d.ts +3 -0
- package/src/index.d.ts +3 -0
- package/src/translation.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -73,6 +73,26 @@ var defaultTranslations = {
|
|
|
73
73
|
"assetFilters.followedFilter.label": "Followed",
|
|
74
74
|
"assetFilters.groupFilter.missingGroup": "Missing group",
|
|
75
75
|
"assetFilters.hourIntervalFilter.label": "Hour interval",
|
|
76
|
+
"assetFilters.inspectionTemplateAssigned.ALL": "All",
|
|
77
|
+
"assetFilters.inspectionTemplateAssigned.HAS_TEMPLATE": "Has template",
|
|
78
|
+
"assetFilters.inspectionTemplateAssigned.NO_TEMPLATE": "Does not have template",
|
|
79
|
+
"assetFilters.lastInspectionResult.FAILED_CRITICAL": "Failed",
|
|
80
|
+
"assetFilters.lastInspectionResult.FAILED_LOW": "Passed (with warning)",
|
|
81
|
+
"assetFilters.lastInspectionResult.NO_LAST_INSPECTION": "Unknown",
|
|
82
|
+
"assetFilters.lastInspectionResult.PASSED": "Passed",
|
|
83
|
+
"assetFilters.lastInspectionResult.SKIPPED": "Skipped",
|
|
84
|
+
"assetFilters.lastPerformedInspection.ALL": "All",
|
|
85
|
+
"assetFilters.lastPerformedInspection.MORE_THAN_12_HOURS_AGO": "More than 12 hours ago",
|
|
86
|
+
"assetFilters.lastPerformedInspection.MORE_THAN_2_HOURS_AGO": "More than 2 hours ago",
|
|
87
|
+
"assetFilters.lastPerformedInspection.MORE_THAN_24_HOURS_AGO": "More than 24 hours ago",
|
|
88
|
+
"assetFilters.lastPerformedInspection.MORE_THAN_7_DAYS_AGO": "More than 7 days ago",
|
|
89
|
+
"assetFilters.lastPerformedInspection.MORE_THAN_8_HOURS_AGO": "More than 8 hours ago",
|
|
90
|
+
"assetFilters.lastPerformedInspection.NEVER": "Never",
|
|
91
|
+
"assetFilters.lastPerformedInspection.WITHIN_12_HOURS": "Within 12 hours",
|
|
92
|
+
"assetFilters.lastPerformedInspection.WITHIN_2_HOURS": "Within 2 hours",
|
|
93
|
+
"assetFilters.lastPerformedInspection.WITHIN_24_HOURS": "Within 24 hours",
|
|
94
|
+
"assetFilters.lastPerformedInspection.WITHIN_7_DAYS": "Within 7 days",
|
|
95
|
+
"assetFilters.lastPerformedInspection.WITHIN_8_HOURS": "Within 8 hours",
|
|
76
96
|
"assetFilters.lastSeenFilter.anytime": "Any time",
|
|
77
97
|
"assetFilters.lastSeenFilter.last24Hours": "Last 24 hours",
|
|
78
98
|
"assetFilters.lastSeenFilter.last30Days": "Last 30 days",
|
|
@@ -153,6 +173,9 @@ var defaultTranslations = {
|
|
|
153
173
|
"fleetlist.column.insights.cumulativeIdleHours": "Total Idle Hours",
|
|
154
174
|
"fleetlist.column.insights.cumulativeOperatingHours": "Total Hours",
|
|
155
175
|
"fleetlist.column.insights.fuelLevel": "Fuel Level",
|
|
176
|
+
"fleetlist.column.inspectionTemplateAssigned": "Template assigned",
|
|
177
|
+
"fleetlist.column.lastInspectionResult": "Result of last inspection",
|
|
178
|
+
"fleetlist.column.lastPerformedInspection": "Last performed inspection",
|
|
156
179
|
"fleetlist.column.lastSeen": "Last Seen (GPS)",
|
|
157
180
|
"fleetlist.column.metadataCompleteness": "Metadata Completeness",
|
|
158
181
|
"fleetlist.column.model": "Model",
|
|
@@ -1862,6 +1885,125 @@ const GetMetadataCompletenessSummaryDocument = {
|
|
|
1862
1885
|
},
|
|
1863
1886
|
],
|
|
1864
1887
|
};
|
|
1888
|
+
const GetInspectionLastStatusesSummaryDocument = {
|
|
1889
|
+
kind: "Document",
|
|
1890
|
+
definitions: [
|
|
1891
|
+
{
|
|
1892
|
+
kind: "OperationDefinition",
|
|
1893
|
+
operation: "query",
|
|
1894
|
+
name: { kind: "Name", value: "GetInspectionLastStatusesSummary" },
|
|
1895
|
+
variableDefinitions: [
|
|
1896
|
+
{
|
|
1897
|
+
kind: "VariableDefinition",
|
|
1898
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
|
|
1899
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
|
|
1900
|
+
},
|
|
1901
|
+
],
|
|
1902
|
+
selectionSet: {
|
|
1903
|
+
kind: "SelectionSet",
|
|
1904
|
+
selections: [
|
|
1905
|
+
{
|
|
1906
|
+
kind: "Field",
|
|
1907
|
+
name: { kind: "Name", value: "assetSummary" },
|
|
1908
|
+
arguments: [
|
|
1909
|
+
{
|
|
1910
|
+
kind: "Argument",
|
|
1911
|
+
name: { kind: "Name", value: "filters" },
|
|
1912
|
+
value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
|
|
1913
|
+
},
|
|
1914
|
+
],
|
|
1915
|
+
selectionSet: {
|
|
1916
|
+
kind: "SelectionSet",
|
|
1917
|
+
selections: [
|
|
1918
|
+
{
|
|
1919
|
+
kind: "Field",
|
|
1920
|
+
name: { kind: "Name", value: "inspectionLastStatuses" },
|
|
1921
|
+
selectionSet: {
|
|
1922
|
+
kind: "SelectionSet",
|
|
1923
|
+
selections: [
|
|
1924
|
+
{ kind: "Field", name: { kind: "Name", value: "total" } },
|
|
1925
|
+
{ kind: "Field", name: { kind: "Name", value: "undefined" } },
|
|
1926
|
+
{
|
|
1927
|
+
kind: "Field",
|
|
1928
|
+
name: { kind: "Name", value: "summary" },
|
|
1929
|
+
selectionSet: {
|
|
1930
|
+
kind: "SelectionSet",
|
|
1931
|
+
selections: [
|
|
1932
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
1933
|
+
{ kind: "Field", name: { kind: "Name", value: "count" } },
|
|
1934
|
+
],
|
|
1935
|
+
},
|
|
1936
|
+
},
|
|
1937
|
+
],
|
|
1938
|
+
},
|
|
1939
|
+
},
|
|
1940
|
+
],
|
|
1941
|
+
},
|
|
1942
|
+
},
|
|
1943
|
+
],
|
|
1944
|
+
},
|
|
1945
|
+
},
|
|
1946
|
+
],
|
|
1947
|
+
};
|
|
1948
|
+
const GetInspectionTemplateAssignedSummaryDocument = {
|
|
1949
|
+
kind: "Document",
|
|
1950
|
+
definitions: [
|
|
1951
|
+
{
|
|
1952
|
+
kind: "OperationDefinition",
|
|
1953
|
+
operation: "query",
|
|
1954
|
+
name: { kind: "Name", value: "GetInspectionTemplateAssignedSummary" },
|
|
1955
|
+
variableDefinitions: [
|
|
1956
|
+
{
|
|
1957
|
+
kind: "VariableDefinition",
|
|
1958
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
|
|
1959
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
|
|
1960
|
+
},
|
|
1961
|
+
],
|
|
1962
|
+
selectionSet: {
|
|
1963
|
+
kind: "SelectionSet",
|
|
1964
|
+
selections: [
|
|
1965
|
+
{
|
|
1966
|
+
kind: "Field",
|
|
1967
|
+
name: { kind: "Name", value: "assetSummary" },
|
|
1968
|
+
arguments: [
|
|
1969
|
+
{
|
|
1970
|
+
kind: "Argument",
|
|
1971
|
+
name: { kind: "Name", value: "filters" },
|
|
1972
|
+
value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
|
|
1973
|
+
},
|
|
1974
|
+
],
|
|
1975
|
+
selectionSet: {
|
|
1976
|
+
kind: "SelectionSet",
|
|
1977
|
+
selections: [
|
|
1978
|
+
{
|
|
1979
|
+
kind: "Field",
|
|
1980
|
+
name: { kind: "Name", value: "inspectionTemplateAssigned" },
|
|
1981
|
+
selectionSet: {
|
|
1982
|
+
kind: "SelectionSet",
|
|
1983
|
+
selections: [
|
|
1984
|
+
{ kind: "Field", name: { kind: "Name", value: "total" } },
|
|
1985
|
+
{
|
|
1986
|
+
kind: "Field",
|
|
1987
|
+
name: { kind: "Name", value: "summary" },
|
|
1988
|
+
selectionSet: {
|
|
1989
|
+
kind: "SelectionSet",
|
|
1990
|
+
selections: [
|
|
1991
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
1992
|
+
{ kind: "Field", name: { kind: "Name", value: "count" } },
|
|
1993
|
+
],
|
|
1994
|
+
},
|
|
1995
|
+
},
|
|
1996
|
+
],
|
|
1997
|
+
},
|
|
1998
|
+
},
|
|
1999
|
+
],
|
|
2000
|
+
},
|
|
2001
|
+
},
|
|
2002
|
+
],
|
|
2003
|
+
},
|
|
2004
|
+
},
|
|
2005
|
+
],
|
|
2006
|
+
};
|
|
1865
2007
|
const GetFleetModelsSummaryConnectionDocument = {
|
|
1866
2008
|
kind: "Document",
|
|
1867
2009
|
definitions: [
|
|
@@ -6200,6 +6342,304 @@ const useInsightsFuelLevelFilter = (defaultValue) => {
|
|
|
6200
6342
|
return result;
|
|
6201
6343
|
};
|
|
6202
6344
|
|
|
6345
|
+
/**
|
|
6346
|
+
* Must stay aligned with `Flags.INSPECTIONS_FILTERS` in
|
|
6347
|
+
* `libs/react/core-contexts-internal/src/featureFlags/flag.ts` (ConfigCat key).
|
|
6348
|
+
*/
|
|
6349
|
+
const INSPECTIONS_FILTERS_FEATURE_FLAG_KEY$2 = "inspections_manager_inspectionFilters";
|
|
6350
|
+
const inspectionTemplateAssignedOptions = ["HAS_TEMPLATE", "NO_TEMPLATE", "ALL"];
|
|
6351
|
+
/**
|
|
6352
|
+
* Maps inspection template assigned filter value to a translation key id.
|
|
6353
|
+
*
|
|
6354
|
+
* @param type - Filter value
|
|
6355
|
+
* @returns {string} Translation key id for the option label
|
|
6356
|
+
*/
|
|
6357
|
+
const mapInspectionTemplateAssignedToLabelId = (type) => {
|
|
6358
|
+
switch (type) {
|
|
6359
|
+
case "HAS_TEMPLATE":
|
|
6360
|
+
case "NO_TEMPLATE":
|
|
6361
|
+
case "ALL":
|
|
6362
|
+
return `assetFilters.inspectionTemplateAssigned.${type}`;
|
|
6363
|
+
default:
|
|
6364
|
+
return "assetFilters.unknown";
|
|
6365
|
+
}
|
|
6366
|
+
};
|
|
6367
|
+
/**
|
|
6368
|
+
* Filter view for "template assigned" (inspections). Fetches per-option asset counts via
|
|
6369
|
+
* `GetInspectionTemplateAssignedSummary`, excluding this filter's own value so all options remain
|
|
6370
|
+
* selectable.
|
|
6371
|
+
*
|
|
6372
|
+
* @param {FilterViewProps<ValueName>} props - Props passed to the filter component
|
|
6373
|
+
* @returns {ReactElement} The filter radio UI
|
|
6374
|
+
*/
|
|
6375
|
+
const InspectionTemplateAssignedFilter = (props) => {
|
|
6376
|
+
const [t] = useTranslation();
|
|
6377
|
+
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
6378
|
+
const { data, loading } = reactGraphqlHooks.useQuery(GetInspectionTemplateAssignedSummaryDocument, {
|
|
6379
|
+
// `inspectionTemplateAssigned` is a preview field; the API requires this header to opt in.
|
|
6380
|
+
context: { headers: { "TU-PREVIEW": "ASSET-TEMPLATE-ASSIGNED" } },
|
|
6381
|
+
variables: {
|
|
6382
|
+
filters: {
|
|
6383
|
+
...activeFilters,
|
|
6384
|
+
inspectionTemplateAssigned: null, // Omit the filter's own value so all options show counts
|
|
6385
|
+
},
|
|
6386
|
+
},
|
|
6387
|
+
});
|
|
6388
|
+
const getCountForInspectionTemplateAssigned = react.useCallback((type) => {
|
|
6389
|
+
const summary = data?.assetSummary?.inspectionTemplateAssigned?.summary ?? [];
|
|
6390
|
+
switch (type) {
|
|
6391
|
+
case "HAS_TEMPLATE":
|
|
6392
|
+
case "NO_TEMPLATE":
|
|
6393
|
+
return summary.find(item => item.status === type)?.count ?? 0;
|
|
6394
|
+
case "ALL":
|
|
6395
|
+
return data?.assetSummary?.inspectionTemplateAssigned?.total;
|
|
6396
|
+
default:
|
|
6397
|
+
throw new Error("Unrecognized inspectionTemplateAssigned type");
|
|
6398
|
+
}
|
|
6399
|
+
}, [data?.assetSummary?.inspectionTemplateAssigned?.summary, data?.assetSummary?.inspectionTemplateAssigned?.total]);
|
|
6400
|
+
const options = react.useMemo(() => {
|
|
6401
|
+
return inspectionTemplateAssignedOptions.map(type => ({
|
|
6402
|
+
key: type,
|
|
6403
|
+
count: getCountForInspectionTemplateAssigned(type) ?? undefined,
|
|
6404
|
+
label: t(mapInspectionTemplateAssignedToLabelId(type)),
|
|
6405
|
+
}));
|
|
6406
|
+
}, [getCountForInspectionTemplateAssigned, t]);
|
|
6407
|
+
return jsxRuntime.jsx(filtersFilterBar.DefaultRadioFilter, { ...props, loading: loading, options: options });
|
|
6408
|
+
};
|
|
6409
|
+
/**
|
|
6410
|
+
* Inspection template assigned filter definition. Applied to results via
|
|
6411
|
+
* `AssetFiltersInput.inspectionTemplateAssigned` (see `useActiveAssetFilters`).
|
|
6412
|
+
*/
|
|
6413
|
+
const useInspectionTemplateAssignedFilter = ({ isDefault } = {}) => {
|
|
6414
|
+
const [t] = useTranslation();
|
|
6415
|
+
const inspectionsFiltersEnabled = reactCoreHooks.useHostFeatureFlag(INSPECTIONS_FILTERS_FEATURE_FLAG_KEY$2, {
|
|
6416
|
+
defaultValueWhenMissing: true, // if flag is deleted
|
|
6417
|
+
}) ?? false; // when loading
|
|
6418
|
+
const result = react.useMemo(() => {
|
|
6419
|
+
return {
|
|
6420
|
+
filterKey: "inspectionTemplateAssigned",
|
|
6421
|
+
type: "valueName",
|
|
6422
|
+
group: "INSPECTIONS",
|
|
6423
|
+
default: isDefault,
|
|
6424
|
+
defaultValue: { value: "ALL", name: t(mapInspectionTemplateAssignedToLabelId("ALL")) },
|
|
6425
|
+
title: t("fleetlist.column.inspectionTemplateAssigned"),
|
|
6426
|
+
showInFilterBar: () => inspectionsFiltersEnabled,
|
|
6427
|
+
component: filterProps => jsxRuntime.jsx(InspectionTemplateAssignedFilter, { ...filterProps }),
|
|
6428
|
+
};
|
|
6429
|
+
}, [inspectionsFiltersEnabled, isDefault, t]);
|
|
6430
|
+
return result;
|
|
6431
|
+
};
|
|
6432
|
+
|
|
6433
|
+
/**
|
|
6434
|
+
* Must stay aligned with `Flags.INSPECTIONS_FILTERS` in
|
|
6435
|
+
* `libs/react/core-contexts-internal/src/featureFlags/flag.ts` (ConfigCat key).
|
|
6436
|
+
*/
|
|
6437
|
+
const INSPECTIONS_FILTERS_FEATURE_FLAG_KEY$1 = "inspections_manager_inspectionFilters";
|
|
6438
|
+
const lastInspectionResultOptionKeys = [
|
|
6439
|
+
"PASSED",
|
|
6440
|
+
"FAILED_LOW",
|
|
6441
|
+
"FAILED_CRITICAL",
|
|
6442
|
+
"SKIPPED",
|
|
6443
|
+
"NO_LAST_INSPECTION",
|
|
6444
|
+
];
|
|
6445
|
+
const mapLastInspectionResultOptionToLabelId = (key) => {
|
|
6446
|
+
switch (key) {
|
|
6447
|
+
case "PASSED":
|
|
6448
|
+
return "assetFilters.lastInspectionResult.PASSED";
|
|
6449
|
+
case "FAILED_LOW":
|
|
6450
|
+
return "assetFilters.lastInspectionResult.FAILED_LOW";
|
|
6451
|
+
case "FAILED_CRITICAL":
|
|
6452
|
+
return "assetFilters.lastInspectionResult.FAILED_CRITICAL";
|
|
6453
|
+
case "SKIPPED":
|
|
6454
|
+
return "assetFilters.lastInspectionResult.SKIPPED";
|
|
6455
|
+
case "NO_LAST_INSPECTION":
|
|
6456
|
+
return "assetFilters.lastInspectionResult.NO_LAST_INSPECTION";
|
|
6457
|
+
default:
|
|
6458
|
+
return "assetFilters.unknown";
|
|
6459
|
+
}
|
|
6460
|
+
};
|
|
6461
|
+
const mapStoredFilterValueToLabelId = (value) => {
|
|
6462
|
+
switch (value) {
|
|
6463
|
+
case "PASSED":
|
|
6464
|
+
return "assetFilters.lastInspectionResult.PASSED";
|
|
6465
|
+
case "FAILED_LOW":
|
|
6466
|
+
return "assetFilters.lastInspectionResult.FAILED_LOW";
|
|
6467
|
+
case "FAILED_CRITICAL":
|
|
6468
|
+
return "assetFilters.lastInspectionResult.FAILED_CRITICAL";
|
|
6469
|
+
case "SKIPPED":
|
|
6470
|
+
return "assetFilters.lastInspectionResult.SKIPPED";
|
|
6471
|
+
case "NO_LAST_INSPECTION":
|
|
6472
|
+
return "assetFilters.lastInspectionResult.NO_LAST_INSPECTION";
|
|
6473
|
+
default:
|
|
6474
|
+
return "assetFilters.unknown";
|
|
6475
|
+
}
|
|
6476
|
+
};
|
|
6477
|
+
/**
|
|
6478
|
+
* Checkbox filter for last inspection result. Per-option counts come from the `inspectionLastStatuses`
|
|
6479
|
+
* summary; the `NO_LAST_INSPECTION` option maps to the summary's `undefined` bucket.
|
|
6480
|
+
*
|
|
6481
|
+
* @param props - Filter view props from the filter bar
|
|
6482
|
+
* @returns {ReactElement} Checkbox list for last inspection result values
|
|
6483
|
+
*/
|
|
6484
|
+
const LastInspectionResultFiltersView = (props) => {
|
|
6485
|
+
const [t] = useTranslation();
|
|
6486
|
+
const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
|
|
6487
|
+
const { data, loading } = reactGraphqlHooks.useQuery(GetInspectionLastStatusesSummaryDocument, {
|
|
6488
|
+
// `inspectionLastStatuses` is a preview field; the API requires this header to opt in.
|
|
6489
|
+
context: { headers: { "TU-PREVIEW": "ASSET-LAST-INSPECTION" } },
|
|
6490
|
+
variables: {
|
|
6491
|
+
filters: {
|
|
6492
|
+
...activeFilters,
|
|
6493
|
+
// Omit this filter's own values so counts reflect every option.
|
|
6494
|
+
inspectionLastFilters: {
|
|
6495
|
+
...activeFilters.inspectionLastFilters,
|
|
6496
|
+
statuses: null,
|
|
6497
|
+
includeNeverInspected: null,
|
|
6498
|
+
},
|
|
6499
|
+
},
|
|
6500
|
+
},
|
|
6501
|
+
});
|
|
6502
|
+
const getCountForOption = react.useCallback((key) => {
|
|
6503
|
+
const inspectionLastStatuses = data?.assetSummary?.inspectionLastStatuses;
|
|
6504
|
+
if (key === "NO_LAST_INSPECTION") {
|
|
6505
|
+
return inspectionLastStatuses?.undefined ?? 0;
|
|
6506
|
+
}
|
|
6507
|
+
return inspectionLastStatuses?.summary.find(item => item.status === key)?.count ?? 0;
|
|
6508
|
+
}, [data?.assetSummary?.inspectionLastStatuses]);
|
|
6509
|
+
const options = react.useMemo(() => {
|
|
6510
|
+
return lastInspectionResultOptionKeys.map(key => ({
|
|
6511
|
+
key,
|
|
6512
|
+
count: getCountForOption(key),
|
|
6513
|
+
label: t(mapLastInspectionResultOptionToLabelId(key)),
|
|
6514
|
+
}));
|
|
6515
|
+
}, [getCountForOption, t]);
|
|
6516
|
+
return jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, loading: loading, options: options });
|
|
6517
|
+
};
|
|
6518
|
+
/**
|
|
6519
|
+
* Last inspection result filter definition (INSPECTIONS group; gated by inspections filters feature flag).
|
|
6520
|
+
*
|
|
6521
|
+
* @param root0 - Hook options
|
|
6522
|
+
* @param root0.isDefault - When true, include in default filter bar configuration
|
|
6523
|
+
* @returns {StringArrayFilterDefinition} Filter definition for the asset filter bar
|
|
6524
|
+
*/
|
|
6525
|
+
const useLastInspectionResultFilter = ({ isDefault } = {}) => {
|
|
6526
|
+
const [t] = useTranslation();
|
|
6527
|
+
const inspectionsFiltersEnabled = reactCoreHooks.useHostFeatureFlag(INSPECTIONS_FILTERS_FEATURE_FLAG_KEY$1, {
|
|
6528
|
+
defaultValueWhenMissing: true, // if flag is deleted
|
|
6529
|
+
}) ?? false; // when loading
|
|
6530
|
+
const result = react.useMemo(() => {
|
|
6531
|
+
return {
|
|
6532
|
+
filterKey: "lastInspectionResult",
|
|
6533
|
+
type: "stringArray",
|
|
6534
|
+
group: "INSPECTIONS",
|
|
6535
|
+
default: isDefault,
|
|
6536
|
+
title: t("fleetlist.column.lastInspectionResult"),
|
|
6537
|
+
showInFilterBar: () => inspectionsFiltersEnabled,
|
|
6538
|
+
valueAsText: values => values.map(value => t(mapStoredFilterValueToLabelId(value))),
|
|
6539
|
+
component: filterProps => jsxRuntime.jsx(LastInspectionResultFiltersView, { ...filterProps }),
|
|
6540
|
+
};
|
|
6541
|
+
}, [inspectionsFiltersEnabled, isDefault, t]);
|
|
6542
|
+
return result;
|
|
6543
|
+
};
|
|
6544
|
+
|
|
6545
|
+
/**
|
|
6546
|
+
* Must stay aligned with `Flags.INSPECTIONS_FILTERS` in
|
|
6547
|
+
* `libs/react/core-contexts-internal/src/featureFlags/flag.ts` (ConfigCat key).
|
|
6548
|
+
*/
|
|
6549
|
+
const INSPECTIONS_FILTERS_FEATURE_FLAG_KEY = "inspections_manager_inspectionFilters";
|
|
6550
|
+
const lastPerformedInspectionOptions = [
|
|
6551
|
+
"ALL",
|
|
6552
|
+
"WITHIN_2_HOURS",
|
|
6553
|
+
"WITHIN_8_HOURS",
|
|
6554
|
+
"WITHIN_12_HOURS",
|
|
6555
|
+
"WITHIN_24_HOURS",
|
|
6556
|
+
"WITHIN_7_DAYS",
|
|
6557
|
+
"MORE_THAN_2_HOURS_AGO",
|
|
6558
|
+
"MORE_THAN_8_HOURS_AGO",
|
|
6559
|
+
"MORE_THAN_12_HOURS_AGO",
|
|
6560
|
+
"MORE_THAN_24_HOURS_AGO",
|
|
6561
|
+
"MORE_THAN_7_DAYS_AGO",
|
|
6562
|
+
"NEVER",
|
|
6563
|
+
];
|
|
6564
|
+
/**
|
|
6565
|
+
* Maps last performed inspection filter value to a translation key id.
|
|
6566
|
+
*
|
|
6567
|
+
* @param type - Filter value
|
|
6568
|
+
* @returns {string} Translation key id for the option label
|
|
6569
|
+
*/
|
|
6570
|
+
const mapLastPerformedInspectionToLabelId = (type) => {
|
|
6571
|
+
switch (type) {
|
|
6572
|
+
case "ALL":
|
|
6573
|
+
return "assetFilters.lastPerformedInspection.ALL";
|
|
6574
|
+
case "WITHIN_2_HOURS":
|
|
6575
|
+
return "assetFilters.lastPerformedInspection.WITHIN_2_HOURS";
|
|
6576
|
+
case "WITHIN_8_HOURS":
|
|
6577
|
+
return "assetFilters.lastPerformedInspection.WITHIN_8_HOURS";
|
|
6578
|
+
case "WITHIN_12_HOURS":
|
|
6579
|
+
return "assetFilters.lastPerformedInspection.WITHIN_12_HOURS";
|
|
6580
|
+
case "WITHIN_24_HOURS":
|
|
6581
|
+
return "assetFilters.lastPerformedInspection.WITHIN_24_HOURS";
|
|
6582
|
+
case "WITHIN_7_DAYS":
|
|
6583
|
+
return "assetFilters.lastPerformedInspection.WITHIN_7_DAYS";
|
|
6584
|
+
case "MORE_THAN_2_HOURS_AGO":
|
|
6585
|
+
return "assetFilters.lastPerformedInspection.MORE_THAN_2_HOURS_AGO";
|
|
6586
|
+
case "MORE_THAN_8_HOURS_AGO":
|
|
6587
|
+
return "assetFilters.lastPerformedInspection.MORE_THAN_8_HOURS_AGO";
|
|
6588
|
+
case "MORE_THAN_12_HOURS_AGO":
|
|
6589
|
+
return "assetFilters.lastPerformedInspection.MORE_THAN_12_HOURS_AGO";
|
|
6590
|
+
case "MORE_THAN_24_HOURS_AGO":
|
|
6591
|
+
return "assetFilters.lastPerformedInspection.MORE_THAN_24_HOURS_AGO";
|
|
6592
|
+
case "MORE_THAN_7_DAYS_AGO":
|
|
6593
|
+
return "assetFilters.lastPerformedInspection.MORE_THAN_7_DAYS_AGO";
|
|
6594
|
+
case "NEVER":
|
|
6595
|
+
return "assetFilters.lastPerformedInspection.NEVER";
|
|
6596
|
+
default:
|
|
6597
|
+
return "assetFilters.unknown";
|
|
6598
|
+
}
|
|
6599
|
+
};
|
|
6600
|
+
/**
|
|
6601
|
+
* Filter view for "last performed inspection" (inspections). The selected time bucket is applied to
|
|
6602
|
+
* results via `inspectionLastFilters.performed` (see `useActiveAssetFilters`). The schema exposes no
|
|
6603
|
+
* per-time-bucket summary, so options render without per-option counts.
|
|
6604
|
+
*
|
|
6605
|
+
* @param {FilterViewProps<ValueName>} props - Props passed to the filter component
|
|
6606
|
+
* @returns {ReactElement} The filter radio UI
|
|
6607
|
+
*/
|
|
6608
|
+
const LastPerformedInspectionFilterView = (props) => {
|
|
6609
|
+
const [t] = useTranslation();
|
|
6610
|
+
const options = react.useMemo(() => {
|
|
6611
|
+
return lastPerformedInspectionOptions.map(type => ({
|
|
6612
|
+
key: type,
|
|
6613
|
+
label: t(mapLastPerformedInspectionToLabelId(type)),
|
|
6614
|
+
}));
|
|
6615
|
+
}, [t]);
|
|
6616
|
+
return jsxRuntime.jsx(filtersFilterBar.DefaultRadioFilter, { ...props, loading: false, options: options });
|
|
6617
|
+
};
|
|
6618
|
+
/**
|
|
6619
|
+
* Last performed inspection filter definition. Applied to results via
|
|
6620
|
+
* `inspectionLastFilters.performed` (see `useActiveAssetFilters`); the schema exposes no
|
|
6621
|
+
* per-time-bucket summary, so options render without counts.
|
|
6622
|
+
*/
|
|
6623
|
+
const useLastPerformedInspectionFilter = ({ isDefault } = {}) => {
|
|
6624
|
+
const [t] = useTranslation();
|
|
6625
|
+
const inspectionsFiltersEnabled = reactCoreHooks.useHostFeatureFlag(INSPECTIONS_FILTERS_FEATURE_FLAG_KEY, {
|
|
6626
|
+
defaultValueWhenMissing: true, // if flag is deleted
|
|
6627
|
+
}) ?? false; // when loading
|
|
6628
|
+
const result = react.useMemo(() => {
|
|
6629
|
+
return {
|
|
6630
|
+
filterKey: "lastPerformedInspection",
|
|
6631
|
+
type: "valueName",
|
|
6632
|
+
group: "INSPECTIONS",
|
|
6633
|
+
default: isDefault,
|
|
6634
|
+
defaultValue: { value: "ALL", name: t(mapLastPerformedInspectionToLabelId("ALL")) },
|
|
6635
|
+
title: t("fleetlist.column.lastPerformedInspection"),
|
|
6636
|
+
showInFilterBar: () => inspectionsFiltersEnabled,
|
|
6637
|
+
component: filterProps => jsxRuntime.jsx(LastPerformedInspectionFilterView, { ...filterProps }),
|
|
6638
|
+
};
|
|
6639
|
+
}, [inspectionsFiltersEnabled, isDefault, t]);
|
|
6640
|
+
return result;
|
|
6641
|
+
};
|
|
6642
|
+
|
|
6203
6643
|
/** The time the asset was last seen. */
|
|
6204
6644
|
exports.AssetLastSeen = void 0;
|
|
6205
6645
|
(function (AssetLastSeen) {
|
|
@@ -7928,6 +8368,9 @@ const useDefaultAssetFilterBarDefinition = () => {
|
|
|
7928
8368
|
const { hasAccess: hasDeviceHealthAppAccess } = reactCoreHooks.useHasAccessTo({ irisAppId: "@trackunit/fleet-health" });
|
|
7929
8369
|
const assetType = useAssetTypeFilter();
|
|
7930
8370
|
const metadataCompleteness = useMetadataCompletenessFilter();
|
|
8371
|
+
const inspectionTemplateAssigned = useInspectionTemplateAssignedFilter();
|
|
8372
|
+
const lastInspectionResult = useLastInspectionResultFilter();
|
|
8373
|
+
const lastPerformedInspection = useLastPerformedInspectionFilter();
|
|
7931
8374
|
const groups = useGroupIdsFilter();
|
|
7932
8375
|
const siteEnabledProps = react.useMemo(() => {
|
|
7933
8376
|
return {
|
|
@@ -8009,6 +8452,9 @@ const useDefaultAssetFilterBarDefinition = () => {
|
|
|
8009
8452
|
pendingTelematicsDevices,
|
|
8010
8453
|
telematicsConnected,
|
|
8011
8454
|
activeFilter,
|
|
8455
|
+
inspectionTemplateAssigned,
|
|
8456
|
+
lastInspectionResult,
|
|
8457
|
+
lastPerformedInspection,
|
|
8012
8458
|
serviceStatus,
|
|
8013
8459
|
followed,
|
|
8014
8460
|
partner,
|
|
@@ -8032,6 +8478,9 @@ const useDefaultAssetFilterBarDefinition = () => {
|
|
|
8032
8478
|
groups,
|
|
8033
8479
|
assetType,
|
|
8034
8480
|
metadataCompleteness,
|
|
8481
|
+
inspectionTemplateAssigned,
|
|
8482
|
+
lastInspectionResult,
|
|
8483
|
+
lastPerformedInspection,
|
|
8035
8484
|
brands,
|
|
8036
8485
|
countries,
|
|
8037
8486
|
models,
|
|
@@ -8098,6 +8547,9 @@ exports.InsightsBatteryChargerStateFilterView = InsightsBatteryChargerStateFilte
|
|
|
8098
8547
|
exports.InsightsBatteryPotentialFilterView = InsightsBatteryPotentialFilterView;
|
|
8099
8548
|
exports.InsightsBatteryStateOfChargePercentFilterView = InsightsBatteryStateOfChargePercentFilterView;
|
|
8100
8549
|
exports.InsightsFuelLevelFilterView = InsightsFuelLevelFilterView;
|
|
8550
|
+
exports.InspectionTemplateAssignedFilter = InspectionTemplateAssignedFilter;
|
|
8551
|
+
exports.LastInspectionResultFiltersView = LastInspectionResultFiltersView;
|
|
8552
|
+
exports.LastPerformedInspectionFilterView = LastPerformedInspectionFilterView;
|
|
8101
8553
|
exports.LastSeenFiltersView = LastSeenFiltersView;
|
|
8102
8554
|
exports.MetadataCompletenessFilterView = MetadataCompletenessFilterView;
|
|
8103
8555
|
exports.ModelsFilterView = ModelsFilterView;
|
|
@@ -8124,6 +8576,9 @@ exports.TypesFilterView = TypesFilterView;
|
|
|
8124
8576
|
exports.areaFilterInternalGeoJsonGeometrySchema = areaFilterInternalGeoJsonGeometrySchema;
|
|
8125
8577
|
exports.areaFilterInternalSchema = areaFilterInternalSchema;
|
|
8126
8578
|
exports.assetTypeConst = assetTypeConst;
|
|
8579
|
+
exports.inspectionTemplateAssignedOptions = inspectionTemplateAssignedOptions;
|
|
8580
|
+
exports.lastInspectionResultOptionKeys = lastInspectionResultOptionKeys;
|
|
8581
|
+
exports.lastPerformedInspectionOptions = lastPerformedInspectionOptions;
|
|
8127
8582
|
exports.mapActivityToLabelId = mapActivityToLabelId;
|
|
8128
8583
|
exports.mapMetadataCompletenessToLabelId = mapMetadataCompletenessToLabelId;
|
|
8129
8584
|
exports.metadataCompleteness = metadataCompleteness;
|
|
@@ -8158,6 +8613,9 @@ exports.useInsightsBatteryChargerStateFilter = useInsightsBatteryChargerStateFil
|
|
|
8158
8613
|
exports.useInsightsBatteryPotentialFilter = useInsightsBatteryPotentialFilter;
|
|
8159
8614
|
exports.useInsightsBatteryStateOfChargePercentFilter = useInsightsBatteryStateOfChargePercentFilter;
|
|
8160
8615
|
exports.useInsightsFuelLevelFilter = useInsightsFuelLevelFilter;
|
|
8616
|
+
exports.useInspectionTemplateAssignedFilter = useInspectionTemplateAssignedFilter;
|
|
8617
|
+
exports.useLastInspectionResultFilter = useLastInspectionResultFilter;
|
|
8618
|
+
exports.useLastPerformedInspectionFilter = useLastPerformedInspectionFilter;
|
|
8161
8619
|
exports.useLastSeenFilter = useLastSeenFilter;
|
|
8162
8620
|
exports.useMetadataCompletenessFilter = useMetadataCompletenessFilter;
|
|
8163
8621
|
exports.useModbusProfileFilter = useModbusProfileFilter;
|