@burdenoff/microfe-assethandler 2026.813.2 → 2026.817.1
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/dist/assethandler/hooks/useMaintenancePlans.d.ts +2 -0
- package/dist/assethandler/hooks/useMaintenancePlans.d.ts.map +1 -1
- package/dist/assethandler/hooks/useMaintenancePlans.js +1 -0
- package/dist/assethandler/hooks/useMaintenancePlans.js.map +1 -1
- package/dist/assethandler/ops/MaintenancePlanDialog.js +14 -7
- package/dist/assethandler/ops/MaintenancePlanDialog.js.map +1 -1
- package/dist/assethandler/pages/AssetsAssetCreatePage.d.ts.map +1 -1
- package/dist/assethandler/pages/AssetsAssetCreatePage.js +115 -101
- package/dist/assethandler/pages/AssetsAssetCreatePage.js.map +1 -1
- package/dist/assethandler/pages/AssetsAssetDetailPage.d.ts.map +1 -1
- package/dist/assethandler/pages/AssetsAssetDetailPage.js +121 -102
- package/dist/assethandler/pages/AssetsAssetDetailPage.js.map +1 -1
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.d.ts.map +1 -1
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.js +119 -114
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.js.map +1 -1
- package/dist/assethandler/providers/AssetHandlerProvider.d.ts.map +1 -1
- package/dist/assethandler/providers/AssetHandlerProvider.js +85 -35
- package/dist/assethandler/providers/AssetHandlerProvider.js.map +1 -1
- package/dist/assethandler/store/assethandlerStore.d.ts +3 -0
- package/dist/assethandler/store/assethandlerStore.d.ts.map +1 -1
- package/dist/assethandler/store/assethandlerStore.js +20 -19
- package/dist/assethandler/store/assethandlerStore.js.map +1 -1
- package/dist/assethandler/utils/meter.d.ts +51 -0
- package/dist/assethandler/utils/meter.d.ts.map +1 -0
- package/dist/assethandler/utils/meter.js +51 -0
- package/dist/assethandler/utils/meter.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/assethandler/utils/meter.ts
|
|
2
|
+
var e = "__NOT_METERED__", t = [
|
|
3
|
+
"HOURS",
|
|
4
|
+
"KM",
|
|
5
|
+
"MILES",
|
|
6
|
+
"CYCLES",
|
|
7
|
+
"UNITS"
|
|
8
|
+
], n = {
|
|
9
|
+
HOURS: {
|
|
10
|
+
singular: "hour",
|
|
11
|
+
plural: "hours",
|
|
12
|
+
reading: "Engine hours to date"
|
|
13
|
+
},
|
|
14
|
+
KM: {
|
|
15
|
+
singular: "km",
|
|
16
|
+
plural: "km",
|
|
17
|
+
reading: "Kilometres to date"
|
|
18
|
+
},
|
|
19
|
+
MILES: {
|
|
20
|
+
singular: "mile",
|
|
21
|
+
plural: "miles",
|
|
22
|
+
reading: "Miles to date"
|
|
23
|
+
},
|
|
24
|
+
CYCLES: {
|
|
25
|
+
singular: "cycle",
|
|
26
|
+
plural: "cycles",
|
|
27
|
+
reading: "Cycles to date"
|
|
28
|
+
},
|
|
29
|
+
UNITS: {
|
|
30
|
+
singular: "unit",
|
|
31
|
+
plural: "units",
|
|
32
|
+
reading: "Units produced to date"
|
|
33
|
+
}
|
|
34
|
+
}, r = (e) => typeof e == "string" && t.includes(e), i = t.map((e) => ({
|
|
35
|
+
value: e,
|
|
36
|
+
label: `${n[e].plural.charAt(0).toUpperCase()}${n[e].plural.slice(1)}`
|
|
37
|
+
}));
|
|
38
|
+
function a(e, t) {
|
|
39
|
+
let i = r(e) ? n[e] : n.UNITS;
|
|
40
|
+
return t === 1 ? i.singular : i.plural;
|
|
41
|
+
}
|
|
42
|
+
function o(e) {
|
|
43
|
+
return r(e) ? n[e].reading : n.UNITS.reading;
|
|
44
|
+
}
|
|
45
|
+
function s(e, t) {
|
|
46
|
+
return `${e.toLocaleString()} ${a(t, e)}`;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { i as METER_UNIT_OPTIONS, e as NOT_METERED, s as formatMeter, o as meterReadingLabel };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=meter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meter.js","names":[],"sources":["../../../src/assethandler/utils/meter.ts"],"sourcesContent":["/**\n * The asset usage meter (BOFF-6032).\n *\n * `Asset.unitsProduced` serves two jobs: it drives UNITS_OF_PRODUCTION depreciation,\n * and it is the meter a `MaintenancePlan.intervalMeter` counts against. Until now it\n * only had the first job in the UI — the input was gated behind the depreciation\n * method — so a farm that depreciates a tractor straight-line had nowhere to record\n * engine hours, and any meter-based plan it created could never come due.\n *\n * ★ There is deliberately no second meter. The service comment on `intervalMeter` is\n * explicit that a maintenance-only meter \"would immediately disagree with\" the\n * depreciation one, and two numbers that mean the same thing and drift apart is worse\n * than one number doing double duty.\n *\n * Nothing here converts between units. A plan interval is always read in its own\n * asset's unit; unit safety comes from never comparing across assets.\n */\n\n/**\n * Sentinel for \"this asset is not metered\" in a Select.\n *\n * It is never stored: it maps back to null on save. Radix Select rejects an empty\n * item value and offers no deselect, so without an explicit option an asset that was\n * once set to HOURS could never be un-metered again — the placeholder is only\n * reachable before the first choice is made.\n */\nexport const NOT_METERED = '__NOT_METERED__';\n\n/** Mirrors the `AssetMeterUnit` GraphQL enum, which does the validating. */\nexport const METER_UNITS = ['HOURS', 'KM', 'MILES', 'CYCLES', 'UNITS'] as const;\n\nexport type MeterUnit = (typeof METER_UNITS)[number];\n\nconst UNIT_LABELS: Record<MeterUnit, { singular: string; plural: string; reading: string }> = {\n HOURS: { singular: 'hour', plural: 'hours', reading: 'Engine hours to date' },\n KM: { singular: 'km', plural: 'km', reading: 'Kilometres to date' },\n MILES: { singular: 'mile', plural: 'miles', reading: 'Miles to date' },\n CYCLES: { singular: 'cycle', plural: 'cycles', reading: 'Cycles to date' },\n UNITS: { singular: 'unit', plural: 'units', reading: 'Units produced to date' },\n};\n\nconst isMeterUnit = (value: unknown): value is MeterUnit =>\n typeof value === 'string' && (METER_UNITS as readonly string[]).includes(value);\n\n/** Options for a meter-unit picker. The empty value means \"not metered\". */\nexport const METER_UNIT_OPTIONS: { value: MeterUnit; label: string }[] = METER_UNITS.map(\n (unit) => ({\n value: unit,\n label: `${UNIT_LABELS[unit].plural.charAt(0).toUpperCase()}${UNIT_LABELS[unit].plural.slice(1)}`,\n })\n);\n\n/**\n * The plural noun for an amount in this unit, e.g. `hours` / `km`.\n *\n * Falls back to \"units\" when the asset carries no unit — which is the wording every\n * one of these surfaces used before this existed, so an un-metered estate reads\n * exactly as it did.\n */\nexport function meterUnitLabel(unit: string | null | undefined, count?: number): string {\n const resolved = isMeterUnit(unit) ? UNIT_LABELS[unit] : UNIT_LABELS.UNITS;\n return count === 1 ? resolved.singular : resolved.plural;\n}\n\n/** Field label for the reading input, e.g. \"Engine hours to date\". */\nexport function meterReadingLabel(unit: string | null | undefined): string {\n return isMeterUnit(unit) ? UNIT_LABELS[unit].reading : UNIT_LABELS.UNITS.reading;\n}\n\n/**\n * An amount rendered with its unit, e.g. `250 hours`.\n *\n * The count decides singular/plural, so a plan set to 1 does not read \"1 hours\".\n */\nexport function formatMeter(value: number, unit: string | null | undefined): string {\n return `${value.toLocaleString()} ${meterUnitLabel(unit, value)}`;\n}\n"],"mappings":";AA0BA,IAAa,IAAc,mBAGd,IAAc;CAAC;CAAS;CAAM;CAAS;CAAU;CAAQ,EAIhE,IAAwF;CAC5F,OAAO;EAAE,UAAU;EAAQ,QAAQ;EAAS,SAAS;EAAwB;CAC7E,IAAI;EAAE,UAAU;EAAM,QAAQ;EAAM,SAAS;EAAsB;CACnE,OAAO;EAAE,UAAU;EAAQ,QAAQ;EAAS,SAAS;EAAiB;CACtE,QAAQ;EAAE,UAAU;EAAS,QAAQ;EAAU,SAAS;EAAkB;CAC1E,OAAO;EAAE,UAAU;EAAQ,QAAQ;EAAS,SAAS;EAA0B;CAChF,EAEK,KAAe,MACnB,OAAO,KAAU,YAAa,EAAkC,SAAS,EAAM,EAGpE,IAA4D,EAAY,KAClF,OAAU;CACT,OAAO;CACP,OAAO,GAAG,EAAY,GAAM,OAAO,OAAO,EAAE,CAAC,aAAa,GAAG,EAAY,GAAM,OAAO,MAAM,EAAE;CAC/F,EACF;AASD,SAAgB,EAAe,GAAiC,GAAwB;CACtF,IAAM,IAAW,EAAY,EAAK,GAAG,EAAY,KAAQ,EAAY;AACrE,QAAO,MAAU,IAAI,EAAS,WAAW,EAAS;;AAIpD,SAAgB,EAAkB,GAAyC;AACzE,QAAO,EAAY,EAAK,GAAG,EAAY,GAAM,UAAU,EAAY,MAAM;;AAQ3E,SAAgB,EAAY,GAAe,GAAyC;AAClF,QAAO,GAAG,EAAM,gBAAgB,CAAC,GAAG,EAAe,GAAM,EAAM"}
|