You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2012/10/30 22:20:43 UTC

svn commit: r1403875 - in /ofbiz/branches/20120329_portletWidget: applications/party/config/ applications/party/data/ applications/party/webapp/partymgr/WEB-INF/ applications/party/widget/ applications/party/widget/partymgr/ framework/common/src/org/of...

Author: erwan
Date: Tue Oct 30 21:20:42 2012
New Revision: 1403875

URL: http://svn.apache.org/viewvc?rev=1403875&view=rev
Log:
A patch from Olivier Heintz for portletwidget branch OFBIZ-5060 Add portlet PartyContents and enhance Jquery-upload

Added:
    ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js   (with props)
Modified:
    ofbiz/branches/20120329_portletWidget/applications/party/config/PartyUiLabels.xml
    ofbiz/branches/20120329_portletWidget/applications/party/data/PartyPortletData.xml
    ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/controller-portlet-party.xml
    ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileForms.xml
    ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileMenus.xml
    ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileScreens.xml
    ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/PartyForms.xml
    ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/ProfileScreens.xml
    ofbiz/branches/20120329_portletWidget/framework/common/src/org/ofbiz/common/CommonEvents.java
    ofbiz/branches/20120329_portletWidget/framework/common/webcommon/WEB-INF/common-controller.xml
    ofbiz/branches/20120329_portletWidget/framework/common/widget/CommonScreens.xml
    ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js
    ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
    ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/branches/20120329_portletWidget/applications/party/config/PartyUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/config/PartyUiLabels.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/config/PartyUiLabels.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/config/PartyUiLabels.xml Tue Oct 30 21:20:42 2012
@@ -1071,7 +1071,7 @@
     <property key="FormFieldTitle_partyContentTypeId">
         <value xml:lang="de">Übergeordnete Kontakttyp ID</value>
         <value xml:lang="en">Parent Content Type Id</value>
-        <value xml:lang="fr">Type de contenu parent</value>
+        <value xml:lang="fr">Usage du contenu</value>
         <value xml:lang="hi_IN">उच्च(Parent) सामग्री(content) प्रकार का क्रमांक</value>
         <value xml:lang="it">Tipo contenuto padre</value>
         <value xml:lang="pt_BR">Id do tipo de conteúdo superior</value>

Modified: ofbiz/branches/20120329_portletWidget/applications/party/data/PartyPortletData.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/data/PartyPortletData.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/data/PartyPortletData.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/data/PartyPortletData.xml Tue Oct 30 21:20:42 2012
@@ -212,6 +212,9 @@
         portletTypeId="Screenlet" component="party" subComponent="Profile" useScreen="Y" useScript="N" useMenu="Y" pkIdName="partyId"
         titleLabel="PartyPaymentMethodInformation" screenshot="/images/portlets/PartyPaymentMethods.png"
         securityServiceName="" securityMainAction="VIEW"/>
+  <PortalPortlet portalPortletId="PartyContents" portletName="Contents associated to Party management" description="List and manage Contents associated to one party"
+        portletTypeId="ScreenletList" component="party" subComponent="Profile" useScreen="N" useScript="N" useMenu="Y" pkIdName="partyId"
+        titleLabel="PartyContent" securityMainAction="VIEW"/>
 
   <PortletPortletCategory portalPortletId="PartyInfo" portletCategoryId="PARTY_PROFILE"/>
   <PortletPortletCategory portalPortletId="SelectParty" portletCategoryId="PARTY_PROFILE"/>
@@ -226,6 +229,7 @@
   <PortletPortletCategory portalPortletId="PartyIdentLists" portletCategoryId="PARTY_PROFILE"/>
   <PortletPortletCategory portalPortletId="PartyNotes" portletCategoryId="PARTY_PROFILE"/>
   <PortletPortletCategory portalPortletId="PartyPaymentMethods" portletCategoryId="PARTY_PROFILE"/>
+  <PortletPortletCategory portalPortletId="PartyContents" portletCategoryId="PARTY_PROFILE"/>
 
 
   <PortalPage portalPageId="PartyRecap" sequenceNum="0" portalPageName="Party Profile overview" description="Party profile page whith a lot of portlet" ownerUserLoginId="_NA_"/>
@@ -243,7 +247,8 @@
    <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyRoles" portletSeqId="00001" columnSeqId="00002" sequenceNum="2"/>
    <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyAttributes" portletSeqId="00001" columnSeqId="00002" sequenceNum="3"/>
    <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyAvsSettings" portletSeqId="00001" columnSeqId="00002" sequenceNum="4"/>
-   <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyNotes" portletSeqId="00001" columnSeqId="00002" sequenceNum="5"/>
+   <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyContents" portletSeqId="00001" columnSeqId="00002" sequenceNum="5"/>
+   <PortalPagePortlet portalPageId="PartyRecap" portalPortletId="PartyNotes" portletSeqId="00001" columnSeqId="00002" sequenceNum="6"/>
 
 
   <PortalPortlet portalPortletId="PartyLastVisits" portletName="List last Visits for the Party" description="Last 5 Visits of a certain party"

