// Copyright © Selmo Technology GmbH. All Rights Reserved

using Microsoft.AspNetCore.Components;
using SelmoStudio.Hmi.Server.SelmoHmi.Model.Dtos;
using SelmoStudio.Hmi.Server.SelmoHmi.Sequence.Parameters;

namespace SelmoStudio.Hmi.Server.SelmoHmi.ManualControls.Components
{
    public partial class ManualControlsGroupsComponent : ISequenceParameterChangeNotifier
    {
        [Parameter]
        public string Id { get; set; }

        [Parameter]
        public Dictionary<string, List<ZoneDto>> ZoneGroups { get; set; }

        [Parameter]
        public Guid ParameterLookUpId { get; set; }

        [Parameter]
        public bool ShowManualControls { get; set; }

        [Parameter]
        public EventCallback<SequenceParameterChangedEventArgs> OnParameterChanged { get; set; }

        private List<ZoneDto> _currentZones = new();

        private void ChangeCurrentParams(KeyValuePair<string, List<ZoneDto>> zone)
        {
            ShowManualControls = ShowManualControls == true ? false : true;

            UpdateParameterChange();

            _currentZones = zone.Value;
        }

        private void BackClicked(bool clicked)
        {
            ShowManualControls = ShowManualControls == true ? false : true;

            UpdateParameterChange();
        }

        private void UpdateParameterChange()
        {
            this.NotifyParameterChanged(nameof(ShowManualControls), ShowManualControls);
        }
    }
}