Table of Contents

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

TUIView

The 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

items IEnumerable<TUIView>

Items to add.

asNewItem bool

A value indicating whether added items should be considered new items.

Returns

Task<bool>

A Task representing the asynchronous operation. The task result contains true if items have been added, false otherwise.

AddAsync(params TUIView[])

Adds the specified items at the end of the datasource.

Task<bool> AddAsync(params TUIView[] items)

Parameters

items TUIView[]

Items to add.

Returns

Task<bool>

A Task representing the asynchronous operation. The task result contains true if items have been added, false otherwise.

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 null if 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

source TUIView

The 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 null if 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

items IEnumerable<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

items 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.

GetCloningAllowed(TUIView)

Gets a value indicating whether cloning an item is allowed.

bool GetCloningAllowed(TUIView item)

Parameters

item TUIView

Item on which the CloningAllowed value must be checked.

Returns

bool

true if the item can be cloned; otherwise, false.

GetDeletionAllowed(TUIView)

Gets a value indicating whether deleting an item is allowed.

bool GetDeletionAllowed(TUIView item)

Parameters

item TUIView

Item on which the DeletionAllowed value must be checked.

Returns

bool

true if 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

item TUIView

Item on which the UpdateAllowed value must be checked.

Returns

bool

true if 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

containerId string

The container identifier.

Returns

ViewModel<TUIView>

The view model of the founded view container.

Type Parameters

TContainerUIView

The 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

position int

Position.

items IEnumerable<TUIView>

Items to insert.

asNewItem bool

A value indicating whether inserted items should be considered new items.

Returns

Task<bool>

A Task representing the asynchronous operation. The task result contains true if the items have been inserted, false otherwise.

InsertAsync(int, params TUIView[])

Inserts the specified items at the specified position.

Task<bool> InsertAsync(int position, params TUIView[] items)

Parameters

position int

Position.

items TUIView[]

Items to insert.

Returns

Task<bool>

A Task representing the asynchronous operation. The task result contains true if items have been inserted, false otherwise.

InsertNewAsync(int)

Creates a new item and inserts it at the specified position.

Task<TUIView?> InsertNewAsync(int position)

Parameters

position int

Position.

Returns

Task<TUIView>

A Task representing the asynchronous operation. The task result contains the new item or null if inserting has been canceled.

IsSelected(TUIView)

Gets a value indicating whether the specified item is selected.

bool IsSelected(TUIView item)

Parameters

item TUIView

The item.

Returns

bool

true if the item is selected, otherwise false.

SelectItemAsync(TUIView)

Selects the specified item of the datasource.

Task SelectItemAsync(TUIView item)

Parameters

item TUIView

The item to select.

Returns

Task

A Task representing the asynchronous operation.

UnselectItemAsync(TUIView)

Unselects the specified item of the datasource.

Task UnselectItemAsync(TUIView item)

Parameters

item TUIView

The item to unselect.

Returns

Task

A Task representing the asynchronous operation.