svn commit: r888030 - in /ofbiz/trunk/framework: common/entitydef/ common/webcommon/WEB-INF/ images/webapp/images/ widget/dtd/ widget/src/org/ofbiz/widget/screen/ widget/templates/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r888030 - in /ofbiz/trunk/framework: common/entitydef/ common/webcommon/WEB-INF/ images/webapp/images/ widget/dtd/ widget/src/org/ofbiz/widget/screen/ widget/templates/

buscob
Author: buscob
Date: Mon Dec  7 17:24:21 2009
New Revision: 888030

URL: http://svn.apache.org/viewvc?rev=888030&view=rev
Log:
Added a new feature that allows to save the screenlet collapsed/expanded status as a userPreference. (OFBIZ-3271)
By default screenlets status are saved. A new "save-collapsed" screenlet attribute (default=true) can be used to disable this feature for selected screenlets.
An userPreference with key = screenlet.id+"_collapsed" is used to save the status.
Screenlets that share the same ID, share the same saved status also (i.e. all searchOptions screenlets used in the FindScreenDecorator use the same status). In order to have them separated a different ID should be specified.

Modified:
    ofbiz/trunk/framework/common/entitydef/entitymodel.xml
    ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
    ofbiz/trunk/framework/images/webapp/images/selectall.js
    ofbiz/trunk/framework/widget/dtd/widget-screen.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
    ofbiz/trunk/framework/widget/templates/csvScreenMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/foScreenMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/textScreenMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/xmlScreenMacroLibrary.ftl

Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Mon Dec  7 17:24:21 2009
@@ -540,7 +540,7 @@
           other data types by specifying a java data type in the userPrefDataType field.
       </description>
       <field name="userLoginId" type="id-vlong-ne"></field>
-      <field name="userPrefTypeId" type="id-ne"><description>A unique identifier for this preference</description></field>
+      <field name="userPrefTypeId" type="id-long-ne"><description>A unique identifier for this preference</description></field>
       <field name="userPrefGroupTypeId" type="id-long"><description>Used to assemble groups of preferences</description></field>
       <field name="userPrefValue" type="value"><description>Contains the value of this preference</description></field>
       <field name="userPrefDataType" type="id-long"><description>The java data type of this preference (empty = java.lang.String)</description></field>

Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml (original)
+++ ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml Mon Dec  7 17:24:21 2009
@@ -116,6 +116,12 @@
         <response name="error" type="request" value="main"/>
     </request-map>
 
+    <request-map uri="ajaxSetUserPreference">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="setUserPreference"/>
+        <response name="success" type="none"/>
+    </request-map>
+
     <request-map uri="ajaxAutocompleteOptions">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="ajaxAutocompleteOptions"/>

Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/selectall.js Mon Dec  7 17:24:21 2009
@@ -383,16 +383,22 @@
   * @param expandTxt Localized 'Expand' text
   * @param collapseTxt Localized 'Collapse' text
 */
