@agridea/suibi-module 0.1.0-preview.68e6607 → 0.1.0-preview.69e3ad6

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 (16) hide show
  1. package/dist/elements/browser/main.js +69 -69
  2. package/dist/elements/browser/suibi-module-latest.js +69 -69
  3. package/dist/elements/browser/{suibi-module.v0.1.0-preview.68e6607.js → suibi-module.v0.1.0-preview.69e3ad6.js} +69 -69
  4. package/dist/elements/browser/version.txt +1 -1
  5. package/dist/types/app/components/inline-table/inline-table.component.d.ts +23 -0
  6. package/dist/types/app/components/inline-table/inline-table.types.d.ts +44 -2
  7. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-master-detail/farm-manure-trading-master-detail.component.d.ts +9 -15
  8. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-table/farm-manure-trading-table.component.d.ts +34 -0
  9. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-table/farm-manure-trading-table.config.d.ts +24 -0
  10. package/dist/types/app/nutrient-cycle/farm-manure-trading/index.d.ts +2 -2
  11. package/dist/types/app/nutrient-cycle/farm-manure-trading/transaction-unit.util.d.ts +2 -0
  12. package/dist/types/app/nutrient-cycle/field-spreading/field-spreading.types.d.ts +1 -0
  13. package/package.json +1 -1
  14. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-detail/farm-manure-trading-detail.component.d.ts +0 -26
  15. package/dist/types/app/nutrient-cycle/farm-manure-trading/farm-manure-trading-list/farm-manure-trading-list.component.d.ts +0 -22
  16. /package/dist/elements/browser/{suibi-module.v0.1.0-preview.68e6607.css → suibi-module.v0.1.0-preview.69e3ad6.css} +0 -0
