<Page class="page-container">
    <ActionBar flat="true">
        <NavigationButton (tap)="onBackButton()" android.systemIcon="ic_menu_back" text="Zpět"></NavigationButton>
        <Label class="action-bar-title" text="Již inventarizováno" textWrap="true"></Label>
    </ActionBar>

    <GridLayout class="page page-content" rows="auto, *">
        <GridLayout class="page-area" row="1" rows="*, auto">
            <Label class="no-data" text="Zatím nejsou inventarizované žádné položky." textWrap="true"
                   visibility="{{!items || items.length === 0 || !isAnyIDLast? 'visible' : 'collapsed'}}"></Label>

            <RadListView #list (itemTap)="onTapItem($event)" [itemTemplateSelector]="templateSelector" [items]="items"
                         class="list-group"
                         row="0" separatorColor="white"
                         visibility="{{items && items.length > 0 ? 'visible' : 'collapsed'}}">
                <ng-template let-item="item">
                    <GridLayout columns="auto, *" rows="{{item.expanded ? 'auto,auto' : 'auto'}}"
                                visibility="{{item.idLastInventory ? 'visible' : 'collapsed'}}">
                        <Label class="fas" col="0" text="{{item.expanded ? downIcon : rightIcon}}"></Label>
                        <Label [text]="item.DisplayName" class="h4" col="1" row="0" textWrap="true"></Label>

                        <StackLayout col="1" colSpan="2" row="1"
                                     visibility="{{item.expanded ? 'visible' : 'collapsed'}}">
                            <Label text="{{'Inventární číslo: ' + item.InventoryNumber}}"
                                   visibility="{{item.InventoryNumber ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Kategorie: ' + item.WarehouseItemCategory}}"
                                   visibility="{{item.WarehouseItemCategory ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Je na skladě: ' + (item.InWarehouse ? 'Ano' : 'Ne')}}"
                                   visibility="{{item.InWarehouse !== null ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Datum poslední inventorizace: ' + (item.InventoryDate | dateTime : false)}}"
                                   visibility="{{item.InventoryDate ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Datum pořízení: ' + (item.PurchaseDate | dateTime : false)}}"
                                   visibility="{{item.PurchaseDate ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Popis: ' + item.Description}}" textWrap="true"
                                   visibility="{{item.Description ? 'visible' : 'collapsed'}}"></Label>
                            <Label text="{{'Poznámka: ' + item.Note}}" textWrap="true"
                                   visibility="{{item.Note ? 'visible' : 'collapsed'}}"></Label>
                        </StackLayout>
                    </GridLayout>
                </ng-template>
            </RadListView>
            <StackLayout row="1">
                <StackLayout backgroundColor="gray" height="1"></StackLayout>
                <Label class="m-5" color="gray"
                       text="Inventarizaci je potřeba uzavřít (nebo zrušit) přes webové rozhraní nahráním příslušných dokumentů."
                       textWrap="true"></Label>
            </StackLayout>
        </GridLayout>
        <GridLayout [visibility]="othersIsLoading ? 'visible' : 'collapsed'" class="activity-indicator-wrapper"
                    rowSpan="2">
            <ActivityIndicator [busy]="othersIsLoading"></ActivityIndicator>
        </GridLayout>
    </GridLayout>
</Page>
