@agridea/suibi-module 0.1.0-preview.01100f9 → 0.1.0-preview.0808fe0

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.
Files changed (35) hide show
  1. package/dist/elements/browser/main.js +65 -65
  2. package/dist/elements/browser/styles.css +1 -1
  3. package/dist/elements/browser/suibi-module-latest.css +1 -1
  4. package/dist/elements/browser/suibi-module-latest.js +65 -65
  5. package/dist/elements/browser/{suibi-module.v0.1.0-preview.01100f9.css → suibi-module.v0.1.0-preview.0808fe0.css} +1 -1
  6. package/dist/elements/browser/suibi-module.v0.1.0-preview.0808fe0.js +78 -0
  7. package/dist/elements/browser/version.txt +1 -1
  8. package/dist/elements/browser/wc-global-utilities.css +1 -1
  9. package/dist/types/app/components/data-preview/data-preview.component.d.ts +222 -0
  10. package/dist/types/app/components/inline-table/inline-table.component.d.ts +26 -4
  11. package/dist/types/app/components/inline-table/inline-table.types.d.ts +10 -1
  12. package/dist/types/app/core/navigation/navigation.service.d.ts +7 -0
  13. package/dist/types/app/core/planning/planning-balance.service.d.ts +8 -0
  14. package/dist/types/app/core/utils/custom-unit.util.d.ts +38 -0
  15. package/dist/types/app/core/utils/object.util.d.ts +5 -9
  16. package/dist/types/app/core/validation/ajv-custom.d.ts +1 -0
  17. package/dist/types/app/core/validation/capabilities.d.ts +6 -0
  18. package/dist/types/app/core/validation/global-validation.service.d.ts +2 -0
  19. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-table/farm-manure-trading-table.component.d.ts +10 -9
  20. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading.types.d.ts +4 -0
  21. package/dist/types/app/nutrient-cycle/field-cultivation/arable-land-table/arable-land-table.component.d.ts +3 -2
  22. package/dist/types/app/nutrient-cycle/field-cultivation/arable-land-table/arable-land-table.config.d.ts +2 -0
  23. package/dist/types/app/nutrient-cycle/field-cultivation/field-cultivation-master-detail/field-cultivation-master-detail.component.d.ts +1 -1
  24. package/dist/types/app/nutrient-cycle/field-cultivation/field-cultivation.types.d.ts +5 -1
  25. package/dist/types/app/nutrient-cycle/field-cultivation/field-cultivation.util.d.ts +4 -0
  26. package/dist/types/app/nutrient-cycle/field-cultivation/fodder-cropland-table/fodder-cropland-table.component.d.ts +3 -2
  27. package/dist/types/app/nutrient-cycle/field-cultivation/special-crops-table/special-crops-table.component.d.ts +5 -5
  28. package/dist/types/app/nutrient-cycle/field-cultivation/special-crops-table/special-crops-table.config.d.ts +22 -32
  29. package/dist/types/app/nutrient-cycle/field-spreading/fertiliser-table/fertiliser-table.component.d.ts +16 -7
  30. package/dist/types/app/nutrient-cycle/field-spreading/field-spreading.component.d.ts +2 -0
  31. package/dist/types/app/nutrient-cycle/field-spreading/field-spreading.types.d.ts +1 -0
  32. package/dist/types/app/nutrient-cycle/field-spreading/recycling-table/recycling-table.component.d.ts +10 -9
  33. package/dist/types/app/nutrient-cycle/fodder/fodder-table/fodder-table.component.d.ts +5 -3
  34. package/package.json +1 -1
  35. package/dist/elements/browser/suibi-module.v0.1.0-preview.01100f9.js +0 -78
@@ -4,14 +4,11 @@
4
4
  *
5
5
  * ONE table for the whole CULT_SPECIAL category: the crop dropdown reuses the
6
6
  * `agronomicCropCategorySpecial` code list, which is already filtered on
7
- * cultivationCategory === 'CULT_SPECIAL'. Nutrient columns live in the row's
8
- * `requirementCorrection[]` sub-array: Nmin is the N2 slot in kg, the three
9
- * corrections are the P2O5/K2O/Mg slots in %.
7
+ * cultivationCategory === 'CULT_SPECIAL'. The nutrient columns are the three
8
+ * corrections (P2O5/K2O/Mg slots in %) living in the row's
9
+ * `requirementCorrection[]` sub-array.
10
10
  */
