Index: trunk/prototype/modules/calendar/templates/attendee_add.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/attendee_add.ejs	(revision 5437)
+++ trunk/prototype/modules/calendar/templates/attendee_add.ejs	(revision 5514)
@@ -1,18 +1,37 @@
+	<%var iconStatus = ['','ui-icon-check', 'ui-icon-radio-off', 'ui-icon-close', 'ui-icon-help', 'ui-icon-transferthick-e-w', 'ui-icon-contact']
+	  var legendStatus = ['','Confirmado','Tentativa','Cancelado','Sem Resposta','Delegado', 'Participante']
+	%>
 	<dl class="block-attendee-list attendees-list">
 		<dt class="me"><%= data.event.me.name %></dt>
 		<dd class="me">
 			<select class="status" name="status">
-				<option value="1" <%= data.event.status=='1' ? 'selected="selected"':'' %>>Eu vou</option>
-				<option value="3" <%= data.event.status=='3' ? 'selected="selected"':'' %>>Eu não vou</option>
-				<option value="2" <%= data.event.status=='2' ? 'selected="selected"':'' %>>Talvez</option>
-<!--				<option value="another">Outra pessoa vai</option>-->
+				<%if(!data.event.delegatedFrom[data.event.me.id]){%>
+					<option value="1" <%= data.event.status=='1' ? 'selected="selected"':'' %>>Eu vou</option>
+					<%if(!data.event.acl.participationRequired){%>
+						<option value="3" <%= data.event.status=='3' ? 'selected="selected"':'' %>>Eu não vou</option>
+						<option value="2" <%= data.event.status=='2' ? 'selected="selected"':'' %>>Talvez</option>
+						<option class="hidden" value="5">Delegado</option>
+					<%}%>
+				<%}else{%>
+					<option value="5" 'selected="selected"'>Delegado</option>
+				<%}%>
 			</select>
-                        <%if(data.event.organizer.id != data.event.me.id){%>
-                            <input type="hidden" name="meId" value="<%=data.event.me.id%>">
-                        <%}%>
-			<fieldset class="add-attendee-search search-field ui-corner-all hidden">
-				<span class="ui-icon ui-icon-search"></span>
-				<input class="search" type="text" />
-			</fieldset>
+			<% if (!data.event.acl.organization && !data.event.acl.write && !data.event.acl.inviteGuests && !data.event.acl.participationRequired && !data.event.delegatedFrom[data.event.me.id] ) { %>
+				<fieldset class="add-attendee-options-read">
+					<a href="#" class="button participant-delegate add-attendee-options-button">Delegar participação a um novo participante</a>
+				</fieldset>
+			<% } %>
+			
+			<p class="input-group request-update <%=data.event.delegatedFrom[data.event.me.id] ? '' : "hidden"%>">
+				<input type="checkbox" name="receiveNotification" value="true" <%=data.event.me.receiveNotification=='1' ? 'checked="checked"' : ''%>/>
+				<label for="request-update">Receber atualizações</label>
+			</p>
+			
+			<input type="hidden" name="delegatedFrom[]" value="<%=data.event.me.delegatedFrom%>">
+		
+			<input type="hidden" name="attendee[]" value="<%=data.event.me.id%>">
+			<input type="hidden" name="attendeeType[]" value="0">
+			<input type="hidden" name="attendeeAcl[]" value="<%=data.event.me.acl%>">				
+			
 		</dd>
 
@@ -20,39 +39,88 @@
 		<dd class="attendee-list">
 			<ul class="attendee-list">
-				<li class="organizer <%= data.event.organizer.id == data.event.me.id ? "hidden" : ''%>"> 
+				<li class="organizer <%= (data.event.acl.organization) ? "hidden" : "" %>"> 
 					<div style="overflow:hidden; width:100%; display:table;">
-						<input type="checkbox" value="<%= data.event.organizer.id %>" disabled="disabled">
-						<input type="hidden" name="attendee[]" value="<%=data.event.organizer.id%>">
-						<input type="hidden" name="attendeeType[]" value="0">
-						<input type="hidden" name="attendee_organizer[]" value="<%=data.event.organizer.id%>">
-						<label for="attendee_organizer" title="<%= data.event.organizer.name ? data.event.organizer.name: '' %>" class="name"><%= data.event.organizer.name ? data.event.organizer.name : '' %></label>
-						<label for="attendee_organizer" title="<%= data.event.organizer.mail ? data.event.organizer.mail: '' %>" class="mail"><%= data.event.organizer.mail ? data.event.organizer.mail : '' %></label>
-						<% if (data.event.me.id == data.event.organizer.id && false) { %>
-						<span class="button small swap">Mudar organizador</span>
-						<% } %>
+						<span class="space-status ui-icon <%=iconStatus[data.event.organizer.status]%>" title="<%=legendStatus[data.event.organizer.status]%>"></span>
+						<span class="space-special ui-icon ui-icon-person" title="Organizador"></span>
+						<% if (!data.event.acl.organization && (data.event.organizer.id != data.event.me.id )) { %>
+							<input type="checkbox" value="<%= data.event.organizer.id %>" disabled="disabled">
+							<input type="hidden" name="attendee[]" value="<%=data.event.organizer.id%>">
+							<input type="hidden" name="attendeeType[]" value="0">
+							<input type="hidden" name="attendeeAcl[]" value="<%=data.event.organizer.acl%>">
+							<input type="hidden" name="delegatedFrom[]" value="<%=data.event.organizer.delegatedFrom%>">
+						<%}%>
+						<input type="hidden" name="attendee_organizer" value="<%=data.event.organizer.id%>">
+						<label for="attendee_organizer" title="<%= data.event.organizer.name ? data.event.organizer.name: '' %>" class="name name-special"><%= data.event.organizer.name ? data.event.organizer.name : '' %></label>
+						<label for="attendee_organizer" title="<%= data.event.organizer.mail ? data.event.organizer.mail: '' %>" class="mail name-special"><%= data.event.organizer.mail ? data.event.organizer.mail : '' %></label>
 					</div>
