<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<html>
<head>
    <meta content="issuesummary" name="decorator"/>
    <title><webwork:text name="'logwork.title'"/></title>
</head>

<body>

<script language="JavaScript">
    function selectNewEstimate()
    {
        document.forms['jiraform'].elements['new_estimate_id'].checked = true;
    }

    function resetSelect(form, selectId)
    {
        if (form[selectId])
        {
            form[selectId].selectedIndex = 0;
        }
    }
</script>

<page:applyDecorator name="jiraform">
<page:param name="action">LogWork.jspa</page:param>
<page:param name="cancelURI"><webwork:property value="issuePath"/></page:param>
<page:param name="submitName"><webwork:property value="text('common.forms.log')"/></page:param>
<page:param name="width">100%</page:param>
<page:param name="title"><webwork:text name="'logwork.title'"/></page:param>
<page:param name="description">
    <webwork:text name="'logwork.desc'"/>
</page:param>

<webwork:if test="/issueExists == true">
    <ui:textfield label="text('common.concepts.time.spent')" name="'timeLogged'">
        <ui:param name="'description'">
            <webwork:text name="'logwork.timespent.desc'">
                <webwork:param name="'value0'"><webwork:property value="daysPerWeek"/></webwork:param>
                <webwork:param name="'value1'"><webwork:property value="hoursPerDay"/></webwork:param>
            </webwork:text>
        </ui:param>
    </ui:textfield>

    <webwork:if test="hasIssuePermission('edit', issue)">
        <tr>
            <td bgcolor="#fffff0" valign="top" align="right">
                <webwork:text name="'logwork.adjustestimate'"/>:
            </td>

            <td bgcolor="#ffffff" valign=top>
                <input type="radio" name="adjustEstimate" id="auto_adjust_estimate_id" align="middle" value="auto"
                <webwork:if test="adjustEstimate == 'auto'"> checked</webwork:if>>
                <label for="auto_adjust_estimate_id">
                    <webwork:text name="'logwork.bullet1.autoadjust'"/><br>
                    &nbsp; &nbsp; &nbsp; &nbsp; <span class="subText">(<webwork:text name="'logwork.bullet1.autoadjust.desc'"/>
                    )</span><br>
                </label>

                <input type="radio" name="adjustEstimate" id="leave_estimate_id" align="middle" value="leave"
                <webwork:if test="adjustEstimate == 'leave'"> checked</webwork:if>>
                <label for="leave_estimate_id">
                    <webwork:if test="estimate==null">
                        <webwork:text name="'logwork.bullet2.estimateunknown'"/><br>
                    </webwork:if>
                    <webwork:else>
                        <webwork:text name="'logwork.bullet2.leaveestimate'">
                            <webwork:param name="'value0'"><b><webwork:property value="estimate"/></b></webwork:param>
                        </webwork:text><br>
                    </webwork:else>
                </label>

                <input type="radio" name="adjustEstimate" id="new_estimate_id" align="middle" value="new"
                <webwork:if test="adjustEstimate == 'new'"> checked</webwork:if>>
                <label for="new_estimate_id">
                    <webwork:text name="'logwork.bullet3.setnewestimate'"/> <br>
                </label>
            </td>
        </tr>
        <tr>
            <td bgcolor="#fffff0" valign="top" align="right"/>
            <td bgcolor="#ffffff" valign="top">
                <input type="text" name="newEstimate" align="middle" size="5" onChange="selectNewEstimate();"
                       value="<webwork:property value="/newEstimate"/>"> <span class="subText">(<webwork:text
                    name="'logwork.bullet3.example'"/>)</span><br>
            </td>
        </tr>
    </webwork:if>

    <ui:textarea label="text('logwork.workdesc')" name="'comment'" cols="60" rows="10"/>

    <webwork:property id="groupsNotPresent" value="groupLevels/empty"/>
    <webwork:property id="rolesNotPresent" value="roleLevels/empty"/>

    <tr>
        <td class="fieldLabelArea"><webwork:text name="'logwork.viewableby'"/>:</td>
        <td class="fieldValueArea" bgcolor="#ffffff">
            <select  name="commentLevel" id="commentLevel">
                <option value=""><webwork:text name="'comment.constants.allusers'"/></option>
                <webwork:if test="@rolesNotPresent == false">
                    <optgroup label="<webwork:text name="'common.words.project.roles'"/>">
                        <!-- TODO: keep value on error -->
                        <webwork:iterator value="roleLevels">
                            <option value="role:<webwork:property value="./id"/>" <webwork:if test="/levelSelected('role:' + ./id) == true">selected</webwork:if>><webwork:property value="./name"/></option>
                         </webwork:iterator>
                    </optgroup>
                </webwork:if>
                <webwork:if test="@groupsNotPresent == false">
                    <optgroup label="<webwork:text name="'common.words.groups'"/>">
                        <webwork:iterator value="groupLevels">
                            <option value="group:<webwork:property value="."/>" <webwork:if test="/levelSelected('group:' + .) == true">selected</webwork:if>><webwork:property value="."/></option>
                        </webwork:iterator>
                    </optgroup>
                </webwork:if>
            </select>
        </td>
    </tr>

    <ui:component name="'id'" template="hidden.jsp" theme="'single'"/>
</webwork:if>
</page:applyDecorator>
</body>
</html>