54 lines
3.7 KiB
Markdown
54 lines
3.7 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/Modules/Groups/GroupList/ViewModel/GroupListViewModel.cs
|
||
|
|
generated_at: "2026-04-17T16:00:47.692641+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "b926e051d9942d3a"
|
||
|
|
---
|
||
|
|
|
||
|
|
# GroupListViewModel Documentation
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
`GroupListViewModel` is the presentation logic layer for the Group List module in a WPF/Prism-based application. It manages the display, filtering, sorting, and manipulation of group entities. The class serves as a mediator between the `IGroupListView` view and the underlying `Group` model, handling user interactions (selection, double-click editing, filtering), coordinating with the event system for cross-module communication, and enforcing tag-based access control for non-administrator users.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### Methods
|
||
|
|
|
||
|
|
| Signature | Description |
|
||
|
|
|-----------|-------------|
|
||
|
|
| `void ClearAllFilters()` | Clears all field-based filters by emptying the internal `_filterByField` dictionary. |
|
||
|
|
| `void MouseDoubleClick(int index)` | Publishes a `GroupListEditGroupEvent` with the group ID when a single group is selected and the index is valid. |
|
||
|
|
| `void Filter(string term)` | Sets `CurrentSearchTerm` and triggers a sort/refresh operation. |
|
||
|
|
| `IGroup GetGroup(int? id, bool updateTags = true)` | Retrieves a group by ID. Optionally updates tags from the database. Returns an empty `Group` if not found or if `id < 0`. |
|
||
|
|
| `IGroup GetGroup(string displayName)` | Retrieves a non-embedded group by display name. Returns `null` if no non-embedded match is found. |
|
||
|
|
| `IGroup[] GetGroups(int[] ids)` | Returns all groups whose IDs are contained in the provided array. |
|
||
|
|
| `IGroup[] GetAllGroups()` | Returns all groups from the model layer. |
|
||
|
|
| `void DeleteGroups(int[] ids)` | Deletes groups by ID, nullifies `StaticGroupId` on related embedded groups, updates `AllGroups`, and re-applies filters. |
|
||
|
|
| `IGroup CreateGroup()` | Creates a new `Group` instance (marked as new). |
|
||
|
|
| `IGroup CreateGroup(SqlDataReader reader, List<string> includedHardwareStringList, List<int> dasIdList)` | Creates a `Group` from a SQL data reader. |
|
||
|
|
| `IGroup CreateGroup(IGroupDbRecord groupRecord, List<string> includedHardwareStringList, List<int> dasIdList)` | Creates a `Group` from a database record object. |
|
||
|
|
| `IGroup CreateGroup(List<string> includedHardwareStringList)` | Creates a `Group` with specified hardware strings. |
|
||
|
|
| `void Filter(object tag, string term)` | Parses `tag` as a `GroupFields` enum, updates filter dictionary, and triggers filtering. |
|
||
|
|
| `void OnSetActive(object page, bool groupTile, object o)` | Initializes the view model when activated. Filters groups by user role and tag compatibility. If `groupTile` is true, loads test setup lists asynchronously. |
|
||
|
|
| `void Unset()` | Clears all group arrays, filters, and publishes a `ListViewStatusEvent` with `Unloaded` status. |
|
||
|
|
| `void Sort(object o, bool bColumnClick)` | Sorts `Groups` by the specified field. Toggles sort direction on repeated column clicks. Applies both search term and field-based filters. |
|
||
|
|
| `void Cleanup()` | Empty implementation. |
|
||
|
|
| `Task CleanupAsync()` | Returns `Task.CompletedTask`. |
|
||
|
|
| `void Initialize()` | Empty implementation. |
|
||
|
|
| `void Initialize(object parameter)` | Empty implementation. |
|
||
|
|
| `void Initialize(object parameter, object model)` | Empty implementation. |
|
||
|
|
| `Task InitializeAsync()` | Returns `Task.CompletedTask`. |
|
||
|
|
| `Task InitializeAsync(object parameter)` | Returns `Task.CompletedTask`. |
|
||
|
|
| `void Activated()` | Empty implementation. |
|
||
|
|
| `void OnPropertyChanged(string propertyName)` | Raises the `PropertyChanged` event. |
|
||
|
|
|
||
|
|
### Properties
|
||
|
|
|
||
|
|
| Property | Type | Description |
|
||
|
|
|----------|------|-------------|
|
||
|
|
| `View` | `IGroupListView` | The associated view instance. Set via constructor; `DataContext` is
|