Interface IViewModel<TUIView>
- Namespace
- GroupeIsa.Neos.Designer.UIAbstractions
- Assembly
- GroupeIsa.Neos.Designer.UIAbstractions.dll
Provides the functionalities of the MVVM view model of an UI view.
public interface IViewModel<TUIView> : IViewModel, IBaseViewModel where TUIView : class, IUIView
Type Parameters
TUIViewThe type of UI view on which the view model is based.
- Inherited Members
Properties
CreatedItems
Gets the new items of the datasource.
IReadOnlyCollection<TUIView> CreatedItems { get; }
Property Value
- IReadOnlyCollection<TUIView>
Datasource
Gets the datasource.
IDatasource<TUIView> Datasource { get; }
Property Value
- IDatasource<TUIView>
DatasourceCurrent
Gets the item at the Position in the datasource.
Null when Position is -1 or greater than the position of the last item of the datasource.
Warning : not to be confused with the Item property of actions / event rules which designates the datasource item on which an action / event rule is triggered.
In most cases, you should use the Item property when available instead of DatasourceCurrent.
TUIView? DatasourceCurrent { get; }
Property Value
- TUIView
Examples
The following example shows the access to the instance at the current position.
If the position is valid, the OrderedAt property of the instance is set to the current date.
if (DatasourceCurrent != null)
{
DatasourceCurrent.OrderedAt = DateTime.Now;
}
ModifiedItems
Gets the modified items of the datasource.
IReadOnlyCollection<TUIView> ModifiedItems { get; }
Property Value
- IReadOnlyCollection<TUIView>
PersistenceErrorItems
Gets the elements with at least one persistence error.
IReadOnlyCollection<TUIView> PersistenceErrorItems { get; }
Property Value
- IReadOnlyCollection<TUIView>
SelectedItems
Gets the selected items in the datasource.
IReadOnlyCollection<TUIView> SelectedItems { get; }
Property Value
- IReadOnlyCollection<TUIView>
Methods
AddAsync(IEnumerable<TUIView>, bool)
Adds the specified items at the end of the datasource.
Task<bool> AddAsync(IEnumerable<TUIView> items, bool asNewItem = false)
Parameters
itemsIEnumerable<TUIView>Items to add.
asNewItemboolA value indicating whether added items should be considered new items.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains
trueif items have been added,falseotherwise.
AddAsync(params TUIView[])
Adds the specified items at the end of the datasource.
Task<bool> AddAsync(params TUIView[] items)
Parameters
itemsTUIView[]Items to add.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains
trueif items have been added,falseotherwise.
Examples
The following example shows how to add an item to the data source.
Order item = new Order();
if (await AddAsync(item))
{
Console.WriteLine("Item added");
}
else
{
Console.WriteLine("Item not added");
}
AddNewAsync()
Creates a new item and adds it at the end of the datasource.
Task<TUIView?> AddNewAsync()
Returns
- Task<TUIView>
A Task representing the asynchronous operation. The task result contains the new item or
nullif adding has been canceled.
Examples
The following example shows how to create and add a new item to the data source.
IOrder? item = await AddNewAsync();
CloneAsync(TUIView)
Creates a new item that is a copy of the specified source item and adds it at the end of the datasource.
Task<TUIView?> CloneAsync(TUIView source)
Parameters
sourceTUIViewThe source item from which the new item will be cloned.
Returns
- Task<TUIView>
A Task representing the asynchronous operation. The task result contains the new item that is the result of the cloning operation or
nullif cloning has been canceled.
CreateNewItem()
Creates a new item.
TUIView CreateNewItem()
Returns
- TUIView
The created item.
Remarks
The item is not added to the datasource.
DeleteDataAsync(IEnumerable<TUIView>)
Removes the specified items from the server via an API call.
Task<bool> DeleteDataAsync(IEnumerable<TUIView> items)
Parameters
itemsIEnumerable<TUIView>Items to remove.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains a value indicating whether the items have been removed.
DeleteDataAsync(params TUIView[])
Removes the specified items from the server via an API call.
Task<bool> DeleteDataAsync(params TUIView[] items)
Parameters
itemsTUIView[]Items to remove.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains a value indicating whether the items have been removed.
EnsureDataLoadedAsync(IDatasource<TUIView>)
Ensures data is loaded.
Task EnsureDataLoadedAsync(IDatasource<TUIView> datasource)
Parameters
datasourceIDatasource<TUIView>The datasource to ensure data is loaded for.
Returns
Remarks
This method should be used exclusively for sub-view models that are not configured for automatic loading.
GetCloningAllowed(TUIView)
Gets a value indicating whether cloning an item is allowed.
bool GetCloningAllowed(TUIView item)
Parameters
itemTUIViewItem on which the
CloningAllowedvalue must be checked.
Returns
- bool
trueif the item can be cloned; otherwise,false.
GetDeletionAllowed(TUIView)
Gets a value indicating whether deleting an item is allowed.
bool GetDeletionAllowed(TUIView item)
Parameters
itemTUIViewItem on which the
DeletionAllowedvalue must be checked.
Returns
- bool
trueif the item can be deleted; otherwise,false.
GetFullDatasource()
Gets the original datasource when the UI view datasource comes from a computed source.
When a parent UI view displays in its template the current UI view, it can provide a computed source. This source can contain different items from the ones that should originally be included in the datasource. This is typically used to provide a filtered datasource to a sub-view.
GetFullDatasource() gets the original datasource instead on the one from the computed source.
IDatasource<TUIView> GetFullDatasource()
Returns
- IDatasource<TUIView>
The original datasource.
Remarks
If the datasource does not come from a computed source, GetFullDatasource() return the same value as Datasource.
GetUpdateAllowed(TUIView)
Gets a value indicating whether updating an item is allowed.
bool GetUpdateAllowed(TUIView item)
Parameters
itemTUIViewItem on which the
UpdateAllowedvalue must be checked.
Returns
- bool
trueif the item can be updated; otherwise,false.
GetViewModelOfViewContainer<TContainerUIView>(string)
Gets the view model of a view container in the current UIView by the specified container identifier.
ViewModel<TUIView> GetViewModelOfViewContainer<TContainerUIView>(string containerId) where TContainerUIView : class, IUIView
Parameters
containerIdstringThe container identifier.
Returns
- ViewModel<TUIView>
The view model of the founded view container.
Type Parameters
TContainerUIViewThe type of the uiview loaded in the view container.
InsertAsync(int, IEnumerable<TUIView>, bool)
Inserts the specified items at the specified position.
Task<bool> InsertAsync(int position, IEnumerable<TUIView> items, bool asNewItem = false)
Parameters
positionintPosition.
itemsIEnumerable<TUIView>Items to insert.
asNewItemboolA value indicating whether inserted items should be considered new items.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains
trueif the items have been inserted,falseotherwise.
InsertAsync(int, params TUIView[])
Inserts the specified items at the specified position.
Task<bool> InsertAsync(int position, params TUIView[] items)
Parameters
positionintPosition.
itemsTUIView[]Items to insert.
Returns
- Task<bool>
A Task representing the asynchronous operation. The task result contains
trueif items have been inserted,falseotherwise.
InsertNewAsync(int)
Creates a new item and inserts it at the specified position.
Task<TUIView?> InsertNewAsync(int position)
Parameters
positionintPosition.
Returns
- Task<TUIView>
A Task representing the asynchronous operation. The task result contains the new item or
nullif inserting has been canceled.
IsSelected(TUIView)
Gets a value indicating whether the specified item is selected.
bool IsSelected(TUIView item)
Parameters
itemTUIViewThe item.
Returns
- bool
trueif the item is selected, otherwisefalse.
ReloadDataAsync(IEnumerable<TUIView>)
Reloads the specified items from the server via an API call.
Task ReloadDataAsync(IEnumerable<TUIView> items)
Parameters
itemsIEnumerable<TUIView>Items to reload.
Returns
ReloadDataAsync(TUIView)
Reloads the specified item from the server via an API call.
Task ReloadDataAsync(TUIView item)
Parameters
itemTUIViewItem to reload.
Returns
SelectItemAsync(TUIView)
Selects the specified item of the datasource.
Task SelectItemAsync(TUIView item)
Parameters
itemTUIViewThe item to select.
Returns
SetCurrentAndSelectAsync(TUIView)
Sets the current item, selects it and unselects the others.
Task SetCurrentAndSelectAsync(TUIView item)
Parameters
itemTUIViewThe item to select.
Returns
UnselectItemAsync(TUIView)
Unselects the specified item of the datasource.
Task UnselectItemAsync(TUIView item)
Parameters
itemTUIViewThe item to unselect.