// Copyright © Selmo Technology GmbH. All Rights Reserved

using Microsoft.AspNetCore.Components;
using Novus.Shared.Types.IssueHandling;
using SelmoStudio.Hmi.Server.SelmoHmi.Shared.WellKnownTypes;

namespace SelmoStudio.Hmi.Server.SelmoHmi.Issues.Components
{
    public partial class IssueReportComponent
    {
        private IEnumerable<Severity> selectedSeverities;

        private IEnumerable<object> severities = Enum.GetValues(typeof(Severity)).Cast<Severity>().Select(s => new { Text = $"{s}", Value = s });

        [Parameter]
        public string Id { get; set; }

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

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

        [Parameter]
        public IEnumerable<Issue> Issues { get; set; }

        [Parameter]
        public int Width { get; set; }

        [Parameter]
        public int Height { get; set; }

        [Parameter]
        public WellKnownLengthUnits WidthUnit { get; set; }

        [Parameter]
        public WellKnownLengthUnits HeightUnit { get; set; }

        private void OnSelectedSeverityChange(object value)
        {
            if (selectedSeverities != null && !selectedSeverities.Any())
            {
                selectedSeverities = null;
            }
        }
    }
}