<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:e="http://www.ivu.de/elect/tags">


    <!--@elvariable id="msgs" type="de.ivu.elect.business.lokalisierung.control.LokalisierungResourceBundle"-->

    <!--@elvariable id="backingView" type="de.ivu.elect.presentation.exchange.AbstractImportSearchView"-->

    <!--@elvariable id="actionMenu" type="de.ivu.elect.jee.presentation.action.AbstractActionMenuModelBuilder"-->
    <ui:param name="actionMenu" value="#{empty actionMenu ? dateiImportSearchActionMenu : actionMenu}"/>

    <!--@elvariable id="editAction" type="de.ivu.elect.jee.presentation.action.AbstractBaseActionEntry"-->
    <ui:param name="editAction" value="#{empty editAction ? dateiImportEditAction : editAction}"/>

    <e:form id="frmImport">
        <p:panel id="ctnExport">
            <ui:insert name="preImportReport" />

            <!-- ELECT-1504 -->
            <p:remoteCommand name="finish" actionListener="#{importSearchAfterUploadRedirect.finish}"/>

            <p:fileUpload id="fileUploadComponent" rendered="#{backingView.isUploadPossible()}" disabled="false" required="false" mode="advanced" multiple="false" auto="true"
                          listener="#{backingView.handleFileUpload}" update=":frmSearchResult:tblSearchResult" oncomplete="finish();"
                          allowTypes="#{backingView.fileUploadAllowTypes}"
                          accept="#{backingView.fileUploadAccept}"
                          label="#{backingView.fileUploadLabel}"
                          uploadLabel="#{msgs['entity.upload.action.upload']}"
                          cancelLabel="#{msgs['entity.upload.action.cancel']}"
                          invalidFileMessage="#{msgs['entity.upload.action.upload.invalid.file.message']}"
                          invalidSizeMessage="#{msgs['entity.upload.action.upload.invalid.size.message']}"
                          virusScan="#{virusScanAvailable.virusScanAvailable}"
            />

            <h:outputText rendered="#{not backingView.isUploadPossible()}" value="#{msgs[backingView.getUploadNotPossibleMessageKey()]}" />
        </p:panel>
    </e:form>

    <ui:fragment rendered="#{backingView.searchRendered}">
    <e:formSearch>
        <ui:define name="dataTable">
            <e:searchTable searchView="#{dateiImportSearchView}" value="#{backingView.getSearchResult()}"
                           actionMenu="#{actionMenu}"
                           columnBuilder="#{dateiImportColumnBuilder}">
                <p:ajax event="rowDblselect" listener="#{editAction.onRowDblselect}"/>
            </e:searchTable>
        </ui:define>
    </e:formSearch>
    </ui:fragment>

    <e:modalDialog dialogName="EditComment" header="#{msgs['entity.edit.action.comment']}">
            <p:panel id="ctnEditKommentar" rendered="#{backingView.isEntitySelected()}">
                <e:inputTextarea id="inputKommentar"
                                 maxlength="#{dateiImportMeta.kommentarMaxLength}"
                                 label="#{msgs['entity.edit.action.comment']}"
                                 value="#{dateiImportConversationSelect.entity.kommentar}"/>

                <f:facet name="footer">
                    <p:commandButton id="btnOk" value="#{msgs['entity.edit.action.save']}"
                                     action="#{backingView.commitComment}"/>

                    <p:commandButton id="btnCancel" onclick="PF('dlgEditCommentWidget').hide()" update="btnOk"
                                     value="#{msgs['entity.edit.action.cancel']}" styleClass="ui-button--flat" />
                </f:facet>
            </p:panel>
    </e:modalDialog>

    <e:modalDialog dialogName="DeleteConfirm" header="#{msgs['entity.edit.action.delete.confirm']}">
            <p:panel id="ctnDeleteConfirm"
                     rendered="#{backingView.isEntitySelected() and backingView.getSelectedEntity().isLoeschenMoeglich(principal)}">
                <h:outputFormat value="#{msgs['datei.import.edit.action.delete.confirm.message']}">
                    <f:param value="#{backingView.getSelectedEntity().datei.dateiname}"/>
                </h:outputFormat>

                <f:facet name="footer">
                    <p:commandButton id="btnDelete" action="#{backingView.delete}" ajax="false" immediate="true"
                                     value="#{msgs['entity.edit.action.delete']}"/>

                    <p:commandButton id="btnCancelDialog" onclick="PF('dlgDeleteConfirmWidget').hide()"
                                     value="#{msgs['entity.edit.action.cancel']}" styleClass="ui-button--flat" />
                </f:facet>
            </p:panel>
    </e:modalDialog>

</ui:composition>
