<%@page import="it.cedaf.icare.configurazioni.commons.FieldEnabler"%>
<%@ include file="/project/include.jsp" %>

<br>
<shell:multipleColumnList dto="dto_fieldsetList" numOfColumns="3" />
<br>

<script type="text/javascript">
	var cpArrayProperties = new Object();
	function eformat_cpmt(element, value) {
		if (cpArrayProperties['' + element.id]) {
			element.style.whiteSpace = 'nowrap';
			element.style.padding = '10px 0px 10px 5px';
			while (value && value.indexOf(',') != -1) value = value.replace(',', '<br>&nbsp;');
		
		} 
		element.innerHTML = value;
	}

	function editSingleProp(tile, codice, id_element) {
		var event = 'configurazioni.editSingleProp?tile=' + tile + '&codice=' + codice + '&selectedRow=' + cpGetMasterCurrentRow();
		var element = document.getElementById(id_element);
		var point = getElementPoint(element);
		point.moveByOffset(40, 0);
		var rec = point.getRectangle(800, 600, HORIZONTAL_LEFT | VERTICAL_CENTER);
		rec.moveInside(getClientAreaRectangle(), 40);
		showIFrameModalByEvent('id_editSingleProp', 'Modifica propriet�', event, rec);
	}

	function closeSingleProp() {
		hideModal('id_editSingleProp');
	}
	
</script>

<c:set var="idx" scope="page" value="0" />	
<c:forEach var="fieldsetName" items="${dto_fields.fieldsetNames}" varStatus="status">
<center>
<a name="fieldset${status.index}"></a>
<shell:fieldset title="${fieldsetName}">
	<table cellspacing="3" cellpadding="0" >
		<c:forEach var="field" items="${dto_fields.fields[status.index]}">
			<c:if test="${field.enabled}">
   			<tr>
    		<td class="form-label">
				<shell:label prop="prop_${idx}" label="${field.descrizione}"/>
			</td>
			<td class="form-values">													
				<bui:out modes="update">
					<c:choose>
						<c:when test="${field.type == 'SHORT_TEXT'}">								
							<j:bind prop="prop_${idx}">
								<j:text class="form-verylong-text" />
								<shell:error />
							</j:bind>								
						</c:when>
						
						<c:when test="${field.type == 'LONG_TEXT'}">								
							<j:bind prop="prop_${idx}">
								<j:textarea class="form-long-textarea" />
								<shell:error />
							</j:bind>								
						</c:when>
						
						<c:when test="${field.type == 'INTEGER' || field.type == 'DECIMAL'}">
							<j:bind prop="prop_${idx}">
								<j:text class="form-short-text" />
								<shell:error />
							</j:bind>
						</c:when>
						
						<c:when test="${field.type == 'ENUM'}">
							<j:bind prop="prop_${idx}">
								<j:select class="form-input" emptyOptionDescr=""/>
								<shell:error />
							</j:bind>							
						</c:when>
						
						<c:when test="${field.type == 'CHECKBOX'}">
							<j:bind prop="prop_${idx}">
								<j:valueSetIterator>
									<j:checkbox />${j:getValueSetItem().description}<br>
								</j:valueSetIterator>
								<shell:error />
							</j:bind>							
						</c:when>
						
						<c:when test="${field.type == 'RADIO'}">
							<j:bind prop="prop_${idx}">
								<j:valueSetIterator>
									<j:radio />${j:getValueSetItem().description}<br>
								</j:valueSetIterator>
								<shell:error />
							</j:bind>							
						</c:when>
						
						<c:when test="${field.type == 'DATE'}">
							<j:bind prop="prop_${idx}">
								<j:text class="form-date" id="prop_${idx}CLD" />
								<shell:calendar inputId="prop_${idx}CLD" />
								<shell:error />
							</j:bind>															
						</c:when>
					</c:choose>
				</bui:out>
				<bui:out modes="view">
					<c:choose>
						<c:when test="${field.type == 'LONG_TEXT'}">
							<div id="${empty slave ? 'cpmt' : 'cpst_'}${slave}_prop_${idx}" class="form-long-textarea" style="overflow:auto;"></div>
						</c:when>
					<c:otherwise>
						<j:tile name="shell.plaintext" prop="prop_${idx}" />
					</c:otherwise>
					</c:choose>
					<c:if test="${field.array}"><script type="text/javascript">cpArrayProperties['cpmt_prop_${idx}']='1';</script></c:if>
					<c:if test="${! empty field.configurationTile}">
						<shell:button id="btn_prop_${idx}" href="javascript:editSingleProp('${field.configurationTile}', '${field.codice}', 'btn_prop_${idx}')" img="commons.doc_edit_small" title="Modifica la propriet�" />
					</c:if>
				</bui:out>
			</td>
    		</tr>
    		</c:if>
    		<c:set var="idx" scope="page" value="${idx + 1}" />
   		</c:forEach>
   	</table>
   	&nbsp;<shell:button href="#shell_top" img="shell.arrowUp" text="Torna alla lista" title="Torna alla lista delle configurazioni" />
</shell:fieldset>
<center>
</c:forEach>