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

<c:set var="type" value="${frd.type}"/>
<c:set var="props" value="${type.properties}"/>
<c:set var="formUiid" value="${u:uiid()}"/>
<c:set var="taUiid" value="${u:uiid()}"/>

<c:url var="editUrl" value="${form.requestURI}">
	<c:param name="method" value="properties"/>
	<c:param name="id" value="${type.id}"/>
	<c:param name="returnUrl" value="${form.returnUrl}"/>
</c:url>

<c:set var="saveCommand" value="$$.ajax.post($('#${formUiid}'), {control: this}).done(() => $$.ajax.load('${form.requestUrl}', $('#${formUiid}').parent()));"/>

<html:form action="${form.requestURI}" styleId="${formUiid}">
	<input type="hidden" name="method" value="propertiesUpdate"/>
	<input type="hidden" name="id" value="${type.id}"/>
	<input type="hidden" name="returnUrl" value="${form.returnUrl}"/>

	<c:set var="lastModifyObject" value="${props}"/>
	<%@ include file="/WEB-INF/jspf/last_modify_hiddens.jsp"%>

	<ul>
		<li><a href="#${formUiid}-1">${l.l('Properties')}</a></li>
	</ul>

	<div id="${formUiid}-1">
		<div class="in-table-cell in-va-top">
			<div style="min-width: 350px; max-width: 350px;">
				<h2>${l.l('Параметры')}</h2>
				<ui:select-mult name="param" showId="1" moveOn="true" showComment="true" style="width: 100%;"
					list="${frd.parameterList}" map="${ctxParameterMap}" values="${props.parameterIds}"/>
			</div>
			<div class="w100p pl1">
				<h2>${l.l('Конфигурация')}</h2>
				<textarea id="${taUiid}" name="config" style="resize: none; width: 100%;" rows="20">${frd.config}</textarea>
			</div>
		</div>
	</div>

	<div class="mt1">
		<ui:form-ok-cancel/>
		<span style="float: right;">
			<button type="button" class="btn-grey mr1" onclick="${saveCommand}"
				title="${l.l('Save without leaving editor')}">${l.l('Save')}</button>
			<button type="button" class="btn-grey" onclick="$$.ajax.load('${editUrl}', $('#${formUiid}').parent())">${l.l('Restore')}</button>
		</span>
	</div>
</html:form>

<script>
	$('#${formUiid}').tabs();
	$(function () {
		$$.ui.codeMirror('${taUiid}');
	})
</script>

<shell:state text="${l.l('Свойства типа номенклатуры')}: ${type.title} #${type.id}"/>
