r7512 - in dumbhippo/trunk/server: src/com/dumbhippo/server src/com/dumbhippo/server/impl web/css3 web/javascript/dh web/tags/2 web/tags/3



Author: marinaz
Date: 2008-09-24 16:57:12 -0500 (Wed, 24 Sep 2008)
New Revision: 7512

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/ExternalAccountSystem.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
   dumbhippo/trunk/server/web/css3/account-positions.css
   dumbhippo/trunk/server/web/javascript/dh/account.js
   dumbhippo/trunk/server/web/tags/2/formTableRow.tag
   dumbhippo/trunk/server/web/tags/2/loveHateEntry.tag
   dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag
   dumbhippo/trunk/server/web/tags/3/loveEntry.tag
Log:
Allow setting which accounts should and should not be used on Mugshot. 

Provide a visual indication when an account is not used.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/ExternalAccountSystem.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/ExternalAccountSystem.java	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/ExternalAccountSystem.java	2008-09-24 21:57:12 UTC (rev 7512)
@@ -98,6 +98,8 @@
 
 	public void setSentiment(ExternalAccount externalAccount, Sentiment sentiment);
 	
+	public void setMugshotEnabled(ExternalAccount externalAccount, boolean mugshotEnabled);
+	
 	public void validateAll();
 	
 	public OnlineAccountType getOnlineAccountType(ExternalAccountType accountType);

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java	2008-09-24 21:57:12 UTC (rev 7512)
@@ -282,7 +282,11 @@
 	@HttpContentTypes(HttpResponseData.XMLMETHOD)
 	@HttpParams( { "groupId", "url" })
 	public void doRemoveGroupFeed(XmlBuilder xml, UserViewpoint viewpoint, Group group, URL url) throws XmlMethodException;
