<%@ page contentType="text/html; charset=UTF-8"%><%@ include file="/WEB-INF/jspf/include/taglibs.jsp"%>

<div id="paramResult"></div>

<div style="margin: 10px auto;"><button class="btn btn-secondary" onclick="showBlock( 'parametersRoot', 'list', parametersQuery ); return false;">К списку...</button></div>			

<form>
<div class="tile">
	<div class="titleFont3 titleBottomLine">Редактор параметра</div>
	<div class="paramEditorTitle" style="margin-top: 20px;">${pref.title}</div>
	<div class="paramEditors" style="width: 100%; margin-top: 10px;">
	<c:forEach var="email" varStatus="status" items="${emails}">
		<div class="flexRow" style="margin-top: 10px; margin-bottom: 10px; align-items: center;">
			<div class="titleFont2">${email[1]} &lt;${email[0]}&gt;</div>
			<div class="flexRow">
				<div><img onclick="showBlock( 'parametersRoot', 'showEditor', { ...parametersQuery, index: ${status.index}, paramId: ${pref.id} } ); return false;" src="${pageContext.request.contextPath}/img/edit.png" class="iconButton" title="Редактировать"></div>
				<div><img onclick="showBlock( 'paramResult', 'update', { ...parametersQuery, paramId: ${pref.id}, index: ${status.index}, command: 'delete' } ); return false;" src="${pageContext.request.contextPath}/img/delete.png" class="iconButton" title="Удалить"></div>
			</div>
		</div>
		<div class="line"></div>		
	</c:forEach>
	</div>
	<div class="titleFont3" style="margin: 20px 5px; margin-top: 50px; background-color: #eee; padding: 5px 10px; border-radius: 10px;"><c:choose><c:when test="${not empty paramIndex}">Редактировать адрес</c:when><c:otherwise> Добавить новый адрес</c:otherwise></c:choose></div>				
	<div class="textField" style="width: 100%; font-size: 0.9rem; padding: 0px 20px; box-sizing: border-box;">
		<input type="hidden" name="paramIndex" value="${paramIndex}"> 
		<div class="paramColor">E-mail адрес:</div>
		<input type="text" name="paramValue" style="width: 100%;" value="${paramValue}">
		<div class="paramColor" style="margin-top: 5px;">Имя (название):</div>
		<input type="text" name="paramName" style="width: 100%;" value="${fn:escapeXml(paramName)}">
	</div>
	<div class="flexRow" style="margin: 20px 10px;">
		<div></div>
		<div style="text-align: right;">
			<button class="btn btn-primary" onclick="showBlock( 'paramResult', 'update', { ...parametersQuery, paramId: ${pref.id}, index: this.form.paramIndex.value, value: this.form.paramValue.value, name: this.form.paramName.value, command: 'update' } ); return false;">Сохранить</button>
			<button class="btn btn-outline-primary" style="margin-left: 20px;" onclick="showBlock( 'parametersRoot', 'list', parametersQuery ); return false;">Отмена</button>
		</div>
	</div>
</div>
</form>