<Page (loaded)="onLoad()" class="page-container">
    <ActionBar flat="true">
        <NavigationButton text="Zpět" android.systemIcon="ic_menu_back" (tap)="onBackButton()"></NavigationButton>
        <Label class="action-bar-title" text="{{warehouse ? warehouse.DisplayName : ''}}" textWrap="true"></Label>
    </ActionBar>

    <FlexboxLayout *ngIf="(isLoading$ | async) == false && othersIsLoading == false" class="page page-content"
                   flexDirection="column" height="90%" justifyContent="space-between">
        <ScrollView>
            <StackLayout>
                <GridLayout class="menu-container page-area" columns="*, *" rows="auto">
                    <TopMenuItem (clickItem)="onUpdateTap()" [column]="0" [disabled]="false" [icon]="updateIcon"
                                 name="Upravit"></TopMenuItem>
                    <TopMenuItem (clickItem)="newItem()" [column]="1" [disabled]="false" [icon]="newIcon"
                                 name="Přidat novou položku"></TopMenuItem>
                </GridLayout>

                <StackLayout class="page-area">
                    <StackLayout visibility="{{warehouse ? 'visible' : 'collapsed'}}">
                        <LineInfoItem [value]="warehouse.RegistrationNumber" name="E.Č."></LineInfoItem>
                        <LineInfoItem *ngIf="warehouse.IsEnabled" name="Je aktivní"
                                      value="{{warehouse.IsEnabled ? 'Ano' : 'Ne'}}"></LineInfoItem>
                        <GridLayout (tap)="onUnitTap()" class="line-info-item m-y-2" columns="*, *" rows="auto"
                                    visibility="{{warehouse.Unit ? 'visible' : 'collapsed'}}">
                            <Label class="p-r-5" text="Přiřazená jednotka" textWrap="true"></Label>
                            <Label [text]="warehouse.Unit" class="highlighted" col="1" textAlignment="right"
                                   textWrap="true"></Label>
                        </GridLayout>
                        <GridLayout (tap)="onWarehouseMainTap()" class="line-info-item m-y-2" columns="*, *" rows="auto"
                                    visibility="{{warehouse.WarehouseMain ? 'visible' : 'collapsed'}}">
                            <Label class="p-r-5" text="Nadřazený sklad" textWrap="true"></Label>
                            <Label [text]="warehouse.WarehouseMain" class="highlighted" col="1" textAlignment="right"
                                   textWrap="true"></Label>
                        </GridLayout>

                        <AddressBlock *ngIf="warehouse.Street || warehouse.City || warehouse.Postcode"
                                      [city]="warehouse.City" [postcode]="warehouse.Postcode"
                                      [street]="warehouse.Street" label="Adresa" state="Česká republika"></AddressBlock>
                        <LineInfoItem *ngIf="warehouse.Note" name="Poznámka" value=" "></LineInfoItem>
                        <Label [text]="warehouse.Note" class="m-l-10" textWrap="true"
                               visibility="{{warehouse.Note ? 'visible' : 'collapsed'}}"></Label>


                        <StackLayout visibility="{{items.length !== 0 ? 'visible' : 'collapsed'}}">
                            <Label class="h4" text="Položky"></Label>
                            <MaterialUnitList (tapItem)="onTapItem($event)" [items]="items"></MaterialUnitList>
                        </StackLayout>
                    </StackLayout>
                    <Label *ngIf="!warehouse" class="no-data" text="O skladu nejsou dostupné žádné informace."
                           textWrap="true"></Label>
                </StackLayout>
            </StackLayout>
        </ScrollView>
    </FlexboxLayout>
    <GridLayout [visibility]="(isLoading$ | async) || othersIsLoading ? 'visible' : 'collapsed'"
                class="activity-indicator-wrapper">
        <ActivityIndicator [busy]="(isLoading$ | async) || othersIsLoading"></ActivityIndicator>
    </GridLayout>
</Page>