-function toggleScreenlet(link, areaId, expandTxt, collapseTxt){
+function toggleScreenlet(link, areaId, saveCollapsed, expandTxt, collapseTxt){
     toggleCollapsiblePanel(link, areaId, expandTxt, collapseTxt);
     var container = $(areaId);
     var screenlet = container.up('div');
     if(container.visible()){
         var currentParam = screenlet.id + "_collapsed=false";
         var newParam = screenlet.id + "_collapsed=true";
+        if(saveCollapsed=='true'){
+            setUserLayoutPreferences('GLOBAL_PREFERENCES',screenlet.id+"_collapsed",'true');
+        }
     } else {
         var currentParam = screenlet.id + "_collapsed=true";
         var newParam = screenlet.id + "_collapsed=false";
+        if(saveCollapsed=='true'){
+            setUserLayoutPreferences('GLOBAL_PREFERENCES',screenlet.id+"_collapsed",'false');
+        }
     }
     var paginationMenus = $$('div.nav-pager');
     paginationMenus.each(function(menu) {
@@ -496,3 +502,22 @@
     }
   }
 }
+
+//calls ajax request for storing user layout preferences
+function setUserLayoutPreferences(userPrefGroupTypeId, userPrefTypeId, userPrefValue){
+  new Ajax.Request('ajaxSetUserPreference',{
+    method: "post",
+    parameters: {userPrefGroupTypeId: userPrefGroupTypeId, userPrefTypeId: userPrefTypeId, userPrefValue: userPrefValue},
+    onLoading: function(transport){
+    },
+
+    onSuccess: function(transport){
+    },
+
+    onComplete: function(transport){
+    }
+ });
+}
+
+function toggleLeftColumn(){
+}

Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Mon Dec  7 17:24:21 2009
@@ -930,6 +930,15 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="save-collapsed" default="true">
+            <xs:annotation><xs:documentation>When set to true, screenlet collapse status is saved as user preference. Defaults to true.</xs:documentation></xs:annotation>
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
         <xs:attribute name="padded" default="true">
             <xs:annotation><xs:documentation>When set to true, screenlet content will be padded. Defaults to true.</xs:documentation></xs:annotation>
             <xs:simpleType>

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Mon Dec  7 17:24:21 2009
@@ -662,6 +662,8 @@
         sr.append(title);
         sr.append("\" collapsible=");
         sr.append(Boolean.toString(collapsible));
+        sr.append(" saveCollapsed=");
+        sr.append(Boolean.toString(screenlet.saveCollapsed()));
         sr.append(" collapsibleAreaId=\"");
         sr.append(collapsibleAreaId);
         sr.append("\" expandToolTip=\"");

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Mon Dec  7 17:24:21 2009
@@ -333,6 +333,7 @@
         protected Form navigationForm = null;
         protected boolean collapsible = false;
         protected boolean initiallyCollapsed = false;
+        protected boolean saveCollapsed = true;
         protected boolean padded = true;
         protected List<ModelScreenWidget> subWidgets;
 
@@ -344,6 +345,9 @@
             if (this.initiallyCollapsed) {
                 this.collapsible = true;
             }
+            // By default, for a collapsible screenlet, the collapsed/expanded status must be saved
+            this.saveCollapsed = !("false".equals(screenletElement.getAttribute("save-collapsed")));
+            
             this.padded = !"false".equals(screenletElement.getAttribute("padded"));
             if (this.collapsible && UtilValidate.isEmpty(this.name) && idExdr.isEmpty()) {
                 throw new IllegalArgumentException("Collapsible screenlets must have a name or id [" + this.modelScreen.getName() + "]");
@@ -387,7 +391,7 @@
 
         @Override
         public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException {
-            boolean collapsed = initiallyCollapsed;
+            boolean collapsed = getInitiallyCollapsed(context);
             if (this.collapsible) {
                 String preferenceKey = getPreferenceKey(context) + "_collapsed";
                 Map<String, Object> requestParameters = UtilGenerics.checkMap(context.get("requestParameters"));
@@ -414,11 +418,21 @@
         public boolean collapsible() {
             return this.collapsible;
         }
-
-        public boolean initiallyCollapsed() {
+        
+        //initially-collapsed status, which may be overriden by user preference
+        public boolean getInitiallyCollapsed(Map<String, Object> context) {
+            String screenletId = this.getId(context) + "_collapsed";
+            Map<String, ? extends Object> userPreferences = UtilGenerics.checkMap(context.get("userPreferences"));
+            if (userPreferences != null && userPreferences.containsKey(screenletId)) {
+                return Boolean.valueOf((String)userPreferences.get(screenletId)).booleanValue() ;
+            }
+            
             return this.initiallyCollapsed;
         }
 
+        public boolean saveCollapsed() {
+            return this.saveCollapsed;
+        }
         public boolean padded() {
             return this.padded;
         }

Modified: ofbiz/trunk/framework/widget/templates/csvScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvScreenMacroLibrary.ftl?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/csvScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/csvScreenMacroLibrary.ftl Mon Dec  7 17:24:21 2009
@@ -48,7 +48,7 @@
 <#macro renderImage src id style wid hgt border alt urlString></#macro>
 
 <#macro renderContentFrame fullUrl width height border></#macro>
-<#macro renderScreenletBegin id title collapsible collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
+<#macro renderScreenletBegin id title collapsible saveCollapsed collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
 <#macro renderScreenletSubWidget></#macro>
 <#macro renderScreenletEnd></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/foScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foScreenMacroLibrary.ftl?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/foScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/foScreenMacroLibrary.ftl Mon Dec  7 17:24:21 2009
@@ -62,7 +62,7 @@
 <#macro renderImage></#macro>
 
 <#macro renderContentFrame></#macro>
-<#macro renderScreenletBegin id title collapsible collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
+<#macro renderScreenletBegin id title collapsible saveCollapsed collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
 <#macro renderScreenletSubWidget></#macro>
 <#macro renderScreenletEnd></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl Mon Dec  7 17:24:21 2009
@@ -129,16 +129,16 @@
 </#macro>
 
 <#macro renderContentFrame fullUrl width height border><iframe src="${fullUrl}" width="${width}" height="${height}" <#if border?has_content>border="${border}"</#if> /></#macro>
-<#macro renderScreenletBegin id title collapsible collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled>
+<#macro renderScreenletBegin id title collapsible saveCollapsed collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled>
 <div class="screenlet"<#if id?has_content> id="${id}"</#if>><#rt/>
 <#if showMore>
 <div class="screenlet-title-bar"><ul><#if title?has_content><li class="h3">${title}</li></#if>
 <#if collapsible>
 <li class="<#rt/>
 <#if collapsed>
-collapsed"><a <#if javaScriptEnabled>onclick="javascript:toggleScreenlet(this, '${collapsibleAreaId}', '${expandToolTip}', '${collapseToolTip}');"<#else>href="${fullUrlString}"</#if><#if expandToolTip?has_content> title="${expandToolTip}"</#if>
+collapsed"><a <#if javaScriptEnabled>onclick="javascript:toggleScreenlet(this, '${collapsibleAreaId}', '${saveCollapsed?string}', '${expandToolTip}', '${collapseToolTip}');"<#else>href="${fullUrlString}"</#if><#if expandToolTip?has_content> title="${expandToolTip}"</#if>
 <#else>
-expanded"><a <#if javaScriptEnabled>onclick="javascript:toggleScreenlet(this, '${collapsibleAreaId}', '${expandToolTip}', '${collapseToolTip}');"<#else>href="${fullUrlString}"</#if><#if expandToolTip?has_content> title="${expandToolTip}"</#if>
+expanded"><a <#if javaScriptEnabled>onclick="javascript:toggleScreenlet(this, '${collapsibleAreaId}', '${saveCollapsed?string}', '${expandToolTip}', '${collapseToolTip}');"<#else>href="${fullUrlString}"</#if><#if expandToolTip?has_content> title="${expandToolTip}"</#if>
 </#if>
 >&nbsp</a></li>
 </#if>

Modified: ofbiz/trunk/framework/widget/templates/textScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/textScreenMacroLibrary.ftl?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/textScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/textScreenMacroLibrary.ftl Mon Dec  7 17:24:21 2009
@@ -48,7 +48,7 @@
 <#macro renderImage src id style wid hgt border alt urlString></#macro>
 
 <#macro renderContentFrame fullUrl width height border></#macro>
-<#macro renderScreenletBegin id title collapsible collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
+<#macro renderScreenletBegin id title collapsible saveCollapsed collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled></#macro>
 <#macro renderScreenletSubWidget></#macro>
 <#macro renderScreenletEnd></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/xmlScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/xmlScreenMacroLibrary.ftl?rev=888030&r1=888029&r2=888030&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/xmlScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/xmlScreenMacroLibrary.ftl Mon Dec  7 17:24:21 2009
@@ -52,7 +52,7 @@
 </#macro>
 
 <#macro renderContentFrame fullUrl width height border></#macro>
-<#macro renderScreenletBegin id title collapsible collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled>
+<#macro renderScreenletBegin id title collapsible saveCollapsed collapsibleAreaId expandToolTip collapseToolTip fullUrlString padded menuString showMore collapsed javaScriptEnabled>
 </#macro>
 <#macro renderScreenletSubWidget></#macro>
 <#macro renderScreenletEnd></#macro>