Files
DP44/docs/ai/DataPRO/Modules/ISO/ExtraProperties/ViewModel.md
2026-04-17 14:55:32 -04:00

120 lines
4.3 KiB
Markdown

---
source_files:
- DataPRO/Modules/ISO/ExtraProperties/ViewModel/ExtraPropertiesListViewModel.cs
generated_at: "2026-04-17T16:00:24.517111+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "b887776733154f74"
---
# ExtraPropertiesListViewModel Documentation
## 1. Purpose
`ExtraPropertiesListViewModel` is a Prism-based ViewModel that manages a collection of key-value pair properties ("Extra Properties") within the DataPRO ISO module. It provides CRUD operations, sorting, filtering, validation, and clipboard support (copy/paste) for extra properties. The class serves as the presentation logic layer between the `IExtraPropertiesListView` and the underlying `IExtraProperty` data model, coordinating changes through Prism's `IEventAggregator` for loose coupling with other system components.
---
## 2. Public Interface
### Constructor
```csharp
public ExtraPropertiesListViewModel(
IExtraPropertiesListView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
```
Initializes the ViewModel, sets up the View's DataContext, creates interaction requests, and subscribes to `RaiseNotification`, `BusyIndicatorChangeNotification`, and conditionally `TextPastedEvent` events.
### Properties
| Property | Type | Description |
|----------|------|-------------|
| `View` | `IExtraPropertiesListView` | Gets/sets the associated view. |
| `NotificationRequest` | `InteractionRequest<Notification>` | Interaction request for displaying notifications. |
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Interaction request for displaying confirmations. |
| `Page` | `IDataPROPage` | Gets/sets the associated page context. |
| `Parent` | `object` | Gets/sets the parent object reference. |
| `IsDirty` | `bool` | Indicates whether the data has been modified. |
| `IsBusy` | `bool` | Controls busy indicator state; notifies on change. |
| `IsMenuIncluded` | `bool` | Controls menu inclusion; notifies on change. |
| `IsNavigationIncluded` | `bool` | Controls navigation inclusion; notifies on change. |
| `IsReadOnly` | `bool` | Controls read-only state (FB14098: permission-based editing disable). |
| `AllExtraProperties` | `List<IExtraProperty>` | Complete list of all extra properties. |
| `ExtraProperties` | `ObservableCollection<IExtraProperty>` | Filtered/sorted collection bound to the view. |
| `SelectedProperties` | `IExtraProperty[]` | **Throws `NotImplementedException`**. |
### Methods
```csharp
public void SetPage(IDataPROPage page)
```
Sets the `Page` property.
```csharp
public void SetParent(object parent)
```
Sets the `Parent` property.
```csharp
public void Cleanup()
public Task CleanupAsync()
```
No-op cleanup methods. `CleanupAsync` returns `Task.CompletedTask`.
```csharp
public void Initialize()
public void Initialize(object parameter)
public void Initialize(object parameter, object model)
public Task InitializeAsync()
public Task InitializeAsync(object parameter)
```
No-op initialization methods. Async versions return `Task.CompletedTask`.
```csharp
public void Activated()
```
No-op activation method.
```csharp
public void OnPropertyChanged(string propertyName)
```
Raises `PropertyChanged` event. When `propertyName` is `"ExtraProperties"`, publishes `ExtraPropertiesChangedEvent`.
```csharp
public void Filter(object tag, string term)
```
Filters properties by search term for the specified field tag (`"Key"` or `"Value"`).
```csharp
public void Sort(object columnTag, bool columnClick)
```
Sorts properties by the specified column tag (`"Key"` or `"Value"`). Toggles sort direction on repeated clicks.
```csharp
public bool Validate(ref List<string> errors)
```
Validates properties, adding error messages to the list. Returns `true` if no new errors were added.
```csharp
public void SetExtraProperties(IList<IExtraProperty> properties)
```
Replaces all properties with the provided list, adds an empty row at the end, resets sort to Key/ascending, and applies sort/filter.
```csharp
public void CopySelected()
```
Copies `_selectedItems` to the end of `AllExtraProperties` (before the empty row), re-sorts, filters, and publishes `PageModifiedEvent`.
```csharp
public void DeleteSelected()
```
Removes `_selectedItems` from collections. Ensures an empty row remains at the end. Publishes `PageModifiedEvent`.
### Internal Methods
```csharp
internal void MarkModified(IExtraProperty iep)
```
Adds a