-				</li>		
-				
-			<% if (data.event && data.event.attendee) {
-				for (var i=0; i< data.event.attendee.length; i++) {
-			%>
-				<li class="attendee"> 
+				</li>
+			<%if(!!data.event.delegatedFrom[data.event.me.id]){
+				var delegated_me = data.event.delegatedFrom[data.event.me.id]%>
+				<li class="me-delegated">
 					<div style="overflow:hidden; width:100%; display:table;">
-						<input type="checkbox" value="<%= data.event.attendee[i].id %>" disabled="disabled">
-						<input type="hidden" name="attendee[]" value="<%=data.event.attendee[i].id%>">
-						<input type="hidden" name="attendeeType[]" value="<%=data.event.attendee[i].isExternal%>">
-						<label title="<%= data.event.attendee[i].name ? data.event.attendee[i].name: '' %>" class="name"><%= data.event.attendee[i].name ? data.event.attendee[i].name : '' %></label>
-						<label title="<%= data.event.attendee[i].mail ? data.event.attendee[i].mail : '' %>" class="mail"><%= data.event.attendee[i].mail ? data.event.attendee[i].mail : '' %></label>
-						<span class="ui-icon ui-icon-close ui-corner-all ui-icon-float-right"></span>
-					</div> 
-					<a class="button close">X</a>
+						<span class="space-status ui-icon <%=iconStatus[delegated_me.status]%>" title="<%=legendStatus[delegated_me.status]%>"></span>
+						<span class="space-special ui-icon <%=iconStatus[5]%>" title="Delegado para"></span>
+						<input type="checkbox" value="<%= delegated_me.id%>" disabled="disabled">
+						<label for="me-delegated" title="<%= delegated_me.name ? delegated_me.name: '' %>" class="name name-special"><%= delegated_me.name ? delegated_me.name : '' %></label>
+						<label for="me-delegated" title="<%= delegated_me.mail ? delegated_me.mail: '' %>" class="mail name-special"><%= delegated_me.mail ? delegated_me.mail : '' %></label>
+					</div>
 				</li>
-				
-				
-				
-			<%	
-				} 
-			} else { %>
-				<li>Não há outros participantes.</li>
+			<%}%>
+			<% if (data.event && data.event.attendee.length > 0) {
+				for (var i=0; i< data.event.attendee.length; i++) {%>
+					<li class="attendee"> 
+						<div style="overflow:hidden; width:100%; display:table;">
+							<%if(data.event.delegatedFrom[data.event.attendee[i].id]){%>
+								<span class="open-delegate new ui-icon ui-icon-triangle-1-e"></span>
+							<%}else{%>
+								<span class="space-status ui-icon <%=iconStatus[data.event.attendee[i].status]%>" title="<%=legendStatus[data.event.attendee[i].status]%>"></span>
+							<%}%>
+							<span class="space-special ui-icon <%= !!data.event.delegatedFrom[data.event.attendee[i].id] ? iconStatus[5] : iconStatus[6]%>" title="<%=!!data.event.delegatedFrom[data.event.attendee[i].id] ? legendStatus[5] : legendStatus[6]%>"></span>
+							<%if(data.event.acl.organization || data.event.acl.write){%>
+								<input type="checkbox" value="<%= data.event.attendee[i].id %>">
+							<%}else{%>
+								<input type="checkbox" value="<%= data.event.attendee[i].id%>" disabled="disabled">
+							<%}%>
+							<input type="hidden" name="attendee[]" value="<%=data.event.attendee[i].id%>">
+							<input type="hidden" name="attendeeType[]" value="<%=data.event.attendee[i].isExternal%>">
+							<input type="hidden" name="attendeeAcl[]" value="<%=data.event.attendee[i].acl%>">
+							<input type="hidden" name="delegatedFrom[]" value="<%=data.event.attendee[i].delegatedFrom%>">
+							<label title="<%= data.event.attendee[i].name ? data.event.attendee[i].name: '' %>" class="name <%= !!data.event.delegatedFrom[data.event.attendee[i].id] ? "name-special-delegated" : "name-special" %>"><%= data.event.attendee[i].name ? data.event.attendee[i].name : '' %></label>
+							<label title="<%= data.event.attendee[i].mail ? data.event.attendee[i].mail : ''%>" class="mail <%= !!data.event.delegatedFrom[data.event.attendee[i].id] ? "name-special-delegated" : "name-special"%>"><%= data.event.attendee[i].mail ? data.event.attendee[i].mail : '' %></label>
+							<span class="ui-icon ui-icon-close ui-corner-all ui-icon-float-right"></span>
+						</div> 
+						<div class="attendee-options">
+							<%if(data.event.acl.organization || data.event.acl.write){%>
+								<a class="button edit attendee-options-button-edit new">Editar permissões</a>
+								<a class="button close new">Remover</a>
+							<%}%>
+						</div>
+
+
+						<%if(!!data.event.delegatedFrom[data.event.attendee[i].id]){%>
+							<%var attendee = data.event.delegatedFrom[data.event.attendee[i].id]%>
+							<% while(attendee != 0){%>
+								<div class="list-delegates hidden">
+									<div style="overflow:hidden; width:100%; display:table;">
+										<span class="status-delegate ui-icon <%=iconStatus[attendee.status]%>" title="<%=legendStatus[attendee.status]%>"></span>
+										<span class="space-special-delegated ui-icon <%= !!data.event.delegatedFrom[attendee.id] ? iconStatus[5] : iconStatus[6]%>" title="<%=!!data.event.delegatedFrom[attendee.id] ? legendStatus[5] : legendStatus[6]%>"></span>
+										<input type="hidden" name="attendee[]" value="<%=attendee.id%>">
+										<input type="hidden" name="attendeeType[]" value="<%=attendee.isExternal%>">
+										<input type="hidden" name="attendeeAcl[]" value="<%=attendee.acl%>">
+										<input type="hidden" name="delegatedFrom[]" value="<%=attendee.delegatedFrom%>">
+										<label title="<%= attendee.name ? attendee.name : '' %>" class="name <%=attendee.status == 5 ? "name-status-delegated-delegated" : "name-status-delegated-none"%>"><%= attendee.name ? attendee.name : '' %></label>
+										<label title="<%= attendee.mail ? attendee.mail : '' %>" class="mail <%=attendee.status == 5 ? "name-status-delegated-none" : "name-status-delegated-none"%>"><%= attendee.mail ? attendee.mail : '' %></label>
+										<span class="ui-icon ui-icon-close ui-corner-all ui-icon-float-right"></span>
+									</div> 
+								</div>
+								<%attendee = !!data.event.delegatedFrom[attendee.id] ? data.event.delegatedFrom[attendee.id] : 0%>
+							<%}%>
+						<%}%>
+						
+
+					</li>	
+				<%} 
+			} else if(data.event.me.id == data.event.organizer.id && !(data.event.attendee.length > 0) ) { %>
+				<li class="not-attendee">Não há outros participantes.</li>
 			<% } %>
 			</ul>
@@ -86,29 +154,19 @@
 		
 	</dl>
-<% if (data.event.isOrganizer == 1) { %>
-	<dl class="block-add-attendee">
-		<dt class="add-attendee">Adicionar convidados</dt>
-		<dd class="add-attendee">
-			<fieldset class="block-add-attendee" title="Participantes">
-				<fieldset class="add-attendee-search search-field ui-corner-all">
-					<span class="ui-icon ui-icon-search"></span>
-					<input class="search" type="text" />
-				</fieldset>
-				<ul class="search-result-list ui-corner-all">
+<% var isSearch = (data.event.acl.organization || data.event.acl.write || data.event.acl.inviteGuests) ? '' : 'hidden' %>
+<dl class="block-add-attendee search <%=isSearch%>">
+	<dt class="add-attendee search">Adicionar outros convidados</dt>
+	<dd class="add-attendee">
+		<fieldset class="block-add-attendee" title="Participantes">
+			<fieldset class="add-attendee-search search-field ui-corner-all">
+				<span class="ui-icon ui-icon-search"></span>
+				<input class="search" type="text" />
+			</fieldset>
+			<ul class="search-result-list ui-corner-all">
 
-				</ul>
+			</ul>
 
-			</fieldset>
+		</fieldset>
+	</dd>
+</dl>
 
-			<fieldset class="block-add-attendee-permissions ui-corner-all hidden">
-				<legend>Convidados podem:</legend>
-				<ul class="add-attendee-permissions-list">
-					<li><input type="checkbox" name="attendee-mod-event"><label for="attendee-mod-event">Modificar evento </label></li>
-					<li><input type="checkbox" name="attendee-invite-others"><label for="attendee-invite-others">Convidar outros</label></li>
-					<li><input type="checkbox" name="attendee-view-list-invited"><label for="attendee-view-list-invited">Ver lista de convidados</label></li>
-					<li><input type="checkbox" name="attendee-optional"><label for="attendee-optional">Participação opcional</label></li>
-				</ul>
-			</fieldset>
-		</dd>
-	</dl>
-<% } %>