Modified: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/controller-portlet-party.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/controller-portlet-party.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/controller-portlet-party.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/controller-portlet-party.xml Tue Oct 30 21:20:42 2012
@@ -351,6 +351,28 @@ under the License.
         <response name="success" type="request" value="json"/>
         <response name="error" type="request" value="json"/>
     </request-map>
+<!--#Bam# jquery-submit-upload-file -->
+    <request-map uri="EditPartyContentPt"><security https="true" auth="true"/><response name="success" type="view" value="EditPartyContentPt"/></request-map>
+    <request-map uri="updatePartyContentJson">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="updatePartyContent"/>
+        <response name="success" type="request" value="json"/>
+        <response name="error" type="request" value="json"/>
+    </request-map>
+    <request-map uri="uploadPartyContentJson">
+        <security auth="true" https="true"/>
+        <event type="service" invoke="uploadPartyContentFile"/>
+        <response name="success" type="request" value="jsonUpload"/>
+        <response name="error" type="request" value="jsonUpload"/>
+    </request-map>
+    <request-map uri="removePartyContentJson">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="removePartyContent"/>
+        <response name="success" type="request" value="showPortlet"/>
+        <response name="error" type="request" value="showPortlet"/>
+    </request-map>
+<!--#Eam# jquery-submit-upload-file -->
+
 
     <request-map uri="editPartyAttributePt">
       <security https="true" auth="true"/>
@@ -434,6 +456,8 @@ under the License.
 
     <view-map name="EditPartyNotePt" type="screen" page="component://party/widget/ProfileScreens.xml#EditPartyNote"/>
     <view-map name="AssocPartyNotePt" type="screen" page="component://party/widget/ProfileScreens.xml#AssocPartyNote"/>
+    <view-map name="EditPartyContentPt" type="screen" page="component://party/widget/ProfileScreens.xml#EditPartyContent"/><!--#Eam# jquery-submit-upload-file -->
+
     <view-map name="editPartyAttributePt" type="screen" page="component://party/widget/ProfileScreens.xml#EditPartyAttribute"/>
     <view-map name="editavsoverridePt"    type="screen" page="component://party/widget/ProfileScreens.xml#editavsoverride"/>
     <view-map name="visitdetailPt"        type="screen" page="component://party/widget/VisitScreens.xml#visitdetail"/>

Modified: ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileForms.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileForms.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileForms.xml Tue Oct 30 21:20:42 2012
@@ -248,6 +248,7 @@ under the License.
         <field name="PartyUserLoginsMenu">   <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
         <field name="PartyRolesMenu">        <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
         <field name="PartyNotesMenu">        <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
+        <field name="PartyContentsMenu">     <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
         <field name="PartyPaymentsMenu">     <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
         <field name="PartyIdentListsMenu">   <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
         <field name="PartyAttributesMenu">   <radio no-current-selected-key="Y"><option key="Y"/><option key="N"/></radio></field>
@@ -869,6 +870,97 @@ under the License.
           <parameter param-name="partyId"/>
         </on-event-update-area>
     </form>
