<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:pd="dendrarium">

    <!-- Komponent wyswietlajacy liste odpowiedzi, np. zdan danego dendrologa

         PARAMETRY:
         String id  - id tabelki
         String title  -  tytul tabelki
         List<Answer> collisions  -  lista odpowiedzi do wyswietlenia
         Boolean anuluj  -  czy wyswietlic link Anuluj
         Boolean wybierz  -  czy wyswietlic link Wybierz
         Boolean pobierz  -  czy wyswietlic link Pobierz
         Boolean renderIfEmpty  -  czy cokolwiek wyswietlic jesli lista jest pusta
         ...

         Autor: ks
    -->

    <c:if test="#{renderIfEmpty or collisions.rowCount>0}">
        <p>
            <h3 class="titlebar">#{title}</h3>

            <!-- <h:form id="#{id}"> -->

            <h:outputText id="#{id}_msg" value="Nie znaleziono kolizji" rendered="#{collisions.rowCount==0}"/>
            <h:dataTable id="#{id}_tab" value="#{collisions}" var="c" rendered="#{collisions.rowCount>0}" styleClass="mytab" columnClasses="ccol1,ccol2,ccol3,ccol4,ccol5,ccol6,ccol7,ccol8">
                <h:column id="#{id}_c1">
                    #{c.index+1} / #{c.packet.size}
                </h:column>
                <h:column id="#{id}_c11">
                    #{c.packet.name}
                </h:column>
                <h:column id="#{id}_c2">
                    #{c.description}
                </h:column>
                <h:column id="#{id}_c3">
                    #{c.state}
                </h:column>
                <h:column id="#{id}_c4">
                    #{c.user1Answer.user.name}
                </h:column>
                <h:column id="#{id}_c5">
                    #{c.user2Answer.user.name}
                </h:column>
                <h:column id="#{id}_c6" rendered="#{typ}">
                    #{c.superAnswerType}
                </h:column>
                <h:column id="#{id}_c7" headerClass="klasa">

                    <s:link value="Wybierz" action="#{workOnAnswer.select}" rendered="#{wybierz}">
                        <f:param name="answerId" value="#{c.id}" />
                        <f:param name="colMode" value="1" />
                    </s:link>
                    <h:outputText value ="&#160;&#160;"  rendered="#{wybierz}"/>

                    <s:link value="Anuluj" action="#{workOnCollisionStateless.cancel}" rendered="#{anuluj}">
                        <f:param name="collisionId" value="#{c.id}" />
                    </s:link>
                    <h:outputText value ="&#160;&#160;"  rendered="#{anuluj}"/>

                    <c:if test="#{pobierz}">
                        <a href="javascript:toggleVisibility('pobierz_#{id}_#{c.id}')"> Pobierz</a>

                        <div style="visibility:hidden; display:none" id="pobierz_#{id}_#{c.id}">
                            <h:form id="pobierzform_#{id}_#{c.id}" action="#{download.download}">
                                <h:selectOneMenu id="profilemenu#{id}" value="#{download.exportFormat}" >
                                    <s:selectItems value="#{download.availableExportFormats}" var="format" label="#{format.name}" />
                                    <s:convertEnum/>
                                </h:selectOneMenu>
                                <h:commandButton action="#{download.download}" value="OK" />
                                <input type="hidden" name="answerId" value="#{c.superAnswer.id}" />
                            </h:form>
                        </div>
                    </c:if>
                </h:column>
            </h:dataTable>
            <!-- </h:form> -->
        </p>
    </c:if>
</ui:composition>