<%@ 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="phone" varStatus="status" items="${phones}">
		<div class="flexRow" style="margin-top: 10px; margin-bottom: 10px; align-items: center;">
			<div class="titleFont2">${phone[0]}<c:if test="${not empty phone[1]}"> [${phone[1]}]</c:if></div>
			<div class="flexRow">
				<div><img onclick="showBlock( 'parametersRoot', 'showEditor', { ...parametersQuery, paramId: ${pref.id}, index: ${status.index} } ); 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 class="paramEditorValue" style="display: none; margin: 3px;" index="-1"><nobr><input type="text" name="paramPhoneValue" style="width: 40%" onInput="doPhoneParamFormat(this);">&nbsp;<input type="text" name="paramPhoneComment" style="width: 55%">&nbsp;<a href="#" onclick="jQuery(this).parent().parent().remove(); return false;">[X]</a></a></nobr></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">Номер:</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>

<script type="text/javascript">
<!--
	function checkLoadFunction()
	{
		if ( typeof sortPrefixs == 'function' && typeof window.prefixs != 'undefined' )
		{
			sortPrefixs();
		}
		else
		{
			setTimeout( "checkLoadFunction()", 1000 );
		}
	}
	
	checkLoadFunction();
//-->
</script>   