+     <form name="PartyContents" type="list" list-name="listIt" separate-columns="false" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+        <actions>
+            <entity-and entity-name="PartyContentDetail" list="listIt">
+                <field-map field-name="partyId" from-field="parameters.partyId"/>
+            </entity-and>
+        </actions>
+        <field name="partyId"><hidden/></field>
+        <field name="contentId" title="${uiLabelMap.CommonId}">
+          <show-portlet portlet-id="${portalPortletId}" target="EditPartyContentPt" area-id="${editAreaDivId}" description="${contentId}">
+            <parameter param-name="contentId"/>
+            <parameter param-name="partyId"/>
+            <parameter param-name="partyContentTypeId"/>
+            <parameter param-name="fromDate"/>
+          </show-portlet>
+        </field>
+        <field name="contentName"><display/></field>
+        <field name="partyContentTypeId"><display-entity entity-name="PartyContentType"/></field>
+        <field name="description"><display/></field>
+        <field name="statusId"><display-entity entity-name="StatusItem"/></field>
+        <field name="localeString"><display-entity entity-name="CountryCode" key-field-name="countryCode" description="${countryName}${countryCode}"/></field>
+<!--        <field name="contentTypeId"><display-entity entity-name="ContentType"/></field>-->
+        <field name="mimeTypeId"><display-entity entity-name="MimeType"/></field>
+        <field name="dataResourceId" title="${uiLabelMap.FormFieldTitle_dataResourceName}" use-when="dataResourceId==null"><display/> </field>
+        <field name="dataResourceId" title="${uiLabelMap.FormFieldTitle_dataResourceName}" use-when="dataResourceId!=null">
+            <display-entity entity-name="DataResource" description="${dataResourceName}"/>
+        </field>
+       <field name="viewLink" title=" " use-when="dataResourceId!=null">
+            <hyperlink target="img/${contentName}" target-type="inter-app" target-window="upload" image-location="${iconsPurpose.Download}" image-title="${uiLabelMap.IconsTooltips_Download}">
+                <parameter param-name="imgId" from-field="dataResourceId"/>
+            </hyperlink>
+        </field>
+        <field name="deleteLink" title=" ">
+            <show-portlet portlet-id="${portalPortletId}" area-id="${areaId}" target="removePartyContentJson" image-location="${iconsPurpose.Delete}" image-title="${uiLabelMap.IconsTooltips_Delete}" request-confirmation="true" confirmation-message="${uiLabelMap.CommonConfirmDelete} : ${contentName}">
+                   <parameter param-name="contentId"/>
+                   <parameter param-name="partyId"/>
+                   <parameter param-name="partyContentTypeId"/>
+                   <parameter param-name="fromDate"/>
+            </show-portlet>
+        </field>
+    </form>
+
+    <form name="EditPartyContent" target="updatePartyContentJson" type="upload" default-map-name="content"
+        focus-field-name="contentTypeId" header-row-style="header-row" default-table-style="basic-table">
+        <actions>
+            <entity-one entity-name="StatusItem" value-field="currentStatus" auto-field-map="false">
+                <field-map field-name="statusId" from-field="content.statusId"/>
+            </entity-one>
+            <entity-one entity-name="DataResource" value-field="dataResource" auto-field-map="false">
+                <field-map field-name="dataResourceId" from-field="content.dataResourceId"/>
+            </entity-one>
+        </actions>
+        <alt-target use-when="content==null" target="uploadPartyContentJson"/>
+        <field name="partyId" map-name="parameters"><hidden/></field>
+        <field name="dataResourceId" map-name="dataResource" use-when="content!=null"><hidden/></field>
+        <field use-when="content!=null" name="contentId" tooltip="${uiLabelMap.CommonNotModifRecreat}"><display/></field>
+        <field name="dataCategoryId"><hidden value="PERSONAL"/></field>
+        <field name="contentTypeId"><hidden value="DOCUMENT"/></field>
+        <field name="statusId"><hidden value="CTNT_PUBLISHED"/></field>
+        <field name="uploadedFile" title="${uiLabelMap.CommonUpload}" use-when="content==null"><file/></field>
+        <field name="fromDate" use-when="content!=null"><display type="date-time"/></field>
+        <field name="thruDate" use-when="content!=null"><date-time/></field>
+        <field name="partyContentTypeId">
+            <drop-down allow-empty="false">
+                <entity-options description="${description}" entity-name="PartyContentType"/>
+            </drop-down>
+        </field>
+        <field name="mimeTypeId" >
+            <drop-down allow-empty="false">
+                <entity-options description="${description}" entity-name="MimeType"/>
+            </drop-down>
+        </field>
+        <field name="isPublic" title="${uiLabelMap.PartyIsPublic}" map-name="dataResource">
+            <drop-down no-current-selected-key="N">
+                <option key="N" description="${uiLabelMap.CommonNo}"/>
+                <option key="Y" description="${uiLabelMap.CommonYes}"/>
+            </drop-down>
+        </field>
+        <field name="submitButton" title="${groovy: content==null ? uiLabelMap.CommonAdd: uiLabelMap.CommonSave}"><submit button-type="button"/></field>
+        <field name="back" title=" " position="2" widget-style="buttontext">
+            <show-portlet portlet-id="${parameters.portalPortletId}" area-id="${parameters.areaId}" description="${uiLabelMap.CommonBack}" >
+               <parameter param-name="partyId" from-field="parameters.partyId"/>
+            </show-portlet>
+        </field>
+        <on-event-update-area event-type="submit" area-id="${parameters.areaId}" area-target="showPortlet">
+             <parameter param-name="partyId" from-field="parameters.partyId"/>
+        </on-event-update-area>
+        <sort-order>
+            <sort-field name="uploadedFile"/>
+        </sort-order>
+    </form>
+
 
 
     <form name="PartyAttributes" type="list" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">

Modified: ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileMenus.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileMenus.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileMenus.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileMenus.xml Tue Oct 30 21:20:42 2012
@@ -143,6 +143,20 @@
               <parameter param-name="partyId" from-field="parameters.partyId"/>
             </show-portlet>
         </menu-item>