@@ -1 +1 @@
1
- 0.1.0-preview.68e6607 68e6607
1
+ 0.1.0-preview.69e3ad6 69e3ad6
@@ -106,6 +106,29 @@ export declare class InlineTableComponent {
106
106
  addRow(): void;
107
107
  /** Removes the row at `idx` from the array. */
108
108
  removeRow(idx: number): void;
109
+ /** Ids of the expanded sub-rows panels, keyed `${rowIdx}:${col.key}` (UI-only state). */
110
+ private readonly expandedSubrows;
111
+ isSubrowsExpanded(rowIdx: number, col: InlineColumnDef): boolean;
112
+ toggleSubrows(rowIdx: number, col: InlineColumnDef): void;
113
+ /** Reads the nested key/value entries of a sub-rows column (never null). */
114
+ getSubEntries(row: Record<string, unknown>, col: InlineColumnDef): Record<string, unknown>[];
115
+ /** Options for the key select of a sub-rows column. */
116
+ getSubrowOptions(col: InlineColumnDef): BaseCodeListEntry[];
117
+ /** Localized label for a sub-entry key (descriptor designation, id as fallback). */
118
+ subrowKeyLabel(col: InlineColumnDef, keyValue: unknown): string;
119
+ /** Collapsed-cell summary, e.g. "Bovins 25 %, Porcs 75 %" ('–' when empty). */
120
+ subrowsSummary(row: Record<string, unknown>, col: InlineColumnDef): string;
121
+ /** Sum of the value fields of all sub-entries. */
122
+ subEntryTotal(row: Record<string, unknown>, col: InlineColumnDef): number;
123
+ /** Whether the sub-entry values sum to the configured expected total. */
124
+ subEntryTotalOk(row: Record<string, unknown>, col: InlineColumnDef): boolean;
125
+ addSubEntry(rowIdx: number, col: InlineColumnDef): void;
126
+ removeSubEntry(rowIdx: number, col: InlineColumnDef, subIdx: number): void;
127
+ onSubEntryKeyChange(rowIdx: number, col: InlineColumnDef, subIdx: number, value: unknown): void;
128
+ /** Commits on every keystroke (not on blur) — same rationale as `onNumberChange`. */
129
+ onSubEntryValueChange(rowIdx: number, col: InlineColumnDef, subIdx: number, event: Event): void;
130
+ /** Writes the sub-entry array back to the row, runs rowTransform, emits rowsChange. */
131
+ private updateSubEntries;
109
132
  /**
110
133
  * Core change handler: sets the new value on the row, applies the optional
111
134
  * `rowTransform` for any cross-field side-effects, then emits the updated array.
@@ -15,8 +15,45 @@ import type { BaseCodeListEntry } from '../../jsonforms/shared/option-sources/co
15
15
  /** Supported cell widget types. Extend with new literal types as needed.
16
16
  * 'readonly' renders the resolved value as plain text (no input) — for columns
17
17
  * that are fully derived from other fields and must not be user-editable.
18
- * 'checkbox' renders a boolean mat-checkbox bound to a true/false row field. */
19
- export type InlineCellType = 'select' | 'number' | 'text' | 'readonly' | 'checkbox';
18
+ * 'checkbox' renders a boolean mat-checkbox bound to a true/false row field.
19
+ * 'subrows' renders an expandable editor for a nested list of key/percentage
20
+ * pairs (e.g. manureDerivation[]) — see `InlineSubrowsConfig`. */
21
+ export type InlineCellType = 'select' | 'number' | 'text' | 'readonly' | 'checkbox' | 'subrows';
22
+ /**
23
+ * Configuration for a `type: 'subrows'` column — an expandable editor for a nested
24
+ * array of `{ key, value }` entries (e.g. manureDerivation: zoologicalAnimal +
25
+ * percentageAllocation). The collapsed cell shows a joined summary; expanding it
26
+ * opens a floating panel with one select + number input per entry, an add button,
27
+ * and a total indicator (green when the sum matches `expectedTotal`).
28
+ */
29
+ export interface InlineSubrowsConfig {
30
+ /** Path to the nested array on the row object (e.g. `'manureDerivation'`). */
31
+ arrayPath: string;
32
+ /** Field holding the code-list key in each sub-entry (e.g. `'zoologicalAnimal'`). */
33
+ keyField: string;
34
+ /** Key into the shared `CODE_LISTS` map for the key select options. */
35
+ keyCodeListKey: string;
36
+ /** i18n key for the key sub-column header inside the panel. */
37
+ keyLabelKey: string;
38
+ /** Field holding the numeric share in each sub-entry (e.g. `'percentageAllocation'`). */
39
+ valueField: string;
40
+ /** i18n key for the value sub-column header inside the panel. */
41
+ valueLabelKey: string;
42
+ /** i18n key for the "add sub-entry" button label. */
43
+ addLabelKey: string;
44
+ /** i18n key for the expand toggle label (collapsed state). */
45
+ expandLabelKey: string;
46
+ /** i18n key for the collapse toggle label (expanded state). */
47
+ collapseLabelKey: string;
48
+ /** i18n key for the total indicator label. */
49
+ totalLabelKey: string;
50
+ /** Expected sum of the value fields (e.g. 100) — the indicator turns green on match. */
51
+ expectedTotal?: number;
52
+ /** Min for the value number input (default 0). */
53
+ valueMin?: number;
54
+ /** Max for the value number input (default: none). */
55
+ valueMax?: number;
56
+ }
20
57
  /**
21
58
  * Definition for a single column in an inline table.
22
59
  *
@@ -124,6 +161,11 @@ export interface InlineColumnDef {
124
161
  arrayKeyField?: string;
125
162
  arrayKeyValue?: string;
126
163
  arrayValueField?: string;
164
+ /**
165
+ * Sub-rows editor config — required when `type: 'subrows'`, ignored otherwise.
166
+ * Drives the expandable key/percentage pair editor (see `InlineSubrowsConfig`).
167
+ */
168
+ subrows?: InlineSubrowsConfig;
127
169
  }
128
170
  /**
129
171
  * Full configuration for one inline-table instance — the "uischema" equivalent.
@@ -1,25 +1,19 @@
1
- import { TradingMode } from '../farm-manure-trading-list/farm-manure-trading-list.component';
2
1
  import { FarmManureTradingSupply, FarmManureTradingDispense } from '../farm-manure-trading.types';
2
+ /**
3
+ * Farm manure trading page — two inline tables (supply "Reprises" / dispense
4
+ * "Cessions") editing `nutrientCycle.farmManureTrading` directly. The former
5
+ * master-detail round-trip (list + JSONForms detail pane) was replaced by inline
6
+ * editing, so validation deep-links (`selectedFarmManureTrading`) are merely
7
+ * consumed and cleared — there is no detail pane left to open (fodder pattern).
8
+ */
3
9
  export declare class FarmManureTradingMasterDetailComponent {
4
10
  private readonly dataSvc;
5
11
  private readonly navigationSvc;
6
12
  constructor();
7
13
  readonly supplyRows: import("@angular/core").Signal<FarmManureTradingSupply[]>;
8
14
  readonly dispenseRows: import("@angular/core").Signal<FarmManureTradingDispense[]>;
9
- readonly activeTab: import("@angular/core").WritableSignal<import("../../../core/navigation/navigation.service").FarmManureTradingMode>;
10
- readonly selectedSupplyIndex: import("@angular/core").WritableSignal<number | null>;
11
- readonly selectedDispenseIndex: import("@angular/core").WritableSignal<number | null>;
12
- readonly currentDetail: import("@angular/core").Signal<FarmManureTradingSupply | null>;
13
- readonly currentIndex: import("@angular/core").Signal<number | null>;
14
- readonly detailOpen: import("@angular/core").Signal<boolean>;
15
- readonly activeTabIndex: import("@angular/core").Signal<0 | 1>;
16
- onTabChange(index: number): void;
17
- openDetail(mode: TradingMode, index: number): void;
18
- closeDetail(): void;
19
- addEntry(mode: TradingMode): void;
20
- deleteEntry(mode: TradingMode, index: number): void;
21
- onDetailChange(payload: FarmManureTradingSupply | FarmManureTradingDispense): void;
22
- private createEmptyEntry;
15
+ onSupplyChange(rows: FarmManureTradingSupply[]): void;
16
+ onDispenseChange(rows: FarmManureTradingDispense[]): void;
23
17
  private patchRows;
24
18
  private cloneTrading;
25
19
  }
