diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index c4b0fbb1..62e571fc 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -29,9 +29,10 @@ 11. Do not suggest removal/rollback as a solution — find a fix for the problem. 12. All AyCode references are via **DLL** (not ProjectReference) — this is intentional. nopCommerce 4.80.9 requirement. 13. **No redundant code** — before writing new logic, search for existing methods. Reuse or extract shared logic into smaller methods rather than duplicating. -14. **Keep all .md files in sync** — when you modify code, update any affected .md file (README.md, docs/, GLOSSARY, ARCHITECTURE, CONVENTIONS, SCHEMA, etc.). If you notice any .md content does not match the current code, fix it automatically. +14. **Keep all .md files in sync** — when you modify code, update any affected .md file in the same area. If you already read an .md file during your work and notice it contradicts the current code, fix the discrepancy — but do NOT proactively scan or open .md files just to check for issues. 15. **MgGridBase** (AyCode.Blazor) is the canonical grid base for all data screens. New grids inherit `FruitBankGridBase`, set CRUD tags in the constructor, and use `MgGridWithInfoPanel` for layout. See `AyCode.Blazor/docs/MGGRID.md` for the full technical reference. Do NOT create parallel grid base classes. 16. **AyCode.Core** solution (`../../../Aycode/Source/AyCode.Core/`) contains all core framework code: SignalR base classes, serialization, binary protocol, data sources, logging. When a type is referenced but not defined in this solution, look it up in AyCode.Core source and docs. 17. **AyCode.Blazor** solution (`../../../Aycode/Source/AyCode.Blazor/`) contains all UI framework code: MgGridBase, MgGridWithInfoPanel, toolbar, layout persistence, Blazor component infrastructure. When a UI base class or component is not found here, look it up in AyCode.Blazor source and docs. 18. **Mango.Nop Libraries** (`../NopCommerce.Common/4.70/Libraries/`) — independent shared library with its own `.github/copilot-instructions.md` and `docs/`. Contains DTOs, entities, data access, and service base classes. When a DTO or entity base class is not found in this solution, look it up in the Libraries source and docs. 19. **FruitBank nopCommerce Plugin** (`../NopCommerce.Common/4.70/Plugins/Nop.Plugin.Misc.AIPlugin/`) is the server-side plugin running inside nopCommerce 4.80.9. Contains SignalR hubs/endpoints, measurement services, data access (DbTable classes), admin controllers, and AI services. When a server-side endpoint or service is referenced, look it up here. +20. **Documentation layering** — write `.md` documentation at the **defining layer** (where the code lives). Higher-layer `.md` files reference the base docs (e.g. `see AyCode.Core/docs/SIGNALR.md`) and document only project-specific overrides or extensions. Never duplicate base-layer descriptions in consumer-level docs. diff --git a/FruitBankHybrid.Shared/Components/Grids/README.md b/FruitBankHybrid.Shared/Components/Grids/README.md index 91f3e00a..a7e82459 100644 --- a/FruitBankHybrid.Shared/Components/Grids/README.md +++ b/FruitBankHybrid.Shared/Components/Grids/README.md @@ -1,16 +1,52 @@ # Grids -Domain-specific DevExpress grid components, one per entity type. All extend MgGridBase for layout persistence. +Domain-specific grid components, one per entity type. All inherit `FruitBankGridBase`. + +> For the MgGrid framework reference see: `AyCode.Blazor/docs/MGGRID.md` + +## FruitBankGridBase + +`FruitBankGridBase` is the project-specific adapter that fixes the generic parameters: + +``` +MgGridBase, TDataItem, int, LoggerClient> +``` + +Adds these defaults in `OnParametersSet` (based on `IsMasterGrid`): + +| Setting | Master | Detail | +|---|---|---| +| `SizeMode` | `Small` | `Small` | +| `ShowGroupPanel` | `true` | `false` | +| `ShowSearchBox` | `true` | `false` | +| `ShowFilterRow` | `true` | `false` | +| `FilterMenuButtonDisplayMode` | `Never` | `Always` | +| `DetailRowDisplayMode` | `Auto` | `Never` | +| `DetailExpandButtonDisplayMode` | `Auto` | `Never` | +| `PagerVisible` | `true` | `true` | +| `PageSize` | 20 (Small) / 15 | 10 | +| `AllowColumnReorder` | `true` | `true` | +| `AllowGroup` | `true` | `false` | +| `EditMode` | `EditRow` | `EditRow` | +| `FocusedRowEnabled` | `true` | `true` | +| `ColumnResizeMode` | `NextColumn` | `NextColumn` | +| `PageSizeSelectorVisible` | `true` | `true` | + +Also adds `OnCustomizeElement`: alternating row colors (`.alt-item`), header background (`#E6E6E6`), `hideDetailButton` for non-admin users. + +## Legacy MgGridBase + +`Components/MgGridBase.cs` — a non-generic legacy class that directly extends `DxGrid` and implements `IMgGridBase`. Used by older pages that predate the generic `MgGridBase<…>`. New grids should use `FruitBankGridBase` instead. ## Subfolders -| Folder | Entity | -|---|---| -| `GenericAttributes/` | GridGenericAttributeBase — context-based attribute grids | -| `OrderItems/` | GridOrderItem — order item grid (partial) | -| `Partners/` | GridPartnerBase — partner grid with SignalR | -| `Products/` | GridStockQuantityHistoryDtoBase — stock history visualization | -| `ShippingDocuments/` | GridShippingDocumentBase — shipping document management | -| `ShippingItems/` | GridShippingItemBase — shipping item detail with context awareness | -| `Shippings/` | GridShippingBase — master shipping grid | -| `StockTakingItems/` | GridStockTakingItemBase — stock taking item grid | +| Folder | Entity | Notes | +|---|---|---| +| `GenericAttributes/` | `GridGenericAttributeBase` | Context-based (ContextIds: EntityId, KeyGroup, StoreId). Parent type switching: Product, Order, OrderItem | +| `OrderItems/` | `GridOrderItem` | Commented out — placeholder | +| `Partners/` | `GridPartnerBase` | Simple master grid with CRUD tags | +| `Products/` | `GridStockQuantityHistoryDtoBase` | Detail grid under ProductDto | +| `ShippingDocuments/` | `GridShippingDocumentBase` | Parent type switching: Shipping, Product, Partner. Sets ContextIds/KeyFieldNameToParentId per parent type | +| `ShippingItems/` | `GridShippingItemBase` | Parent type switching: ShippingDocument, Shipping, Partner | +| `Shippings/` | `GridShippingBase` | Simple master grid with CRUD tags | +| `StockTakingItems/` | `GridStockTakingItemBase` | Simple master grid, GetAll only | diff --git a/FruitBankHybrid.Shared/Components/README.md b/FruitBankHybrid.Shared/Components/README.md index 61781e97..d210d49c 100644 --- a/FruitBankHybrid.Shared/Components/README.md +++ b/FruitBankHybrid.Shared/Components/README.md @@ -4,7 +4,7 @@ DevExpress Blazor grid wrappers, pallet measurement components, and toast notifi ## Key Files (Root) -- **`MgGridBase.cs`** — Base class for all DevExpress grids with layout persistence via localStorage. +- **`MgGridBase.cs`** — Legacy non-generic grid base (directly extends `DxGrid`). Used by older pages. New grids should use `FruitBankGridBase` — see [`Grids/README.md`](Grids/README.md). - **`GridProductDto.cs`** — Product data grid component. - **`OrderNotificationToast.razor`** — Toast notification for order updates. - **Pallet components** — PalletItemComponent.razor, GridShippingItemPallets.razor, GridDetailOrderItemPallets.razor. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 6a7ba11e..16558a93 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -90,12 +90,7 @@ public class FruitBankGridBase : MgGridBase, TDataItem, int, LoggerClient> ``` -Adds FruitBank-specific defaults: -- `GetLayoutUserId()` → `LoggedInModel.CustomerDto?.Id ?? 0` (per-user layout) -- Master grid: filter row, group panel, search box, `PageSize=20`, `EditMode=EditRow` -- Detail grid: no filter/group/search, `PageSize=10` -- Alternating row style (`.alt-item`), header background (`#E6E6E6`) -- Detail rows hidden for non-admin users (`hideDetailButton` CSS) +Adds FruitBank-specific defaults (master vs detail grid settings, alternating row style, header background). For the full settings table see [`FruitBankHybrid.Shared/Components/Grids/README.md`](../FruitBankHybrid.Shared/Components/Grids/README.md). ### SignalR Tag Mapping diff --git a/docs/CONVENTIONS.md b/docs/CONVENTIONS.md index 0f7a1781..22db35d4 100644 --- a/docs/CONVENTIONS.md +++ b/docs/CONVENTIONS.md @@ -33,29 +33,6 @@ 4. Wrap in `` 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. diff --git a/docs/GLOSSARY.md b/docs/GLOSSARY.md index 2505f027..e0c769da 100644 --- a/docs/GLOSSARY.md +++ b/docs/GLOSSARY.md @@ -64,16 +64,8 @@ FruitBank extends them via: ## UI / Grid Components +For MgGrid framework terms (MgGridBase, MgGridWithInfoPanel, MgGridToolbarBase, MgGridDataColumn, MgGridInfoPanel, IMgGridBase, etc.) see [`AyCode.Blazor/docs/GLOSSARY.md`](../../../Aycode/Source/AyCode.Blazor/docs/GLOSSARY.md#mggrid-system) and [`MGGRID.md`](../../../Aycode/Source/AyCode.Blazor/docs/MGGRID.md). + | Term | Definition | |---|---| -| **MgGridBase** | Abstract generic grid component from AyCode.Blazor. Extends DevExpress `DxGrid` with SignalR CRUD, layout persistence, master-detail, InfoPanel. See [AyCode.Blazor/docs/MGGRID.md](../../../Aycode/Source/AyCode.Blazor/docs/MGGRID.md). | -| **FruitBankGridBase** | Project-level adapter: fixes `TSignalRDataSource=SignalRDataSourceObservable`, `TId=int`, `TLoggerClient=LoggerClient`. Adds per-user layout, master/detail defaults. | -| **MgGridWithInfoPanel** | `DxSplitter` wrapper: grid (left pane) + InfoPanel (right pane), fullscreen overlay, splitter size persistence. | -| **MgGridToolbarBase** | `DxToolbar` base with `Grid` (IMgGridBase) reference and `RefreshClick` callback. | -| **MgGridDataColumn** | Extended `DxGridDataColumn` with URL template support (`{PropertyName}` placeholders in links). | -| **MgGridInfoPanel** | Default InfoPanel showing column-value pairs for the focused row, supports edit mode. | -| **IMgGridBase** | Public interface for grid: `IsSyncing`, `GridEditState`, `ParentGrid`, `StepPrevRow/NextRow`, layout persistence methods. | -| **MgGridEditState** | Enum: `None` (no edit), `New` (adding item), `Edit` (modifying item). | -| **AutoSaveLayoutName** | Base name for localStorage layout keys. Default: `"Grid{TDataItem.Name}"`. | -| **SignalRCrudTags** | Bundle of 5 integer message tags (GetAll, GetItem, Add, Update, Remove) for one entity type. | -| **IsMasterGrid** | `true` when `ParentDataItem == null` — the grid is a top-level (not detail) grid. | +| **FruitBankGridBase** | Project-level adapter: fixes `TSignalRDataSource=SignalRDataSourceObservable`, `TId=int`, `TLoggerClient=LoggerClient`. Adds per-user layout, master/detail defaults. See [`Grids/README.md`](../FruitBankHybrid.Shared/Components/Grids/README.md). |