+
+        <menu-item name="PartyContents">
+            <condition>
+              <or>
+                  <if-empty field="PartyContentsMenu"/>
+                  <if-compare field="PartyContentsMenu" operator="equals" value="Y"/>
+              </or>
+            </condition>
+            <show-portlet portlet-id="PartyContents" target="ShowPartyDetail" area-id="${areaId}" image-location="${iconsPurpose.Attach}" 
+                                                                                                    image-title="${uiLabelMap.IconsTooltips_Attach}">
+              <parameter param-name="partyId" from-field="parameters.partyId"/>
+            </show-portlet>
+        </menu-item>
+
         <menu-item name="PartyPayments">
             <condition>
               <or>
@@ -475,6 +489,24 @@
       </menu-item>
     </menu>
 
+    <menu name="PartyContents" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
+        <actions>
+            <set field="areaId" from-field="parameters.areaId" default-value="${currentAreaId}"/>
+        </actions>
+        <menu-item name="RefreshPortlet">
+            <show-portlet portlet-id="${portalPortletId}" area-id="${areaId}" image-location="${iconsPurpose.Refresh}" image-title="${uiLabelMap.IconsTooltips_Refresh}">
+                 <parameter param-name="partyId" from-field="parameters.partyId"/>
+            </show-portlet>
+        </menu-item>
+        <menu-item name="AddPartyContent">
+            <condition><not><if-empty field="parameters.partyId"/></not></condition>
+            <show-portlet portlet-id="${portalPortletId}" target="EditPartyContentPt" area-id="${editAreaDivId}" image-location="${iconsPurpose.Add}" image-title="${uiLabelMap.IconsTooltips_Add}">
+               <parameter param-name="partyId" from-field="parameters.partyId"/>
+            </show-portlet>
+        </menu-item>
+    </menu>
+
+
     <menu name="PartyAttributes" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
         <actions>
             <set field="areaId" from-field="parameters.areaId" default-value="${currentAreaId}"/>

Modified: ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileScreens.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileScreens.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/widget/ProfileScreens.xml Tue Oct 30 21:20:42 2012
@@ -454,6 +454,25 @@
         </section>
     </screen>
 
+    <screen name="EditPartyContent">
+        <section>
+            <condition><not><if-empty field="parameters.partyId"/></not></condition>
+            <actions>
+                <set field="partyId" from-field="parameters.partyId"/>
+                <set field="contentId" from-field="parameters.contentId"/>
+                <entity-one value-field="content" entity-name="PartyContentDetail"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="portletUiLabelDecorator" location="component://party/widget/CommonScreens.xml">
+                    <decorator-section name="body">
+                         <include-form name="EditPartyContent" location="component://party/widget/ProfileForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+
+
     <screen name="PartyPaymentMethods">
         <section>
             <condition><not><if-empty field="parameters.partyId"/></not></condition>

Modified: ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/PartyForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/PartyForms.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/PartyForms.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/PartyForms.xml Tue Oct 30 21:20:42 2012
@@ -633,6 +633,23 @@ under the License.
         <field name="createButton" use-when="content==null"><submit button-type="button"/></field>
         <field name="updateButton" use-when="content!=null"><submit button-type="button"/></field>
     </form>
+<!--#Bam# jquery-submit-upload-file 
+     currently not activated, is for : if used uploadJs for screen
+    <form name="UploadPartyContent" extends="AddPartyContent">
+        <actions>
+            <set field="content" from-field="nullField"/>
+        </actions>
+        <alt-target use-when="content==null" target="uploadPartyContentJson"/>
+        <field name="dataResourceName"><ignored/></field>
+        <field name="uploadedFile" title="${uiLabelMap.CommonUpload}"><file/></field>
+        <on-event-update-area area-target="partyContentList" event-type="submit" area-id="partyContentList">
+            <parameter param-name="partyId"/>
+        </on-event-update-area>
+        <sort-order>
+            <sort-field name="uploadedFile"/>
+        </sort-order>
+    </form>
+#Eam# jquery-submit-upload-file  -->
 
     <form name="ListPartyContents" type="list" separate-columns="false"
         odd-row-style="alternate-row" default-table-style="basic-table hover-bar">

Modified: ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/ProfileScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/ProfileScreens.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/ProfileScreens.xml (original)
+++ ofbiz/branches/20120329_portletWidget/applications/party/widget/partymgr/ProfileScreens.xml Tue Oct 30 21:20:42 2012
@@ -439,6 +439,12 @@
                         <html-template location="component://party/webapp/partymgr/party/profileblocks/Content.ftl"/>
                     </html>
                 </platform-specific>
+<!--#Bam# jquery-submit-upload-file 
+     currently not activated, is for : if used uploadJs for screen
+                <screenlet title="${uiLabelMap.PageTitleAddPartyContent}">
+                    <include-form name="UploadPartyContent" location="component://party/widget/partymgr/PartyForms.xml"/>
+                </screenlet>
+#Eam# jquery-submit-upload-file -->
             </widgets>
         </section>
     </screen>