11
11
  import type { InlineTableConfig } from '../../../components/inline-table/inline-table.types';
12
- /** Nmin maps to the N2 requirement-correction slot, always expressed in kg. */
13
- export declare const NMIN_FORMULA = "N2";
14
- export declare const NMIN_UNIT = "kg";
15
12
  /** Correction slots managed by the table, always expressed in % (100 % = no correction). */
16
13
  export declare const CORRECTION_FORMULAS: readonly ["P2O5", "K2O", "Mg"];
17
14
  export declare const CORRECTION_UNIT = "%";
@@ -22,40 +19,33 @@ export declare const SPECIAL_CROPS_CODE_LIST = "agronomicCropCategorySpecial";
22
19
  export declare const SPECIAL_CROPS_IDS: Set<string>;
23
20
  /** Looks up a crop entry in the table's code list. */
24
21
  export declare function specialCropEntry(id: unknown): Record<string, unknown> | undefined;
22
+ /** True when the row's crop belongs to the outdoor-vegetable subcategory (CSC_OUTVG). */
23
+ export declare function isOutdoorVegetableRow(row: Record<string, unknown>): boolean;
25
24
  /**
26
- * Nutrient columns are read-only unless the selected crop has the
27
- * `isPermittedForRequirementCorrection` flag: without it, the pre-filled Nmin and
28
- * correction values are fixed defaults from master data and must not be user-editable.
25
+ * Enforces the isMainCrop rule: null for CSC_OUTVG crops (the main-crop concept does
26
+ * not apply), restored to false when switching back to a crop where the flag applies.
29
27
  */
30
- export declare function nutrientColumnsLocked(crop: Record<string, unknown> | undefined): boolean;
28
+ export declare function normalizeIsMainCrop(row: Record<string, unknown>): Record<string, unknown>;
29
+ /** Corrections (P2O5/K2O/Mg) apply to every special crop; locked only without a crop. */
30
+ export declare function correctionColumnsLocked(crop: Record<string, unknown> | undefined): boolean;
31
31
  /**
32
- * Applies the crop's defaults to the requirement-correction slots.
33
- * - If the crop does NOT permit requirement corrections (or none is selected): the
34
- * managed slots are removed entirely — nothing is editable and nothing is sent to the API.
35
- * - If the crop DOES permit them: the managed slots are pre-filled from the crop's
36
- * master-data `requirement` (N2 in kg; P2O5/K2O/Mg in %) and stay user-editable.
32
+ * Applies the crop's defaults to the requirement-correction slots:
33
+ * - No crop selected: the managed slots are removed entirely — nothing is editable
34
+ * and nothing is sent to the API.
35
+ * - Crop selected: the three corrections (P2O5/K2O/Mg) are reset to 100 % and
36
+ * stay user-editable.
37
37
  */
38
38
  export declare function applyCropDefaults(row: Record<string, unknown>, crop: Record<string, unknown> | undefined): Record<string, unknown>;
39
39
  /**
40
- * Normalizes the managed requirement-correction slots on every edit: fixed units
41
- * (N2 → kg, corrections → %) and removal of managed entries left without a quantity
42
- * (the API rejects present-but-null quantities).
40
+ * Normalizes the managed requirement-correction slots on every edit: fixed unit
41
+ * (%) and removal of managed entries left without a quantity (the API rejects
42
+ * present-but-null quantities).
43
43
  */
44
44
  export declare function normalizeManagedCorrections(row: Record<string, unknown>): Record<string, unknown>;
45
45
  /**
46
- * Shared column definitions for the requirement-correction sub-array (Nmin + P2O5/K2O/Mg),
47
- * reusable across fodder, arable and special tables. `lockRow` disables editing per row.
46
+ * Shared column definitions for the requirement-correction sub-array (P2O5/K2O/Mg),
47
+ * reusable across fodder, arable and special tables. `lockCorrections` disables
48
+ * editing per row.
48
49
  */