-
+	
+	@HttpContentTypes(HttpResponseData.NONE)
+	@HttpParams( { "accountId" })
+	public void doToggleMugshotEnabled(UserViewpoint viewpoint, String accountId) throws IOException, HumanVisibleException;	
+	
 	/**
 	 * Mark an external account as "hated" and give an optional quip about why.
 	 * If the quip is missing or empty it's taken as "delete any quip"

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java	2008-09-24 21:57:12 UTC (rev 7512)
@@ -514,7 +514,33 @@
 		
 		notifier.onExternalAccountLovedAndEnabledMaybeChanged(user, externalAccount);
 	}
+	
+	public void setMugshotEnabled(ExternalAccount externalAccount, boolean mugshotEnabled) {
+		if (externalAccount.isMugshotEnabled() != null && externalAccount.isMugshotEnabled().booleanValue() == mugshotEnabled)
+			return;
+		
+		User user = externalAccount.getAccount().getOwner(); 
 
+		// unset mugshotEnabled on any other account that might have it set if mugshotEnabled=true
+		// set mugshotEnabled to true on some other account that can have it set if mugshotEnabled=false
+		Set<ExternalAccount> externalAccounts = lookupExternalAccounts(new UserViewpoint(user, Site.NONE), user, externalAccount.getOnlineAccountType());
+    	for (ExternalAccount externalAccountToCheck : externalAccounts) {
+    		if (mugshotEnabled && externalAccountToCheck.getSentiment() == Sentiment.LOVE 
+    			&& externalAccountToCheck.isMugshotEnabled() != null && externalAccountToCheck.isMugshotEnabled()) {
+    			externalAccountToCheck.setMugshotEnabled(null);
+    			notifier.onExternalAccountLovedAndEnabledMaybeChanged(user, externalAccountToCheck);
+    			break;
+    		} else if (!mugshotEnabled && externalAccountToCheck.getSentiment() == Sentiment.LOVE 
+    				   && externalAccountToCheck.isMugshotEnabled() == null && !externalAccount.equals(externalAccountToCheck)) {
+    			externalAccountToCheck.setMugshotEnabled(true);
+    		    notifier.onExternalAccountLovedAndEnabledMaybeChanged(user, externalAccountToCheck);
+    		    break;
+    		}    
+    	}    
+        externalAccount.setMugshotEnabled(mugshotEnabled);
+        notifier.onExternalAccountLovedAndEnabledMaybeChanged(user, externalAccount);
+	}
+
 	public boolean getExternalAccountExistsLovedAndEnabled(Viewpoint viewpoint, User user, ExternalAccountType accountType) {
 		try {
 			ExternalAccount external = lookupExternalAccount(viewpoint, user, accountType);

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java	2008-09-24 21:57:12 UTC (rev 7512)
@@ -1596,6 +1596,15 @@
 		}		
 	}
 	
+	public void doToggleMugshotEnabled(UserViewpoint viewpoint, String accountId) throws IOException, HumanVisibleException {
+        try {
+		    ExternalAccount external = externalAccountSystem.lookupExternalAccount(viewpoint, accountId);
+		    externalAccountSystem.setMugshotEnabled(external, !external.isMugshotEnabledWithDefault());
+	    } catch (NotFoundException e) {
+		    throw new RuntimeException(e.getMessage());
+	    }
+	}
+	
 	public void doHateExternalAccount(XmlBuilder xml, UserViewpoint viewpoint, String type, String quip) throws XmlMethodException {
 		
 		// FIXME for any external account that has a feed associated with it, we could try to remove the feed and

Modified: dumbhippo/trunk/server/web/css3/account-positions.css
===================================================================
--- dumbhippo/trunk/server/web/css3/account-positions.css	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/css3/account-positions.css	2008-09-24 21:57:12 UTC (rev 7512)
@@ -39,6 +39,11 @@
     bottom:   2px;
 }
 
+.dh-mugshot-enabled-preference {
+    margin-top: 4px;
+    margin-left: 12px;
+}
+
 #dhAccounts .dh-spacer-row {
 	height:			5px;
 }

Modified: dumbhippo/trunk/server/web/javascript/dh/account.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/account.js	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/javascript/dh/account.js	2008-09-24 21:57:12 UTC (rev 7512)
@@ -214,6 +214,17 @@
 	}
 }
 
+dh.account.toggleMugshotEnabled = function(accountId) {
+  	dh.server.doPOST("togglemugshotenabled",
+			 	     { "accountId" : accountId },
+  					 function(type, data, http) {
+  					 	dh.util.refresh();
+					 },
+					 function(type, error, http) {
+						 alert("Couldn't change the setting for Mugshot use.");
+					 });
+}
+
 dh.account.hateExternalAccount = function(type, quip, loadFunc, errorFunc) {
    	dh.server.doXmlMethod("hateexternalaccount",
 				     { "type" : type,

Modified: dumbhippo/trunk/server/web/tags/2/formTableRow.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/2/formTableRow.tag	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/tags/2/formTableRow.tag	2008-09-24 21:57:12 UTC (rev 7512)
@@ -41,7 +41,7 @@
 	</c:choose>
 	<c:choose>
 	    <c:when test="${!empty info}">
-	        <td class="dh-control-cell dh-control-cell-next-to-info"><div class="dh-control-cell-div"><jsp:doBody/></div></td>
+	        <td class="dh-control-cell dh-control-cell-next-to-info"><div class="dh-control-cell-div" id="${controlId}FormContent"><jsp:doBody/></div></td>
 	        <td class="dh-info-cell">
 	        <c:choose>
 	            <c:when test="${!empty infoLink}">

Modified: dumbhippo/trunk/server/web/tags/2/loveHateEntry.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/2/loveHateEntry.tag	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/tags/2/loveHateEntry.tag	2008-09-24 21:57:12 UTC (rev 7512)
@@ -7,7 +7,9 @@
 <%@ attribute name="isInfoTypeProvidedBySite" required="true" type="java.lang.Boolean" %>
 <%@ attribute name="link" required="true" type="java.lang.String" %>
 <%@ attribute name="baseId" required="true" type="java.lang.String" %>
+<%@ attribute name="accountId" required="true" type="java.lang.String" %>
 <%@ attribute name="mode" required="true" type="java.lang.String" %>
+<%@ attribute name="mugshotEnabled" required="true" type="java.lang.Boolean" %>
 
 <%-- Note: <jsp:doBody/> is used only when an account is loved to dispay additional details --%>
 <%-- because right now it is only useful when an account is loved. It's ok to use it when an --%>
@@ -43,6 +45,12 @@
 			<dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/>
 			<span id="${baseId}LoveValueId"></span>
 		</a>
+	    <c:if test="${!mugshotEnabled}">
+	        &nbsp;
+            <a href="javascript:dh.love.setMode('${baseId}', 'loveEdit')" title="Click to change">
+		      (not used)
+		    </a>   
+		</c:if>  
 	    <jsp:doBody/>
 	</div>
 	<div id="${baseId}HateId" style="display: ${hateDisplay};">
@@ -65,7 +73,23 @@
 		<dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/>
 		<dht:textInput id="${baseId}LoveEntryId" maxlength="255"/>
 		<img src="/images3/${buildStamp}/save_button.gif" onclick="dh.lovehate.saveClicked('${baseId}', 'love')"/>
-		<a href="javascript:dh.lovehate.cancelClicked('${baseId}')" title="I don't love it anymore - go back to being indifferent"><img src="/images3/${buildStamp}/x_button.gif"/></a>
+		<a href="javascript:dh.lovehate.cancelClicked('${baseId}')" title="I don't love it anymore - go back to being indifferent"><img src="/images3/${buildStamp}/x_button.gif"/></a>
+		<c:if test="${mode == 'love'}">
+		    <c:set var="title" value="You can list multiple accounts of a given type, but only up to one of them can be used on Mugshot at the moment."/>
+		    <div class="dh-account-preferences-row dh-mugshot-enabled-preference">
+		        <c:choose>
+		            <c:when test="${mugshotEnabled}">
+                        <input type="checkbox" id="${baseId}MugshotEnabled" checked
+			                   onclick="dh.account.toggleMugshotEnabled('${accountId}');" title="${title}">		            
+		            </c:when>
+		            <c:otherwise>
+                        <input type="checkbox" id="${baseId}MugshotEnabled"
+			                   onclick="dh.account.toggleMugshotEnabled('${accountId}');" title="${title}">			            
+		            </c:otherwise>
+		        </c:choose>    
+			    <label for="${baseId}MugshotEnabled" title="${title}">Use on Mugshot</label>
+			</div>
+		</c:if>	
 	    <jsp:doBody/>
 		<dht:loveHateEntryDescription isEditing="true" baseId="${baseId}" name="${name}" userInfoType="${userInfoType}" isInfoTypeProvidedBySite="${isInfoTypeProvidedBySite}" link="${link}"/>
 	</div>	
@@ -73,7 +97,7 @@
 		<dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiphate_icon.png" style="width: 11; height: 11; overflow: hidden;"/>
 		<dht:textInput id="${baseId}HateEntryId" maxlength="255"/>
 		<img src="/images3/${buildStamp}/save_button.gif" onclick="dh.lovehate.saveClicked('${baseId}', 'hate')"/>
-		<a href="javascript:dh.lovehate.cancelClicked('${baseId}')" title="End the hate - go back to being indifferent"><img src="/images3/${buildStamp}/x_button.gif"/></a>
+		<a href="javascript:dh.lovehate.cancelClicked('${baseId}')" title="End the hate - go back to being indifferent"><img src="/images3/${buildStamp}/x_button.gif"/></a>		
 		<dht:loveHateEntryDescription isEditing="true" baseId="${baseId}" name="${name}" userInfoType="${userInfoType}" isInfoTypeProvidedBySite="${isInfoTypeProvidedBySite}" link="${link}"/>		
 	</div>
 	<div id="${baseId}BusyId" style="display: none;">

Modified: dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/tags/3/accountEditTableExternals.tag	2008-09-24 21:57:12 UTC (rev 7512)
@@ -225,7 +225,9 @@
 							        isInfoTypeProvidedBySite="${supportedAccount.externalAccountType.infoTypeProvidedBySite}"
 							        link="${supportedAccount.externalAccountType.siteLink}"
 							        baseId="dh${supportedAccount.domNodeIdName}"
-							        mode="${supportedAccount.sentiment}">
+							        accountId="${supportedAccount.id}"
+							        mode="${supportedAccount.sentiment}"
+							        mugshotEnabled="${supportedAccount.mugshotEnabled}">
 					                 
 							        <c:if test="${supportedAccount.siteName == 'Amazon' && supportedAccount.mugshotEnabled}">
 								        <div class="dh-amazon-details">
@@ -244,7 +246,9 @@
 							        isInfoTypeProvidedBySite="${supportedAccount.externalAccountType.infoTypeProvidedBySite}"
 							        link="${supportedAccount.externalAccountType.siteLink}"
 							        baseId="dh${supportedAccount.domNodeIdName}"
-							        mode="${supportedAccount.sentiment}">					                 							        
+							        accountId="${supportedAccount.id}"
+							        mode="${supportedAccount.sentiment}"
+							        mugshotEnabled="${supportedAccount.mugshotEnabled}">					                 							        
 							        <c:if test="${supportedAccount.siteName == 'Amazon' && supportedAccount.mugshotEnabled}">
 								        <div class="dh-amazon-details">
 								        <c:forEach items="${account.amazonLinks}" var="amazonLinkPair">

Modified: dumbhippo/trunk/server/web/tags/3/loveEntry.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/loveEntry.tag	2008-09-23 22:30:51 UTC (rev 7511)
+++ dumbhippo/trunk/server/web/tags/3/loveEntry.tag	2008-09-24 21:57:12 UTC (rev 7512)
@@ -7,7 +7,9 @@
 <%@ attribute name="isInfoTypeProvidedBySite" required="true" type="java.lang.Boolean" %>
 <%@ attribute name="link" required="true" type="java.lang.String" %>
 <%@ attribute name="baseId" required="true" type="java.lang.String" %>
+<%@ attribute name="accountId" required="true" type="java.lang.String" %>
 <%@ attribute name="mode" required="true" type="java.lang.String" %>
+<%@ attribute name="mugshotEnabled" required="true" type="java.lang.Boolean" %>
 
 <%--  the Javascript manages this visibility also, but we want to get it right on page load --%>
 <c:choose>
@@ -30,6 +32,12 @@
 		    <dh:png klass="dh-love-hate-icon" src="/images3/${buildStamp}/quiplove_icon.png" style="width: 12; height: 11; overflow: hidden;"/> 
 			<span id="${baseId}LoveValueId"></span>
 		</a>
+        <c:if test="${!mugshotEnabled}">
+            &nbsp;
+            <a href="javascript:dh.love.setMode('${baseId}', 'loveEdit')" title="Click to change">
+		        (not used)
+		    </a>   
+		</c:if>    
 		<jsp:doBody/>
 	</div>
 	<div id="${baseId}IndifferentId" style="display: ${indifferentDisplay};">
@@ -40,6 +48,22 @@
 		<dht:textInput id="${baseId}LoveEntryId" maxlength="255"/>
 		<img src="/images3/${buildStamp}/save_button.gif" onclick="dh.love.saveClicked('${baseId}', 'love')"/>
 		<a href="javascript:dh.love.cancelClicked('${baseId}')" title="Remove the account"><img src="/images3/${buildStamp}/x_button.gif"/></a>
+		<c:if test="${mode == 'love'}">
+		    <c:set var="title" value="You can list multiple accounts of a given type, but only up to one of them can be used on Mugshot at the moment."/>
+		    <div class="dh-account-preferences-row dh-mugshot-enabled-preference">
+		        <c:choose>
+		            <c:when test="${mugshotEnabled}">
+                        <input type="checkbox" id="${baseId}MugshotEnabled" checked
+			                   onclick="dh.account.toggleMugshotEnabled('${accountId}');" title="${title}">		            
+		            </c:when>
+		            <c:otherwise>
+                        <input type="checkbox" id="${baseId}MugshotEnabled"
+			                   onclick="dh.account.toggleMugshotEnabled('${accountId}');" title="${title}">			            
+		            </c:otherwise>
+		        </c:choose>    
+			    <label for="${baseId}MugshotEnabled" title="${title}">Use on Mugshot</label>
+			</div>
+		</c:if>
         <jsp:doBody/>
         <div dhId="DescriptionNormal">
             <div class="dh-love-hate-instruction-editing">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]