Modified: ofbiz/branches/20120329_portletWidget/framework/common/src/org/ofbiz/common/CommonEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/common/src/org/ofbiz/common/CommonEvents.java?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/common/src/org/ofbiz/common/CommonEvents.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/common/src/org/ofbiz/common/CommonEvents.java Tue Oct 30 21:20:42 2012
@@ -274,8 +274,26 @@ public class CommonEvents {
 
         return "success";
     }
+    /*#Bam# jquery-submit-upload-file*/
+    public static String jsonUploadResponseFromRequestAttributes(HttpServletRequest request, HttpServletResponse response) {
+        // pull out the service response from the request attribute
+        Map<String, Object> attrMap = UtilHttp.getJSONAttributeMap(request);
+
+        // create a JSON Object for return
+        JSONObject json = JSONObject.fromObject(attrMap);
+        writeJSONtoResponse(json, response, "text/html"); //text-html since jquery.upload don't work wit contentType application/x-json : http://lagoscript.org/jquery/upload/documentation
+
+        return "success";
+    }
+    /*#Eam# jquery-submit-upload-file*/
 
     private static void writeJSONtoResponse(JSON json, HttpServletResponse response) {
+        /*#Bam# jquery-submit-upload-file*/
+        writeJSONtoResponse(json, response, "application/x-json");
+    }
+
+    private static void writeJSONtoResponse(JSON json, HttpServletResponse response, String contentType ) {
+    /*#Eam# jquery-submit-upload-file*/
         String jsonStr = json.toString();
         if (jsonStr == null) {
             Debug.logError("JSON Object was empty; fatal error!", module);
@@ -283,7 +301,11 @@ public class CommonEvents {
         }
 
         // set the X-JSON content type
+        /*#Bam# jquery-submit-upload-file
         response.setContentType("application/x-json");
+        */
+        response.setContentType(contentType);
+        /*#Eam# jquery-submit-upload-file*/
         // jsonStr.length is not reliable for unicode characters
         try {
             response.setContentLength(jsonStr.getBytes("UTF8").length);

Modified: ofbiz/branches/20120329_portletWidget/framework/common/webcommon/WEB-INF/common-controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/common/webcommon/WEB-INF/common-controller.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/common/webcommon/WEB-INF/common-controller.xml (original)
+++ ofbiz/branches/20120329_portletWidget/framework/common/webcommon/WEB-INF/common-controller.xml Tue Oct 30 21:20:42 2012
@@ -180,6 +180,13 @@ under the License.
         <event type="java" path="org.ofbiz.common.CommonEvents" invoke="jsonResponseFromRequestAttributes"/>
         <response name="success" type="none"/>
     </request-map>
+    <!--#Bam# jquery-submit-upload-file -->
+    <request-map uri="jsonUpload">
+        <security direct-request="false"/>
+        <event type="java" path="org.ofbiz.common.CommonEvents" invoke="jsonUploadResponseFromRequestAttributes"/>
+        <response name="success" type="none"/>
+    </request-map>
+    <!--#Eam# jquery-submit-upload-file -->
 
     <request-map uri="showHelp">
         <security https="true" auth="true"/>

Modified: ofbiz/branches/20120329_portletWidget/framework/common/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/common/widget/CommonScreens.xml?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/common/widget/CommonScreens.xml (original)
+++ ofbiz/branches/20120329_portletWidget/framework/common/widget/CommonScreens.xml Tue Oct 30 21:20:42 2012
@@ -145,6 +145,7 @@ under the License.
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.js" global="true" />
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.0.5.js" global="true" />
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jquery.maskedinput-1.2.2.min.js" global="true" />
+                <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jquery.upload.js" global="true"/><!--#Eam# jquery-submit-upload-file -->
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/js/jquery-ui-1.9.0.custom.min.js" global="true" />
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jeditable/jquery.jeditable.js" global="true" />
                 <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/validate/jquery.validate.min.js" global="true" />

Added: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js?rev=1403875&view=auto
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js (added)
+++ ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js Tue Oct 30 21:20:42 2012
@@ -0,0 +1,266 @@
+/*
+ * jQuery.upload v1.0.2
+ *
+ * Copyright (c) 2010 lagos
+ * Dual licensed under the MIT and GPL licenses.
+ *
+ * http://lagoscript.org
+ */
+(function($) {
+
+	var uuid = 0;
+
+	$.fn.upload = function(url, data, callback, type) {
+		var self = this, inputs, checkbox, checked,
+			iframeName = 'jquery_upload' + ++uuid,
+			iframe = $('<iframe name="' + iframeName + '" style="position:absolute;top:-9999px" />').appendTo('body'),
+			form = '<form target="' + iframeName + '" method="post" enctype="multipart/form-data" />';
+
+		if ($.isFunction(data)) {
+			type = callback;
+			callback = data;
+			data = {};
+		}
+
+		checkbox = $('input:checkbox', this);
+		checked = $('input:checked', this);
+		form = self.wrapAll(form).parent('form').attr('action', url);
+
+		// Make sure radios and checkboxes keep original values
+		// (IE resets checkd attributes when appending)
+		checkbox.removeAttr('checked');
+		checked.attr('checked', true);
+
+		inputs = createInputs(data);
+		inputs = inputs ? $(inputs).appendTo(form) : null;
+
+		form.submit(function() {
+			iframe.load(function() {
+				var data = handleData(this, type),
+					checked = $('input:checked', self);
+
+				form.after(self).remove();
+				checkbox.removeAttr('checked');
+				checked.attr('checked', true);
+				if (inputs) {
+					inputs.remove();
+				}
+
+				setTimeout(function() {
+					iframe.remove();
+					if (type === 'script') {
+						$.globalEval(data);
+					}
+					if (callback) {
+						callback.call(self, data);
+					}
+				}, 0);
+			});
+		}).submit();
+
+		return this;
+	};
+
+	function createInputs(data) {
+		return $.map(param(data), function(param) {
+			return '<input type="hidden" name="' + param.name + '" value="' + param.value + '"/>';
+		}).join('');
+	}
+
+	function param(data) {
+		if ($.isArray(data)) {
+			return data;
+		}
+		var params = [];
+
+		function add(name, value) {
+			params.push({name:name, value:value});
+		}
+
+		if (typeof data === 'object') {
+			$.each(data, function(name) {
+				if ($.isArray(this)) {
+					$.each(this, function() {
+						add(name, this);
+					});
+				} else {
+					add(name, $.isFunction(this) ? this() : this);
+				}
+			});
+		} else if (typeof data === 'string') {
+			$.each(data.split('&'), function() {
+				var param = $.map(this.split('='), function(v) {
+					return decodeURIComponent(v.replace(/\+/g, ' '));
+				});
+
+				add(param[0], param[1]);
+			});
+		}
+
+		return params;
+	}
+
+	function handleData(iframe, type) {
+		var data, contents = $(iframe).contents().get(0);
+
+		if ($.isXMLDoc(contents) || contents.XMLDocument) {
+			return contents.XMLDocument || contents;
+		}
+		data = $(contents).find('body').html();
+
+		switch (type) {
+			case 'xml':
+				data = parseXml(data);
+				break;
+			case 'json':
+				data = window.eval('(' + data + ')');
+				break;
+		}
+		return data;
+	}
+
+	function parseXml(text) {
+		if (window.DOMParser) {
+			return new DOMParser().parseFromString(text, 'application/xml');
+		} else {
+			var xml = new ActiveXObject('Microsoft.XMLDOM');
+			xml.async = false;
+			xml.loadXML(text);
+			return xml;
+		}
+	}
+
+})(jQuery);
+/*
+ * jQuery.upload v1.0.2
+ *
+ * Copyright (c) 2010 lagos
+ * Dual licensed under the MIT and GPL licenses.
+ *
+ * http://lagoscript.org
+ */
+(function($) {
+
+	var uuid = 0;
+
+	$.fn.upload = function(url, data, callback, type) {
+		var self = this, inputs, checkbox, checked,
+			iframeName = 'jquery_upload' + ++uuid,
+			iframe = $('<iframe name="' + iframeName + '" style="position:absolute;top:-9999px" />').appendTo('body'),
+			form = '<form target="' + iframeName + '" method="post" enctype="multipart/form-data" />';
+
+		if ($.isFunction(data)) {
+			type = callback;
+			callback = data;
+			data = {};
+		}
+
+		checkbox = $('input:checkbox', this);
+		checked = $('input:checked', this);
+		form = self.wrapAll(form).parent('form').attr('action', url);
+
+		// Make sure radios and checkboxes keep original values
+		// (IE resets checkd attributes when appending)
+		checkbox.removeAttr('checked');
+		checked.attr('checked', true);
+
+		inputs = createInputs(data);
+		inputs = inputs ? $(inputs).appendTo(form) : null;
+
+		form.submit(function() {
+			iframe.load(function() {
+				var data = handleData(this, type),
+					checked = $('input:checked', self);
+
+				form.after(self).remove();
+				checkbox.removeAttr('checked');
+				checked.attr('checked', true);
+				if (inputs) {
+					inputs.remove();
+				}
+
+				setTimeout(function() {
+					iframe.remove();
+					if (type === 'script') {
+						$.globalEval(data);
+					}
+					if (callback) {
+						callback.call(self, data);
+					}
+				}, 0);
+			});
+		}).submit();
+
+		return this;
+	};
+
+	function createInputs(data) {
+		return $.map(param(data), function(param) {
+			return '<input type="hidden" name="' + param.name + '" value="' + param.value + '"/>';
+		}).join('');
+	}
+
+	function param(data) {
+		if ($.isArray(data)) {
+			return data;
+		}
+		var params = [];
+
+		function add(name, value) {
+			params.push({name:name, value:value});
+		}
+
+		if (typeof data === 'object') {
+			$.each(data, function(name) {
+				if ($.isArray(this)) {
+					$.each(this, function() {
+						add(name, this);
+					});
+				} else {
+					add(name, $.isFunction(this) ? this() : this);
+				}
+			});
+		} else if (typeof data === 'string') {
+			$.each(data.split('&'), function() {
+				var param = $.map(this.split('='), function(v) {
+					return decodeURIComponent(v.replace(/\+/g, ' '));
+				});
+
+				add(param[0], param[1]);
+			});
+		}
+
+		return params;
+	}
+
+	function handleData(iframe, type) {
+		var data, contents = $(iframe).contents().get(0);
+
+		if ($.isXMLDoc(contents) || contents.XMLDocument) {
+			return contents.XMLDocument || contents;
+		}
+		data = $(contents).find('body').html();
+
+		switch (type) {
+			case 'xml':
+				data = parseXml(data);
+				break;
+			case 'json':
+				data = window.eval('(' + data + ')');
+				break;
+		}
+		return data;
+	}
+
+	function parseXml(text) {
+		if (window.DOMParser) {
+			return new DOMParser().parseFromString(text, 'application/xml');
+		} else {
+			var xml = new ActiveXObject('Microsoft.XMLDOM');
+			xml.async = false;
+			xml.loadXML(text);
+			return xml;
+		}
+	}
+
+})(jQuery);

Propchange: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/jquery/plugins/jquery.upload.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js Tue Oct 30 21:20:42 2012
@@ -425,6 +425,46 @@ function ajaxSubmitFormUpdateAreas(form,
        }
    });
 }