49
- export declare function requirementCorrectionColumns(lockRow: (row: Record<string, unknown>) => boolean): InlineTableConfig['columns'];
50
- /**
51
- * Row-transform helper shared by fodder/arable: on every edit it normalizes the managed
52
- * slots and, if the selected crop does not permit requirement corrections, strips them
53
- * entirely (so nothing is sent to the API for those rows).
54
- */
55
- export declare function stripCorrectionsUnlessPermitted(row: Record<string, unknown>, codeListKey: string): Record<string, unknown>;
56
- /**
57
- * Row-transform helper shared by fodder/arable: on crop change it applies the crop's
58
- * master-data defaults (when permitted) or strips the managed slots (when not).
59
- */
60
- export declare function applyCropChangeRules(row: Record<string, unknown>, codeListKey: string): Record<string, unknown>;
50
+ export declare function requirementCorrectionColumns(lockCorrections: (row: Record<string, unknown>) => boolean): InlineTableConfig['columns'];
61
51
  export declare const SPECIAL_CROPS_TABLE_CONFIG: InlineTableConfig;
@@ -1,3 +1,4 @@
1
+ import { InlineColumnDef } from '../../../components/inline-table/inline-table.types';
1
2
  import { FieldSpreadingFertiliserEntry } from '../field-spreading.types';
2
3
  /**
3
4
  * FertiliserTableComponent — thin wrapper around InlineTableComponent.
@@ -17,8 +18,11 @@ import { FieldSpreadingFertiliserEntry } from '../field-spreading.types';
17
18
  * 3. The generic InlineTableComponent requires no changes.
18
19
  */
