#{param name=lblTree /}
#{param name=lbl /}

<%
	import org.exoplatform.commons.utils.HTMLEntityEncoder;

	def encoder = HTMLEntityEncoder.getInstance();
%>

<!-- edit-label-dialog -->
<div class="edit-label-dialog uiPopup modal hide fade" data-id="${lbl.id}" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="popupHeader clearfix">
  	<a href="#" title="Close Window" data-dismiss="modal" aria-hidden="true" class="uiIconClose pull-right"></a>    
  	<span class="PopupTitle popupTitle">&{label.editLabel}</span>
  </div>
  <div class="PopupContent popupContent">
	  <div class="form-horizontal">
	   <%
	   	def printOption(l, level) {
	   %>
	   	<option value="${l.id}" style="padding-left: <%=level*10%>px;" <%= lbl.parent != null && l.id == lbl.parent.id ? "selected" : "" %>>${HTMLEntityEncoder.getInstance().encode(l.name)}</option>	   	
	   <%	
	   	  if (l.getChildren() != null && l.getChildren().size() > 0) {
	   	    printTree(l.getChildren(), level + 1);
	   	  }
	   	}
	   %>
	   <div class="form-horizontal">
	  	<div class="control-group">
	  		<label class="control-label" for="lblParent:">&{label.labelParent}:</label>
	  		<div class="controls">
			   <select id="lblParent" class="lblParent">
			   <option value="0" style="padding-left: 10px;" <%= lbl.parent == null ? "selected" : "" %>>&{label.label}</option>
			  	<%
			  	def printTree(tree, level) {
			  		for (def l : tree) {
			   		printOption(l, level);
			  		}
			  	}
			  	//
			  	printTree(lblTree, 2);
			  	%>
			  	</select>
	  		</div>
	  	</div>
	  	<div class="control-group">
	  		<label class="control-label" for="lblName:">&{label.labelName}:</label>
	  		<div class="controls">
	  			<input type="text" id="lblName" class="lblName" value="<%=encoder.encode(lbl.getName())%>" maxlength="100"/>
	  		</div>
	  	</div>
	  </div>
	  <div class="uiAction uiActionBorder">
	    <button class="btn btn-primary saveLabel" data-dismiss="modal" disabled>&{label.save}</button>
	    <button class="btn" data-dismiss="modal" aria-hidden="true">&{popup.close}</button>
	  </div>
  </div>
</div>