+//#Bam# jquery-submit-upload-file
+/** Submit form, update multiple areas (HTML container elements).
+ * @param form The form element
+ * @param areaCsvString The area CSV string. The CSV string is a flat array in the
+ * form of: areaId, target, target parameters [, areaId, target, target parameters...].
+*/
+function ajaxUploadFormUpdateAreas(form, areaCsvString) {
+       waitSpinnerShow();
+       hideErrorContainer = function() {
+           jQuery('#content-messages').removeClass('errorMessage').fadeIn('fast');
+       }
+       updateFunction = function(data) {
+           if (data._ERROR_MESSAGE_LIST_ != undefined || data._ERROR_MESSAGE_ != undefined) {
+               if(!jQuery('#content-messages')) {
+                  //add this div just after app-navigation
+                  if(jQuery('#content-main-section')){
+                      jQuery('#content-main-section' ).before('<div id="content-messages" onclick="hideErrorContainer()"></div>');
+                  }
+               }
+               jQuery('#content-messages').addClass('errorMessage');
+              if (data._ERROR_MESSAGE_LIST_ != undefined && data._ERROR_MESSAGE_ != undefined) {
+                 jQuery('#content-messages' ).html(data._ERROR_MESSAGE_LIST_ + " " + data._ERROR_MESSAGE_);
+              } else if (data._ERROR_MESSAGE_LIST_ != undefined) {
+                  jQuery('#content-messages' ).html(data._ERROR_MESSAGE_LIST_);
+              } else {
+                  jQuery('#content-messages' ).html(data._ERROR_MESSAGE_);
+              }
+              jQuery('#content-messages').fadeIn('fast');
+           }else {
+               if(jQuery('#content-messages')) {
+                   jQuery('#content-messages').removeClass('errorMessage').fadeIn("fast");
+               }
+               ajaxUpdateAreas(areaCsvString);
+           }
+           waitSpinnerHide();
+       }
+
+   jQuery("#fields_" + form).upload(jQuery("#" + form).attr("action"), function(data) {updateFunction(data)}, 'json');
+}
+//#Eam# jquery-submit-upload-file
 
 /** Enable auto-completion for text elements, with a possible span of tooltip class showing description.
  * @param areaCsvString The area CSV string. The CSV string is a flat array in the

Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Oct 30 21:20:42 2012
@@ -1127,6 +1127,7 @@ public class MacroFormRenderer implement
         String name = modelFormField.getParameterName(context);
         String buttonType =  submitField.getButtonType();
         String formName = modelForm.getCurrentFormName(context);
+        String formType = modelForm.getType();
         String imgSrc = submitField.getImageLocation(context);
         String confirmation = submitField.getConfirmation(context);
         String className = "";
@@ -1171,6 +1172,8 @@ public class MacroFormRenderer implement
         sr.append(alert);
         sr.append("\" formName=\"");
         sr.append(formName);
+        sr.append("\" formType=\"");
+        sr.append(formType);
         sr.append("\" title=\"");
         sr.append(encode(title, modelFormField, context));
         sr.append("\" name=\"");
@@ -1420,6 +1423,7 @@ public class MacroFormRenderer implement
     public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
         String focusFieldName = modelForm.getfocusFieldName();
         String formName = modelForm.getCurrentFormName(context);
+        String formType = modelForm.getType();
         String containerId = modelForm.getCurrentContainerId(context);
         String hasRequiredField = "";
         for (ModelFormField formField : modelForm.getFieldList()) {
@@ -1434,6 +1438,8 @@ public class MacroFormRenderer implement
         sr.append(focusFieldName);
         sr.append("\" formName=\"");
         sr.append(formName);
+        sr.append("\" formType=\"");
+        sr.append(formType);
         sr.append("\" containerId=\"");
         sr.append(containerId);
         sr.append("\" hasRequiredField=\"");

Modified: ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1403875&r1=1403874&r2=1403875&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl Tue Oct 30 21:20:42 2012
@@ -293,15 +293,13 @@ ${item.description}</span>
 </#list>
 </#macro>
 
-<#-- <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl> -->
-<#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl returnParams>
+<#macro renderSubmitField buttonType className alert formName formType title name event action imgSrc confirmation containerId ajaxUrl returnParams>
 <#if buttonType=="text-link">
  <a <@renderClass className alert /> href="javascript:document.${formName}.submit()" <#if confirmation?has_content>onclick="return confirm('${confirmation?js_string}');"</#if>><#if title?has_content>${title}</#if> </a>
 <#elseif buttonType=="image">
  <input type="image" src="${imgSrc}" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if title?has_content> alt="${title}"</#if><#if event?has_content> ${event}="${action}"</#if> <#if confirmation?has_content>onclick="return confirm('${confirmation?js_string}');"</#if>/>
 <#else>
-<#--<input type="<#if containerId?has_content>button<#else>submit</#if>" <@renderClass className alert /><#if name?exists> name="${name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId?has_content> onclick="<#if confirmation?has_content>if (confirm('${confirmation?js_string}')) </#if>ajaxSubmitFormUpdateAreas('${containerId}', '${ajaxUrl}')"<#else><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}');"</#if></#if>/></#if>-->
-<input type="<#if containerId?has_content>button<#else>submit</#if>" <@renderClass className alert /><#if name?exists> name="${name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId?has_content> onclick="<#if confirmation?has_content>if (confirm('${confirmation?js_string}')) </#if><#if returnParams?has_content>ajaxSubmitFormUpdateAreasWithReturn('${containerId}', '${ajaxUrl}', ${returnParams})"<#else>ajaxSubmitFormUpdateAreas('${containerId}', '${ajaxUrl}')"</#if><#else><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}');"</#if></#if>/></#if>
+<input type="<#if containerId?has_content>button<#else>submit</#if>" <@renderClass className alert /><#if name?exists> name="${name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId?has_content> onclick="<#if confirmation?has_content>if (confirm('${confirmation?js_string}')) </#if><#if returnParams?has_content>ajax<#if formType=="upload">Upload<#else>Submit</#if>FormUpdateAreasWithReturn('${containerId}', '${ajaxUrl}', ${returnParams})"<#else>ajax<#if formType=="upload">Upload<#else>Submit</#if>FormUpdateAreas('${containerId}', '${ajaxUrl}')"</#if><#else><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}');"</#if></#if>/></#if>
 </#macro>
 
 <#macro renderResetField className alert name title>
@@ -325,6 +323,9 @@ ${item.description}</span>
 <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit>
 
     <form method="post" action="${linkUrl}"<#if formType=="upload"> enctype="multipart/form-data"</#if><#if targetWindow?has_content> target="${targetWindow}"</#if><#if containerId?has_content> id="${containerId}"</#if> class=<#if containerStyle?has_content>"${containerStyle}"<#else>"basic-form"</#if> onsubmit="javascript:submitFormDisableSubmits(this)"<#if autocomplete?has_content> autocomplete="${autocomplete}"</#if> name="${name}"><#lt/>
+    <#if formType?has_content && formType=="upload">
+        <div id="fields_${containerId}">
+    </#if>
     <#if useRowSubmit?has_content && useRowSubmit>
         <input type="hidden" name="_useRowSubmit" value="Y"/>
         <#if linkUrl?index_of("VIEW_INDEX") &lt;= 0 && linkUrl?index_of(viewIndexField) &lt;= 0>
@@ -335,7 +336,10 @@ ${item.description}</span>
         </#if>
     </#if>
 </#macro>
-<#macro renderFormClose focusFieldName formName containerId hasRequiredField>
+<#macro renderFormClose focusFieldName formName formType containerId hasRequiredField>
+    <#if formType?has_content && formType=="upload">
+        <div id="fields_${containerId}">
+    </#if>
     </form><#lt/>
     <#if focusFieldName?has_content>
         <script language="JavaScript" type="text/javascript">