Author: buscob
Date: Wed Nov 18 23:31:59 2009 New Revision: 881999 URL: http://svn.apache.org/viewvc?rev=881999&view=rev Log: A slightly modified patch from Sascha Rodekamp "Drag 'n' Drop for myPortal + update prototype and script.aculo.us" (https://issues.apache.org/jira/browse/OFBIZ-3190) - OFBIZ-3190 - I changed some tabs to spaces - It seems to me that everything works with the script.aculo.us version that is already present in the framework; so I did not commit the script.aculo.us update since could break some other thing Added: ofbiz/trunk/framework/images/webapp/images/loader.gif (with props) ofbiz/trunk/framework/images/webapp/images/myportal.css ofbiz/trunk/framework/images/webapp/images/myportal.js ofbiz/trunk/framework/images/webapp/images/myportal_load_bg.png (with props) Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml ofbiz/trunk/framework/common/servicedef/services.xml ofbiz/trunk/framework/common/webcommon/WEB-INF/portal-controller.xml ofbiz/trunk/framework/common/webcommon/portal/editPortalPage.ftl ofbiz/trunk/framework/common/widget/PortalPageScreens.xml Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml?rev=881999&r1=881998&r2=881999&view=diff ============================================================================== --- ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml (original) +++ ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml Wed Nov 18 23:31:59 2009 @@ -107,9 +107,9 @@ </if-not-empty> <entity-condition entity-name="PortletAttribute" list="attributeList"> <condition-list combine="and"> - <condition-expr field-name="portalPageId" operator="equals" from-field="parameters.portalPageId"/> - <condition-expr field-name="portalPortletId" operator="equals" from-field="parameters.portalPortletId"/> - <condition-expr field-name="portletSeqId" operator="equals" from-field="parameters.portletSeqId" ignore-if-empty="true"/> + <condition-expr field-name="portalPageId" operator="equals" from-field="parameters.portalPageId"/> + <condition-expr field-name="portalPortletId" operator="equals" from-field="parameters.portalPortletId"/> + <condition-expr field-name="portletSeqId" operator="equals" from-field="parameters.portletSeqId" ignore-if-empty="true"/> </condition-list> </entity-condition> <if-not-empty field="attributeList"> @@ -299,5 +299,72 @@ <set field="first.sequenceNum" from-field="getSequenceNum.sequenceNum" type="Long"/> <call-service service-name="updatePortalPage" in-map-name="first"/> </simple-method> + <!-- update Portlet Seq with Drag & Drop --> + <simple-method method-name="updatePortletSeqDragDrop" short-description="Updates a portlet Seq No for the Drag and Drop Feature"> + <set field="parameters.portalPageId" value="${parameters.o_portalPageId}"/> + <call-simple-method method-name="checkOwnerShip"/> + + <!-- origin Portlet --> + <entity-one value-field="originPp" entity-name="PortalPagePortlet"> + <field-map field-name="portalPageId" value="${parameters.o_portalPageId}"/> + <field-map field-name="portalPortletId" value="${parameters.o_portalPortletId}"/> + <field-map field-name="portletSeqId" value="${parameters.o_portletSeqId}"/> + </entity-one> + <!-- destination Portlet --> + <if-compare operator="equals" field="parameters.mode" value="DRAGDROP"> + <entity-one value-field="destiPp" entity-name="PortalPagePortlet"> + <field-map field-name="portalPageId" value="${parameters.d_portalPageId}"/> + <field-map field-name="portalPortletId" value="${parameters.d_portalPortletId}"/> + <field-map field-name="portletSeqId" value="${parameters.d_portletSeqId}"/> + </entity-one> + + <entity-condition list="modifyPpList" entity-name="PortalPagePortlet"> + <condition-list combine="and"> + <condition-expr field-name="portalPageId" operator="equals" value="${parameters.o_portalPageId}"/> + <condition-expr field-name="sequenceNum" operator="greater-equals" value="${destiPp.sequenceNum}"/> + </condition-list> + </entity-condition> + + </if-compare> + + <!-- Portlets to Modify --> + <if-compare operator="equals" field="parameters.mode" value="ColBOTTOM"> + <entity-one value-field="pPColumn" entity-name="PortalPageColumn"> + <field-map field-name="columnSeqId" value="${parameters.destinationColumn}"/> + <field-map field-name="portalPageId" value="${parameters.o_portalPageId}"/> + </entity-one> + <entity-condition list="modifyPpList" entity-name="PortalPagePortlet"> + <condition-list combine="and"> + <condition-expr field-name="portalPageId" operator="equals" value="${parameters.o_portalPageId}" /> + <condition-expr field-name="columnSeqId" operator="equals" value="${pPColumn.columnSeqId}"/> + </condition-list> + <order-by field-name="-sequenceNum" /> + </entity-condition> + <if-not-empty field="modifyPpList"> + <first-from-list entry="destiPp" list="modifyPpList"/> + <entity-condition list="modifyPpList" entity-name="PortalPagePortlet"> + <condition-list combine="and"> + <condition-expr field-name="sequenceNum" operator="greater" value="${destiPp.sequenceNum}"/> + </condition-list> + </entity-condition> + <set field="destiPp.sequenceNum" value="${destiPp.sequenceNum + 1}" type="Long"/> + <else> + <clone-value new-value-field="destiPp" value-field="originPp"/> + <set field="destiPp.columnSeqId" value="${pPColumn.columnSeqId}"/> + </else> + </if-not-empty> + </if-compare> + <if-not-empty field="modifyPpList"> + <iterate entry="modifyPp" list="modifyPpList"> + <set field="modifyPp.sequenceNum" value="${modifyPp.sequenceNum + 1}" type="Long"/> + <store-value value-field="modifyPp"/> + </iterate> + </if-not-empty> + <!-- Origin Portlet Modify --> + <set field="originPp.sequenceNum" from-field="destiPp.sequenceNum"/> + <set field="originPp.columnSeqId" from-field="destiPp.columnSeqId"/> + <store-value value-field="originPp"/> + </simple-method> + <!-- --> </simple-methods> Modified: ofbiz/trunk/framework/common/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=881999&r1=881998&r2=881999&view=diff ============================================================================== --- ofbiz/trunk/framework/common/servicedef/services.xml (original) +++ ofbiz/trunk/framework/common/servicedef/services.xml Wed Nov 18 23:31:59 2009 @@ -412,7 +412,7 @@ location="org.ofbiz.common.preferences.PreferenceServices" invoke="getUserPreference"> <description> Gets a single user preference. - If not found for the specific userLogin, find it for the _NA_ userlogin. + If not found for the specific userLogin, find it for the _NA_ userlogin. If the value is DEFAULT, find the value in general.properties file. </description> <attribute name="userPrefTypeId" type="String" mode="IN" optional="false"/> @@ -635,6 +635,21 @@ <auto-attributes include="pk" mode="IN" optional="false"/> </service> + <!-- update Sequence No for Drag and Drop --> + <service name="updatePortletSeqDragDrop" engine="simple" auth="true" + location="component://common/script/org/ofbiz/common/PortalPageServices.xml" invoke="updatePortletSeqDragDrop"> + <attribute name="o_portalPageId" mode="IN" type="String" ></attribute> + <attribute name="o_portalPortletId" mode="IN" type="String"></attribute> + <attribute name="o_portletSeqId" mode="IN" type="String"></attribute> + + <attribute name="d_portalPageId" mode="IN" type="String" optional="true"></attribute> + <attribute name="d_portalPortletId" mode="IN" type="String" optional="true"></attribute> + <attribute name="d_portletSeqId" mode="IN" type="String" optional="true"></attribute> + + <attribute name="destinationColumn" mode="IN" optional="true" type="String"/> + <attribute name="mode" type="String" mode="IN"/> + </service> + <!-- PortletAttribute services --> <service name="createPortletAttribute" default-entity-name="PortletAttribute" engine="entity-auto" invoke="create" auth="true"> <description>Create a new Portlet Attribute</description> Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/portal-controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/portal-controller.xml?rev=881999&r1=881998&r2=881999&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/WEB-INF/portal-controller.xml (original) +++ ofbiz/trunk/framework/common/webcommon/WEB-INF/portal-controller.xml Wed Nov 18 23:31:59 2009 @@ -75,6 +75,11 @@ <response name="success" type="request" value="ManagePortalPages"/> <response name="error" type="request" value="ManagePortalPages"/> </request-map> + <request-map uri="updatePortalPagePortletSeqAjax"> + <security https="true" auth="true"/> + <event type="service" invoke="updatePortletSeqDragDrop"/> + <response name="success" type="none" /> + </request-map> <request-map uri="createPortalPage"> <security https="true" auth="true"/> <event type="service" invoke="createPortalPage"/> Modified: ofbiz/trunk/framework/common/webcommon/portal/editPortalPage.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/portal/editPortalPage.ftl?rev=881999&r1=881998&r2=881999&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/portal/editPortalPage.ftl (original) +++ ofbiz/trunk/framework/common/webcommon/portal/editPortalPage.ftl Wed Nov 18 23:31:59 2009 @@ -47,13 +47,14 @@ </tr> <tr> <#list portalPageColumnList?if_exists as portalPageColumn> - <td style="vertical-align: top; <#if portalPageColumn.columnWidthPercentage?has_content> width:${portalPageColumn.columnWidthPercentage}%;</#if>"> + <td style="vertical-align: top; <#if portalPageColumn.columnWidthPercentage?has_content> width:${portalPageColumn.columnWidthPercentage}%;</#if>" id="${portalPageColumn.columnSeqId}" name="portalColumn"> + <script type="text/javascript">makeDroppable("${portalPageColumn.columnSeqId}")</script> <#assign firstInColumn = true/> <#list portalPagePortletViewList as portlet> <#if (!portlet.columnSeqId?has_content && portalPageColumn_index == 0) || (portlet.columnSeqId?if_exists == portalPageColumn.columnSeqId)> <#if portlet.screenName?has_content> <#assign portletFields = '<input name="portalPageId" value="' + portlet.portalPageId + '" type="hidden"/><input name="portalPortletId" value="' + portlet.portalPortletId + '" type="hidden"/><input name="portletSeqId" value="' + portlet.portletSeqId + '" type="hidden"/>'> - <div class="portlet-config"> + <div class="portlet-config" id="${portlet_index}" name="portalPortlet"> <div class="portlet-config-title-bar"> <#list portalPages as portalPageList> <#if portalPage.portalPageId != portalPageList.portalPageId> @@ -64,6 +65,9 @@ </#if> </#list> <ul> + <script type="text/javascript">makeDragable("${portlet_index}");</script> + <script type="text/javascript">makeDroppable("${portlet_index}");</script> + <form method="post" action="<@ofbizUrl>updatePortalPagePortletAjax</@ofbizUrl>" name="freeMove_${portlet_index}">${portletFields}<input name="columnSeqId" value="${portalPageColumnList[portalPageColumn_index].columnSeqId}" type="hidden"/><input name="mode" value="RIGHT" type="hidden"/></form> <li class="title">Portlet : ${portlet.portletName?if_exists} [${portlet.portalPortletId}]</li> <li class="remove"><form method="post" action="<@ofbizUrl>deletePortalPagePortlet</@ofbizUrl>" name="removePP_${portlet_index}">${portletFields}</form><a href="javascript:document.removePP_${portlet_index}.submit()"> </a></li> Modified: ofbiz/trunk/framework/common/widget/PortalPageScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/widget/PortalPageScreens.xml?rev=881999&r1=881998&r2=881999&view=diff ============================================================================== --- ofbiz/trunk/framework/common/widget/PortalPageScreens.xml (original) +++ ofbiz/trunk/framework/common/widget/PortalPageScreens.xml Wed Nov 18 23:31:59 2009 @@ -42,7 +42,7 @@ </widgets> </section> </screen> - + <screen name="showPortlet"> <section> <actions> @@ -64,7 +64,7 @@ </widgets> </section> </screen> - + <screen name="showPortalPage"> <section> <actions> @@ -95,10 +95,12 @@ </widgets> </section> </screen> - + <screen name="ManagePortalPages"> <section> <actions> + <set field="layoutSettings.javaScripts[]" value="/images/myportal.js" global="true"/> + <set field="layoutSettings.styleSheets[+0]" value="/images/myportal.css" global="true"/> <entity-one entity-name="PortalPage" value-field="portalPage"/> <script location="component://common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy"/> </actions> @@ -148,12 +150,14 @@ </entity-condition> </actions> <widgets> - <screenlet title="${uiLabelMap.CommonPortalEditPage}: ${portalPage.portalPageName} [${portalPage.portalPageId}]"> - <link target="addPortalPageColumn" style="buttontext" text="${uiLabelMap.CommonAddColumn}"> - <parameter param-name="portalPageId" from-field="portalPage.portalPageId"/> - </link> - <platform-specific><html><html-template location="component://common/webcommon/portal/editPortalPage.ftl"/></html></platform-specific> - </screenlet> + <container id="portalContainerId"> + <screenlet title="${uiLabelMap.CommonPortalEditPage}: ${portalPage.portalPageName} [${portalPage.portalPageId}]"> + <link target="addPortalPageColumn" style="buttontext" text="${uiLabelMap.CommonAddColumn}"> + <parameter param-name="portalPageId" from-field="portalPage.portalPageId"/> + </link> + <platform-specific><html><html-template location="component://common/webcommon/portal/editPortalPage.ftl"/></html></platform-specific> + </screenlet> + </container> </widgets> </section> </decorator-section> Added: ofbiz/trunk/framework/images/webapp/images/loader.gif URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/loader.gif?rev=881999&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/images/webapp/images/loader.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/images/webapp/images/myportal.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/myportal.css?rev=881999&view=auto ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/myportal.css (added) +++ ofbiz/trunk/framework/images/webapp/images/myportal.css Wed Nov 18 23:31:59 2009 @@ -0,0 +1,28 @@ +#loading { +position: absolute; +z-index: 100; +left: 10px; +top: 250px; +background-image: url(/images/myportal_load_bg.png); +background-repeat:repeat; +background-position:top center; +border: 0px !important; +width: 99%; +height: 100%; +} + +#loaderImg { +position: absolute; +top: 200px; +left: 50%; +} + +td.hover { +border: 2px dashed #aaa; +background:#efefef; +} + +div.hover { +border: 2px dashed #aaa; +background:#efefef; +} Added: ofbiz/trunk/framework/images/webapp/images/myportal.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/myportal.js?rev=881999&view=auto ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/myportal.js (added) +++ ofbiz/trunk/framework/images/webapp/images/myportal.js Wed Nov 18 23:31:59 2009 @@ -0,0 +1,141 @@ +//Drag & Drop Functions for myPortal + +//makes portlets dragable +function makeDragable(portletId){ + drag = document.getElementById(portletId); + new Draggable(drag, + {revert: true, reverteffect : + function(drag, top_offset, left_offset) + { new Effect.MoveBy(drag, -top_offset, -left_offset, {duration:0}); } + }); +} + +//makes columns and portlets droppable +function makeDroppable(id){ + var drop = document.getElementById(id); + if(drop.nodeName == "DIV"){ + Droppables.add(drop, { + accept: 'portlet-config', + hoverclass: 'hover', + onDrop: function(element) { + getDestinationInformationPortlets(element.id, id); + } + }); + }else{ + Droppables.add(drop, { + accept: 'portlet-config', + hoverclass: 'hover', + onDrop: function(element) { + getDestinationInformationColumn(element.id, id); + } + }); + } +} + +//calls ajax request for dropping container on a portlet +function getDestinationInformationPortlets(originId, destinationId){ + loadingImage(); + + var move = document.forms['freeMove_' + destinationId]; + var d_portalPageId = move.elements['portalPageId'].value; + var d_portalPortletId = move.elements['portalPortletId'].value; + var d_portletSeqId = move.elements['portletSeqId'].value; + + var move = document.forms['freeMove_' + originId]; + var o_portalPageId = move.elements['portalPageId'].value; + var o_portalPortletId = move.elements['portalPortletId'].value; + var o_portletSeqId = move.elements['portletSeqId'].value; + + new Ajax.Request('/myportal/control/updatePortalPagePortletSeqAjax',{ + method: "post", + parameters: {o_portalPageId: o_portalPageId, o_portalPortletId: o_portalPortletId, o_portletSeqId: o_portletSeqId, + d_portalPageId: d_portalPageId, d_portalPortletId: d_portalPortletId, d_portletSeqId: d_portletSeqId, mode: "DRAGDROP" }, + + onLoading: function(transport){ + }, + + onSuccess: function(transport){ + var destination = document.getElementById(destinationId); + var origin = document.getElementById(originId); + + destination.parentNode.insertBefore(origin, destination); + //Fix for layout Bug + origin.style.left = destination.style.left; + origin.style.top = 0; + }, + + onComplete: function(transport){ + onCompleteRequest(); + } + }); +} + +//calls ajax request for dropping container on a column +function getDestinationInformationColumn(id, destination){ + loadingImage(); + + var destiCol = destination; + var move = document.forms['freeMove_' + id]; + var portalPageId = move.elements['portalPageId'].value; + var portalPortletId = move.elements['portalPortletId'].value; + var portletSeqId = move.elements['portletSeqId'].value; + var mode = move.elements['mode'].value; + + new Ajax.Request('/myportal/control/updatePortalPagePortletSeqAjax',{ + method: "post", + parameters: {destinationColumn: destination, o_portalPageId: portalPageId, o_portalPortletId: portalPortletId, o_portletSeqId: portletSeqId, mode: "ColBOTTOM"}, + + onLoading: function(transport){ + }, + + onSuccess: function(transport){ + //loadingImage(); + var destination = document.getElementById(destiCol); + var origin = document.getElementById(id); + destination.appendChild(origin); + + origin.style.left = destination.style.left; + origin.style.top = 0; + }, + + onComplete: function(transport){ + onCompleteRequest(); + } + }); +} + +//removes the loading image +function onCompleteRequest() { + var loading = document.getElementById("loading"); + if(loading != null){ + //IE Fix (IE treats DOM objects and Javascript objects separately, and you can't extend the DOM objects using Object.prototype) + loading.parentNode.removeChild(loading); + } +} + +//displays the loading image +function loadingImage() { + var container = document.getElementById("portalContainerId"); + var p = document.createElement("p"); + p.setAttribute("id", "loading"); + var img = document.createElement("img"); + img.setAttribute("src", "/images/loader.gif"); + img.setAttribute("id", "loaderImg"); + p.appendChild(img); + container.appendChild(p); +} + +//Workaround for IE getElementsByName Bug +function getElementsByName_iefix(tag, name) { + var elem = document.getElementsByTagName(tag); + var arr = new Array(); + for(i = 0,iarr = 0; i < elem.length; i++) { + att = elem[i].getAttribute("name"); + if(att == name) { + arr[iarr] = elem[i]; + iarr++; + } + } + return arr; +} + Added: ofbiz/trunk/framework/images/webapp/images/myportal_load_bg.png URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/myportal_load_bg.png?rev=881999&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/images/webapp/images/myportal_load_bg.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream |
Free forum by Nabble | Edit this page |