FruitBankHybridApp/docs/CONVENTIONS.md

64 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Conventions
> For core framework conventions see: `../../../Aycode/Source/AyCode.Core/docs/CONVENTIONS.md`
> For UI framework conventions see: `../../../Aycode/Source/AyCode.Blazor/docs/CONVENTIONS.md`
## Naming
- **fb prefix** on database tables: `fbPallet`, `fbShipping`, `fbShippingItem`, etc.
- **Dto suffix** for DTOs wrapping nopCommerce entities: `OrderDto`, `OrderItemDto`, `ProductDto`.
- **XxxItemPallet** for measurement records: `ShippingItemPallet`, `OrderItemPallet`, `StockTakingItemPallet`.
- **Grid prefix** for Blazor grid components: `GridPartnerBase`, `GridShippingBase`, etc.
- **GridXxxBase** = C# code-behind class inheriting `FruitBankGridBase<TDataItem>`.
- **GridXxx.razor** = Razor markup using `<GridXxxBase>` with `<Columns>` and `<DetailRowTemplate>`.
- **OnGrid prefix** for MgGridBase event parameters: `OnGridItemDeleting`, `OnGridEditModelSaving`, `OnGridFocusedRowChanged`, etc. (avoids collision with DxGrid base events).
- **SignalRTags** constants use numeric ranges by domain (see `FruitBank.Common/SignalRs/`).
## Patterns
- **MeasuringItemPalletBase** as abstract base for all three measurement hierarchies.
- **GenericAttributes** for extending nopCommerce entities with custom data (IsMeasurable, Tare, AverageWeight).
- **Composition interfaces** for measurement traits: IMeasuringValues = IMeasuringWeights + IMeasuringQuantity.
- **DevExpress DxGrid** with `AcSignalRDataSource` for real-time grid data.
- **MgGridBase** — canonical grid base from AyCode.Blazor (see [MGGRID.md](../../../Aycode/Source/AyCode.Blazor/docs/MGGRID.md)). Provides SignalR CRUD, layout persistence, master-detail, InfoPanel, fullscreen.
- **FruitBankGridBase** — project adapter that fixes `TId=int`, `TLoggerClient=LoggerClient`, adds per-user layout and master/detail defaults.
- **FruitBankSignalRClient** as single hub client for all server communication.
- **DatabaseClient** for client-side caching with ConcurrentDictionary tables.
### Grid Creation Checklist
1. Create `GridXxxBase.cs` inheriting `FruitBankGridBase<TEntity>`.
2. Set CRUD tags in constructor: `GetAllMessageTag`, `AddMessageTag`, `UpdateMessageTag`, `RemoveMessageTag`.
3. Create `GridXxx.razor` with `<GridXxxBase>`, `<Columns>`, optional `<DetailRowTemplate>`.
4. Wrap in `<MgGridWithInfoPanel>` if InfoPanel is needed.
5. For detail grids: set `ParentDataItem`, `KeyFieldNameToParentId`, `ContextIds`.
### Grid Layout Storage Keys
```
{AutoSaveLayoutName}_{Master|ParentTypeName}_{AutoSave|UserSave}_{UserId}
```
Example: `GridShipping_Master_AutoSave_42` — auto-saved layout for shipping master grid, user #42.
## Code Reuse
- Before writing new code, search the codebase for existing implementations.
- If a method does most of what you need, extract the shared part into a smaller reusable method rather than copying and modifying.
- Prefer composing existing helpers over creating parallel implementations.
## Critical Rules
- **MeasuringStatus.Finnished** — intentional legacy typo. Do NOT fix.
- **Shipping = INBOUND, Order = OUTBOUND** — never confuse directions.
- **Pallet = measurement record** — always created, even for non-measurable products.
- **NetWeight is calculated, never stored** — GrossWeight PalletWeight (TrayQuantity × TareWeight).
- **DLL references** to AyCode projects are intentional — do not convert to ProjectReference.
- Do not suggest removal/rollback as a solution — find a fix.
## UI (Hungarian Locale)
- Status labels and UI text are in Hungarian.
- MeasuringStatus display: "Nincs elkezdve", "Elkezdve", "Kész", "Auditált".
- Date format follows Hungarian conventions.