Controllo ActionList

Il controllo ActionList elenca una serie di azioni sotto forma di pulsanti.
 
 
Personalizzazione
Per aggiungere le azioni al controllo è necessario specificare namespace e nome classe nella proprietà del controllo CustomControlClass.
 
Nel metodo InitAsync è possibile aggiungere nuove azioni attraverso i metodi nativi della classe Control.
Infine vanno specificati i metodi da eseguire in base al nome assegnato all'azione.
 
using System;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using DataWeb.Structure;
using DataWeb.Identity;
using DataWeb.Data;
using DataWeb.Data.Controls;
using DataWeb.Web.App.Infrastructure;

namespace DataWeb.Web.App.DataWeb.Data.Controls
{
    public class Product_ActionListAreaName(Form form, IServiceProvider serviceProvider) :  ActionList(form, serviceProvider)
    {
        private readonly IStringLocalizer localizer = serviceProvider.GetService<IStringLocalizer>();
        private readonly ProductStore productStore = serviceProvider.GetService<ProductStore>();

        public override async Task InitAsync(CancellationToken cancellationToken = default)
        {
            await base.InitAsync(cancellationToken);

            AddActionSetNavigation("New item",
            [
                new() { IdMaster = StructureDefinition.RootIdMaster, SectionName = AppStructureDefinition.SectionDemoAreas, IsHidden = true },
                new() { IdMaster = StructureDefinition.VoidIdMaster, SectionName = AppStructureDefinition.SectionDemoAreaData }
            ]);

            AddActionSetNavigation("Open section",
            [
                new ContextAction.Step{ IdMaster = StructureDefinition.RootIdMaster, SectionName = AppStructureDefinition.SectionDemoAreas }
            ]);

            AddActionSetRemoteAction("Notify status", "NotifyStatus", ContextActionType.Notification, isConfirmRequired: true, isSaveItemBeforeProcess: true, isReloadAfterProcess: true);

            AddActionSetRemoteAction("Set product status", "SetProductStatus", ContextActionType.Dialog, dialogFormName: "Form_ActionProductStatus", isConfirmRequired: true, isSaveItemBeforeProcess: true, isReloadAfterProcess: true);
        }

        public override async Task<ContextAction.Result> ProcessActionAsync(ContextAction action, IUser user, string itemId = null, object value = null, List<Form.ProvidedValue> controlValues = null, NavigationContext navigationContext = null, CancellationToken cancellationToken = default)
        {
            var result = await base.ProcessActionAsync(action, user, itemId, value, controlValues, navigationContext, cancellationToken);
            if (!result.IsValid)
            {
                return result;
            }

            switch (action.Name)
            {
                case "NotifyStatus":
                    result = await NotifyStatus(itemId);
                    break;
                case "SetProductStatus":
                    result = await SetProductStatus(itemId);
                    break;
            }

            return result;
        }
    }
}