19
20
  export declare class FertiliserTableComponent {
21
+ private readonly i18n;
20
22
  readonly entries: import("@angular/core").InputSignal<FieldSpreadingFertiliserEntry[]>;
21
23
  readonly entriesChange: import("@angular/core").OutputEmitterRef<FieldSpreadingFertiliserEntry[]>;
24
+ /** Row index to highlight after a validation-error deep-link (forwarded to the table). */
25
+ readonly highlightRowIndex: import("@angular/core").InputSignal<number | null>;
22
26
  /** Column/section config exposed to the template (constant — no signal needed). */
23
27
  protected readonly config: import("../../../components/inline-table/inline-table.types").InlineTableConfig;
24
28
  /** Cast typed entries to the generic Record[] expected by InlineTableComponent. */
@@ -29,15 +33,20 @@ export declare class FertiliserTableComponent {
29
33
  /**
30
34
  * Row transform for auto-populating nutrient columns when a product is selected.
31
35
  *
32
- * Also imposes `transactionUnit = 'kg'` on every edit (not just product changes) so
33
- * stale/imported rows with a different or null unit get corrected once touched —
34
- * `createRow` already defaults new rows to 'kg', this is only a safety net.
36
+ * Unit handling: `transactionUnit` is user-selectable between kg and its custom units
37
+ * (t, dt). Switching the unit converts the already-entered quantity so the amount is
38
+ * preserved; legacy/imported rows without a unit default to kg.
35
39
  *
36
40
  * Defined as an arrow-function property so `this` is never needed and the function
37
41
  * can be passed as a value to InlineTableComponent without losing its context.
38
- *
39
- * Only reacts to changes on the `fertiliserProductCategory` column key; all other
40
- * edits pass through unchanged.
41
42
  */
42
- readonly autoPopulateNutrients: (changedKey: string, newValue: unknown, row: Record<string, unknown>) => Record<string, unknown>;
43
+ readonly autoPopulateNutrients: (changedKey: string, newValue: unknown, row: Record<string, unknown>, previousRow?: Record<string, unknown>) => Record<string, unknown>;
44
+ /**
45
+ * Per-cell validation for the nutrient % columns: each value capped at 100 %
46
+ * and the sum of the four ingredients capped at 100 % per row.
47
+ * The inline table bypasses JSONForms/AJV, so these rules (mirroring the
48
+ * `maximum` / `proportionSum` keywords in schema.json) must be surfaced
49
+ * visually here — the global validation panel alone is not visible while typing.
50
+ */
51
+ readonly nutrientCellError: (row: Record<string, unknown>, col: InlineColumnDef) => string | null;
43
52
  }
@@ -5,6 +5,8 @@ export declare class FieldSpreadingComponent {
5
5
  private readonly navigationSvc;
6
6
  private readonly i18n;
7
7
  constructor();
8
+ /** Fertiliser row to highlight (set by validation deep-links, cleared by the next one). */
9
+ readonly highlightedFertiliserIndex: import("@angular/core").WritableSignal<number | null>;
8
10
  readonly schema: import("@angular/core").Signal<JsonSchema>;
9
11
  readonly localizedGeneralUi: import("@angular/core").Signal<import("@jsonforms/core").UISchemaElement>;
10
12
  readonly renderers: {
@@ -23,6 +23,7 @@ export interface FieldSpreadingIngredient {
23
23
  unit?: string | null;
24
24
  }
25
25
  export interface FieldSpreadingFertiliserEntry {
26
+ descriptor?: string | null;
26
27
  fertiliserProductCategory?: string | null;
27
28
  quantity?: number | null;
28
29
  transactionUnit?: string | null;
@@ -6,10 +6,10 @@ import { FieldSpreadingRecyclingEntry } from '../field-spreading.types';
6
6
  * 1. Provides `RECYCLING_TABLE_CONFIG` (the column/section "uischema").
7
7
  * 2. Bridges typed `FieldSpreadingRecyclingEntry[]` to/from the generic
8
8
  * `Record<string, unknown>[]` API of InlineTableComponent.
9
- * 3. Supplies `deriveUnits` as a `rowTransform` — `transactionUnit` ('kg'/'m3') and every
10
- * ingredient's `unit` ('kg/t'/'kg/m3') are fully derived from the selected product's
11
- * matterState (never user-entered) — they are separate mappings, NOT a concatenation of
12
- * one into the other (kg/kg would be wrong for solid products).
9
+ * 3. Supplies `deriveUnits` as a `rowTransform` — the base `transactionUnit` ('kg'/'m3')
10
+ * and every ingredient's `unit` ('kg/t'/'kg/m3') are derived from the selected
11
+ * product's matterState; the user may switch to a custom unit sharing the same base
12
+ * (t, dt for kg), which converts the entered quantity on the fly.
13
13
  */
14
14
  export declare class RecyclingTableComponent {
15
15
  readonly entries: import("@angular/core").InputSignal<FieldSpreadingRecyclingEntry[]>;
@@ -22,10 +22,11 @@ export declare class RecyclingTableComponent {
22
22
  * ingredient with a 0 quantity so it never reaches the final JSON. */
23
23
  onRowsChange(rows: Record<string, unknown>[]): void;
24
24
  /**
25
- * Row transform re-deriving `transactionUnit` and every ingredient's `unit` from the
26
- * product's matterState on each edit — runs unconditionally (not just when
27
- * `typeOfManureRecyclingProduct` changes) so an edit made before the product is picked still
28
- * resolves once it is.
25
+ * Row transform deriving the ingredient units from the product's matterState on each
26
+ * edit, and handling `transactionUnit`:
27
+ * - product change (or missing unit on legacy rows): reset to the derived base unit,
28
+ * - unit switch: convert the entered quantity from the previous to the new unit
29
+ * (both share the same base), so the transacted amount is preserved.
29
30
  */
30
- readonly deriveUnits: (_changedKey: string, _newValue: unknown, row: Record<string, unknown>) => Record<string, unknown>;
31
+ readonly deriveUnits: (changedKey: string, newValue: unknown, row: Record<string, unknown>, previousRow?: Record<string, unknown>) => Record<string, unknown>;
31
32
  }
@@ -19,8 +19,10 @@ export declare class FodderTableComponent {
19
19
  * when it is not permitted for the new kind.
20
20
  * - Product change: pre-fill the dry matter share (T/S %) with the product's
21
21
  * `standardDryMatterContent` (stays editable afterwards; null when none is defined).
22
- * - Units are fixed, never user-entered: quantity is always transacted in kg and the only
23
- * permitted ingredient is dry matter (T/S) expressed in % — re-appended when missing.
22
+ * - `transactionUnit` is selectable between kg and its custom units (t, dt): switching
23
+ * converts the entered quantity so the amount is preserved; rows without a unit
24
+ * default to kg. The only permitted ingredient is dry matter (T/S) in % — re-appended
25
+ * when missing.
24
26
  */
25
- readonly enforceFodderRules: (changedKey: string, newValue: unknown, row: Record<string, unknown>) => Record<string, unknown>;
27
+ readonly enforceFodderRules: (changedKey: string, newValue: unknown, row: Record<string, unknown>, previousRow?: Record<string, unknown>) => Record<string, unknown>;
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agridea/suibi-module",
3
- "version": "0.1.0-preview.01100f9",
3
+ "version": "0.1.0-preview.0808fe0",
4
4
  "scripts": {
5
5
  "ng": "ng",
6
6
  "start": "ng serve",