@@ -0,0 +1,34 @@
1
+ import type { InlineTableConfig } from '../../../components/inline-table/inline-table.types';
2
+ import { FarmManureTradingMode } from '../../../core/navigation/navigation.service';
3
+ import { FarmManureTradingSupply, FarmManureTradingDispense } from '../farm-manure-trading.types';
4
+ type TradingRow = FarmManureTradingSupply | FarmManureTradingDispense;
5
+ /**
6
+ * FarmManureTradingTableComponent — thin wrapper around InlineTableComponent.
7
+ *
8
+ * Responsibilities:
9
+ * 1. Provides the per-mode column/section config (the "uischema").
10
+ * 2. Bridges typed `FarmManureTradingSupply[]`/`Dispense[]` to/from the generic
11
+ * `Record<string, unknown>[]` API of InlineTableComponent.
12
+ * 3. Supplies `deriveUnits` as a `rowTransform` — `transactionUnit` ('kg'/'m3') and
13
+ * every ingredient's `unit` ('kg/t'/'kg/m3') are fully derived from the selected
14
+ * product's matterState (never user-entered) — two independent mappings, NOT a
15
+ * concatenation of one into the other.
16
+ */
17
+ export declare class FarmManureTradingTableComponent {
18
+ readonly mode: import("@angular/core").InputSignal<FarmManureTradingMode>;
19
+ readonly entries: import("@angular/core").InputSignal<TradingRow[]>;
20
+ readonly entriesChange: import("@angular/core").OutputEmitterRef<TradingRow[]>;
21
+ protected readonly config: import("@angular/core").Signal<InlineTableConfig>;
22
+ /** Cast typed entries to generic Record[] for InlineTableComponent. */
23
+ readonly rowsForTable: import("@angular/core").Signal<Record<string, unknown>[]>;
24
+ /** Cast generic output back to typed trading rows. */
25
+ onRowsChange(rows: Record<string, unknown>[]): void;
26
+ /**
27
+ * Row transform re-deriving `transactionUnit` and every ingredient's `unit` from the
28
+ * product's matterState on each edit — runs unconditionally (not just when
29
+ * `typeOfManureRecyclingProduct` changes) so an edit made before the product is picked
30
+ * still resolves once it is.
31
+ */
32
+ readonly deriveUnits: (_changedKey: string, _newValue: unknown, row: Record<string, unknown>) => Record<string, unknown>;
33
+ }
34
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Column and section configuration for the Farm Manure Trading inline tables.
3
+ *
4
+ * This is the "uischema" for the supply ("Reprises") and dispense ("Cessions")
5
+ * tables — one InlineTableConfig per mode, mirroring recycling-table.config.ts.
6
+ * Columns:
7
+ * - Product: typeOfManureRecyclingProduct (code list filtered per mode)
8
+ * - Quantity: quantity (number)
9
+ * - Unit: transactionUnit (readonly — derived from the product's
10
+ * matterState, never user-editable, per the API spec)
11
+ * - Origin: manureDerivation[] (expandable key/share pair editor,
12
+ * expected total 100 %)
13
+ * - Nutrients: Ntot, Nsol (molecularFormula 'Nlos'), P₂O₅, K₂O, Mg read/written
14
+ * via the ingredient[] sub-array (same 5 nutrients as recycling).
15
+ * - Nutrient unit: readonly, derived from the product's matterState (kg/t | kg/m³).
16
+ */
17
+ import type { InlineTableConfig } from '../../../components/inline-table/inline-table.types';
18
+ import type { FarmManureTradingMode } from '../../../core/navigation/navigation.service';
19
+ /** Nutrient formulas tracked per trading entry, in display order. 'Nlos' = soluble nitrogen
20
+ * (matches the `molecularFormula` enum from assets/master-data/substances.json — there is no 'NSol'). */
21
+ export declare const TRADING_NUTRIENT_COLUMNS: readonly ["Ntot", "Nlos", "P2O5", "K2O", "Mg"];
22
+ export type TradingNutrientFormula = (typeof TRADING_NUTRIENT_COLUMNS)[number];
23
+ /** Builds the inline-table config for one mode ('supply' | 'dispense'). */
24
+ export declare function createTradingTableConfig(mode: FarmManureTradingMode): InlineTableConfig;
@@ -1,4 +1,4 @@
1
- export * from './farm-manure-trading-list/farm-manure-trading-list.component';
2
- export * from './farm-manure-trading-detail/farm-manure-trading-detail.component';
1
+ export * from './farm-manure-trading-table/farm-manure-trading-table.component';
2
+ export * from './farm-manure-trading-table/farm-manure-trading-table.config';
3
3
  export * from './farm-manure-trading-master-detail/farm-manure-trading-master-detail.component';
