<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.CheckPoints.CheckPointEditPage"
             xmlns:local="clr-namespace:WorkFlowCheck.MAUI.Pages.BaseStock.CheckPoints"
             xmlns:templateselectors="clr-namespace:WorkFlowCheck.MAUI.TemplateSelectors"
             Title="{Binding CheckPointDTO.ShortName}">
    <StackLayout Padding="20">
        <!-- Cím: Edit Item -->
        <Label Text="Ellenőrzési pont adatai" FontSize="24" HorizontalOptions="Center" />

        <Frame BorderColor="Gray" Padding="5" Margin="1" HasShadow="True">
            <VerticalStackLayout>
                <!-- Editálható név mező -->
                <Entry Text="{Binding CheckPointDTO.ShortName}" Placeholder="Edit item name" />
                <Entry Text="{Binding CheckPointDTO.Code}" Placeholder="Edit item name" />
            </VerticalStackLayout>
        </Frame>
        <Grid ColumnSpacing="46" Margin="0,10,0,10">
            <!-- 10 pixel térköz az oszlopok között -->
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="Auto" />
                <!-- Üres tér a két gomb között -->
                <ColumnDefinition Width="200" />
            </Grid.ColumnDefinitions>

            <Button Text="Save" Command="{Binding SaveCommand}" Grid.Column="0"/>
            <Button Text="Cancel" Command="{Binding CancelCommand}" Grid.Column="2"/>
        </Grid>
        <Label Text="Ellenőrzési feladatok" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" />
        <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
            <CollectionView x:Name="CheckPointCheckListRows" 
                            HeightRequest="440"
                            
                            ItemTemplate="{StaticResource AnswerTemplateSelector}">
                <CollectionView.EmptyView>
                    <Label Text="Nincsenek feladatok." HorizontalOptions="Center" VerticalOptions="Center"/>
                </CollectionView.EmptyView>
            </CollectionView>
        </Frame>
    </StackLayout>
    <ContentPage.Resources>
        <DataTemplate x:Key="I_N_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*,*">
                        <Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center"/>
                        <Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="P_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*">
                        <Label Text="Fénykép készítése szükséges" Grid.Column="0" HorizontalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="V_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*">
                        <Label Text="Érték megadása szükséges" Grid.Column="0" HorizontalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="SI_N_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*,*">
                        <Label Text="I" Grid.Column="0" BackgroundColor="Yellow" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                        <Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="I_SN_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*,*">
                        <Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                        <Label Text="N" Grid.Column="1" BackgroundColor="Yellow" TextColor="Black"  HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="PI_N_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*,*">
                        <Label Text="I" Grid.Column="0" BackgroundColor="Red" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                        <Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <DataTemplate x:Key="I_PN_Template">
            <Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
                <Grid ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
                    <Grid Grid.Column="1" ColumnDefinitions="*,*">
                        <Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                        <Label Text="N" Grid.Column="1" BackgroundColor="Red" TextColor="Black"  HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                    </Grid>
                </Grid>
            </Frame>
        </DataTemplate>
        <templateselectors:AnswerTypeTemplateSelector x:Key="AnswerTemplateSelector"
            I_N_Template="{StaticResource I_N_Template}"
            P_Template="{StaticResource P_Template}"
            SI_N_Template="{StaticResource SI_N_Template}"
            I_SN_Template="{StaticResource I_SN_Template}"
            PI_N_Template="{StaticResource PI_N_Template}"
            I_PN_Template="{StaticResource I_PN_Template}" 
            V_Template="{StaticResource V_Template}"/>
    </ContentPage.Resources>
</ContentPage>