4
4
  export * from './farm-manure-trading.types';
@@ -1 +1,3 @@
1
1
  export declare function deriveTransactionUnit(productCode: string | null | undefined): string | undefined;
2
+ /** Derives the mandatory ingredient unit ('kg/t' or 'kg/m3') from the product's matterState. */
3
+ export declare function deriveTradingIngredientUnit(productCode: string | null | undefined): string | undefined;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agridea/suibi-module",
3
- "version": "0.1.0-preview.68e6607",
3
+ "version": "0.1.0-preview.69e3ad6",
4
4
  "scripts": {
5
5
  "ng": "ng",
6
6
  "start": "ng serve",
@@ -1,26 +0,0 @@
1
- import { JsonSchema, UISchemaElement } from '@jsonforms/core';
2
- import { FarmManureTradingSupply, FarmManureTradingDispense } from '../farm-manure-trading.types';
3
- type Mode = 'supply' | 'dispense';
4
- type TradingRow = FarmManureTradingSupply | FarmManureTradingDispense;
5
- export declare class FarmManureTradingDetailComponent {
6
- private readonly i18n;
7
- row: import("@angular/core").InputSignal<TradingRow | null>;
8
- index: import("@angular/core").InputSignal<number | null>;
9
- mode: import("@angular/core").InputSignal<Mode>;
10
- rowChange: import("@angular/core").OutputEmitterRef<TradingRow>;
11
- close: import("@angular/core").OutputEmitterRef<void>;
12
- readonly renderers: {
13
- tester: import("@jsonforms/core").RankedTester;
14
- renderer: any;
15
- }[];
16
- readonly suibiAjv: import("ajv").Ajv;
17
- private readonly baseSchemas;
18
- private readonly baseUis;
19
- itemSchema: import("@angular/core").Signal<JsonSchema>;
20
- localizedUi: import("@angular/core").Signal<UISchemaElement>;
21
- detailTitle: import("@angular/core").Signal<string>;
22
- jsonFormsData: import("@angular/core").Signal<(FarmManureTradingSupply & import("../../../core/schemas/ui-helper-registry").UiHelperDefinitions) | null>;
23
- onDataChange(event: any): void;
24
- private applyDerivedFields;
25
- }
26
- export {};
@@ -1,22 +0,0 @@
1
- import { FarmManureTradingSupply, FarmManureTradingDispense } from '../farm-manure-trading.types';
2
- import { FarmManureTradingMode } from '../../../core/navigation/navigation.service';
3
- export type TradingMode = FarmManureTradingMode;
4
- type TradingRow = FarmManureTradingSupply | FarmManureTradingDispense;
5
- export declare class FarmManureTradingListComponent {
6
- private readonly masterData;
7
- private readonly i18n;
8
- rows: import("@angular/core").InputSignal<TradingRow[]>;
9
- selectedIndex: import("@angular/core").InputSignal<number | null>;
10
- mode: import("@angular/core").InputSignal<FarmManureTradingMode>;
11
- select: import("@angular/core").OutputEmitterRef<number>;
12
- add: import("@angular/core").OutputEmitterRef<void>;
13
- delete: import("@angular/core").OutputEmitterRef<number>;
14
- readonly displayedColumns: string[];
15
- resolveProduct(code: string | null | undefined): string;
16
- emptyLabel(): string;
17
- emptyHintLabel(): string;
18
- addLabel(): string;
19
- headerLabel(): string;
20
- onDelete(index: number, event: Event): void;
21
- }
22
- export {};