You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by bu...@apache.org on 2009/12/07 18:24:22 UTC

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/

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>



Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
Then make sure each setting name is unique.

-Adrian

Bruno Busco wrote:
> Adrian,
> I understand how the getUserPreferenceGroup service works.
> I only see a problem when I will try to store two records that will
> have the same PK.
> 
> -Bruno
> 
> 2009/12/8 Adrian Crum <ad...@hlmksw.com>:
>> Group the screen settings by screen name. Use the user preferences services
>> to get all settings for the current screen. The service returns a Map, where
>> the key is the setting's name, and the value is the setting's value.
>>
>> -Adrian
>>
>>
>> Bruno Busco wrote:
>>> Sorry, for sure I am missing something but...
>>>
>>> if the prim-key is
>>>     <prim-key field="userLoginId"/>
>>>     <prim-key field="userPrefTypeId"/>
>>> and we want to use:
>>>
>>> userLoginId -> to specify the user the setting belongs to (i.e. admin)
>>> userPrefTypeId -> to specify the screen setting name (i.e.
>>> ProductKeywordsPanel_collapsed)
>>> userPrefGroupTypeId -> to specify the screen where the settings
>>> belongs to, how can we have two settings (i.e. keywordsearchbox)
>>>
>>> how can I have two different settings with the same name but different
>>> screen, that is what the change is all about?
>>>
>>> -Bruno
>>>
>>> 2009/12/8 Adrian Crum <ad...@hlmksw.com>:
>>>> No. The userPrefGroupTypeId field is optional, therefore it cannot be
>>>> part
>>>> of the primary key. Use the user preference services to get preference
>>>> groups.
>>>>
>>>> I believe most (if not all) widget model classes have a getName() method.
>>>>
>>>> -Adrian
>>>>
>>>> Bruno Busco wrote:
>>>>> Hi Adrian,
>>>>> I am trying to implement as you suggested but I found two difficulties:
>>>>>
>>>>> 1) the entity UserPreference has the following prim-key:
>>>>>     <prim-key field="userLoginId"/>
>>>>>     <prim-key field="userPrefTypeId"/>
>>>>>
>>>>> while it should be
>>>>>     <prim-key field="userLoginId"/>
>>>>>     <prim-key field="userPrefGroupTypeId"/>
>>>>>     <prim-key field="userPrefTypeId"/>
>>>>>
>>>>> to do what you propose. Should we change it?
>>>>>
>>>>> 2) how to retrieve the screen name from a screenlet widget rendering
>>>>> code?
>>>>> I mean I need to pass the screen name to the ftl macro in the
>>>>> MacroScreenRendered.java like this:
>>>>> ...
>>>>>       StringWriter sr = new StringWriter();
>>>>>       sr.append("<@renderScreenletBegin ");
>>>>>       sr.append("screenName=\"");
>>>>>       sr.append(screen.name);
>>>>>       sr.append("\" id=\"");
>>>>>       sr.append(screenlet.getId(context));
>>>>>       sr.append("\" title=\"");
>>>>>       sr.append(title);
>>>>>       sr.append("\" collapsible=");
>>>>>       sr.append(Boolean.toString(collapsible));
>>>>> ...
>>>>> but how to retrieve the screen.name ?
>>>>>
>>>>> Many thanks for any help.
>>>>> -Bruno
>>>>>
>>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>> Then do the same thing in the model widget code.
>>>>>>
>>>>>> -Adrian
>>>>>>
>>>>>> Bruno Busco wrote:
>>>>>>> This would mean to change all the screens! :-(
>>>>>>>
>>>>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>>>> <screen name="MyScreen">
>>>>>>>>  <section>
>>>>>>>>     <actions>
>>>>>>>>         <service service-name="getUserPreferenceGroup">
>>>>>>>>             <field-map field-name="userPrefGroupTypeId"
>>>>>>>> value="MyScreen"/>
>>>>>>>>         </service>
>>>>>>>>         <set field="screenSettings" from-field="userPrefMap"/>
>>>>>>>>     </actions>
>>>>>>>>     ...
>>>>>>>>  </section>
>>>>>>>> </screen>
>>>>>>>>
>>>>>>>>
>>>>>>>> Bruno Busco wrote:
>>>>>>>>> Adrian,
>>>>>>>>> sorry for the bad sentence, I couldn't even read myself.
>>>>>>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>>>>>>> ApplicationDecorator.
>>>>>>>>>
>>>>>>>>> So now we have two options to have screenlets with the same id saved
>>>>>>>>> indipendently:
>>>>>>>>> 1) Use a screen related userPrefGroupTypeId.
>>>>>>>>> 2) Combine the screen name for the preference key
>>>>>>>>>
>>>>>>>>> I will work on it...
>>>>>>>>>
>>>>>>>>> Thank you,
>>>>>>>>> -Bruno
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>>>>>> Bruno Busco wrote:
>>>>>>>>>>> Thank you Adrian,
>>>>>>>>>>> but then how to the theme loaded easily? The global ones are
>>>>>>>>>>> already
>>>>>>>>>>> loaded along the selected theme etc.
>>>>>>>>>>>
>>>>>>>>>>> -Bruno
>>>>>>>>>>>
>>>>>>>>>> Or you can combine the screen name and sceenlet id for the
>>>>>>>>>> preference
>>>>>>>>>> key,
>>>>>>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>>>>>>
>>>>>>>>>> Bilgin
>>>>>>>>>>
>>>>>>>>>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Adrian,
I understand how the getUserPreferenceGroup service works.
I only see a problem when I will try to store two records that will
have the same PK.

-Bruno

2009/12/8 Adrian Crum <ad...@hlmksw.com>:
> Group the screen settings by screen name. Use the user preferences services
> to get all settings for the current screen. The service returns a Map, where
> the key is the setting's name, and the value is the setting's value.
>
> -Adrian
>
>
> Bruno Busco wrote:
>>
>> Sorry, for sure I am missing something but...
>>
>> if the prim-key is
>>     <prim-key field="userLoginId"/>
>>     <prim-key field="userPrefTypeId"/>
>> and we want to use:
>>
>> userLoginId -> to specify the user the setting belongs to (i.e. admin)
>> userPrefTypeId -> to specify the screen setting name (i.e.
>> ProductKeywordsPanel_collapsed)
>> userPrefGroupTypeId -> to specify the screen where the settings
>> belongs to, how can we have two settings (i.e. keywordsearchbox)
>>
>> how can I have two different settings with the same name but different
>> screen, that is what the change is all about?
>>
>> -Bruno
>>
>> 2009/12/8 Adrian Crum <ad...@hlmksw.com>:
>>>
>>> No. The userPrefGroupTypeId field is optional, therefore it cannot be
>>> part
>>> of the primary key. Use the user preference services to get preference
>>> groups.
>>>
>>> I believe most (if not all) widget model classes have a getName() method.
>>>
>>> -Adrian
>>>
>>> Bruno Busco wrote:
>>>>
>>>> Hi Adrian,
>>>> I am trying to implement as you suggested but I found two difficulties:
>>>>
>>>> 1) the entity UserPreference has the following prim-key:
>>>>     <prim-key field="userLoginId"/>
>>>>     <prim-key field="userPrefTypeId"/>
>>>>
>>>> while it should be
>>>>     <prim-key field="userLoginId"/>
>>>>     <prim-key field="userPrefGroupTypeId"/>
>>>>     <prim-key field="userPrefTypeId"/>
>>>>
>>>> to do what you propose. Should we change it?
>>>>
>>>> 2) how to retrieve the screen name from a screenlet widget rendering
>>>> code?
>>>> I mean I need to pass the screen name to the ftl macro in the
>>>> MacroScreenRendered.java like this:
>>>> ...
>>>>       StringWriter sr = new StringWriter();
>>>>       sr.append("<@renderScreenletBegin ");
>>>>       sr.append("screenName=\"");
>>>>       sr.append(screen.name);
>>>>       sr.append("\" id=\"");
>>>>       sr.append(screenlet.getId(context));
>>>>       sr.append("\" title=\"");
>>>>       sr.append(title);
>>>>       sr.append("\" collapsible=");
>>>>       sr.append(Boolean.toString(collapsible));
>>>> ...
>>>> but how to retrieve the screen.name ?
>>>>
>>>> Many thanks for any help.
>>>> -Bruno
>>>>
>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>
>>>>> Then do the same thing in the model widget code.
>>>>>
>>>>> -Adrian
>>>>>
>>>>> Bruno Busco wrote:
>>>>>>
>>>>>> This would mean to change all the screens! :-(
>>>>>>
>>>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>>>
>>>>>>> <screen name="MyScreen">
>>>>>>>  <section>
>>>>>>>     <actions>
>>>>>>>         <service service-name="getUserPreferenceGroup">
>>>>>>>             <field-map field-name="userPrefGroupTypeId"
>>>>>>> value="MyScreen"/>
>>>>>>>         </service>
>>>>>>>         <set field="screenSettings" from-field="userPrefMap"/>
>>>>>>>     </actions>
>>>>>>>     ...
>>>>>>>  </section>
>>>>>>> </screen>
>>>>>>>
>>>>>>>
>>>>>>> Bruno Busco wrote:
>>>>>>>>
>>>>>>>> Adrian,
>>>>>>>> sorry for the bad sentence, I couldn't even read myself.
>>>>>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>>>>>> ApplicationDecorator.
>>>>>>>>
>>>>>>>> So now we have two options to have screenlets with the same id saved
>>>>>>>> indipendently:
>>>>>>>> 1) Use a screen related userPrefGroupTypeId.
>>>>>>>> 2) Combine the screen name for the preference key
>>>>>>>>
>>>>>>>> I will work on it...
>>>>>>>>
>>>>>>>> Thank you,
>>>>>>>> -Bruno
>>>>>>>>
>>>>>>>>
>>>>>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>>>>>
>>>>>>>>> Bruno Busco wrote:
>>>>>>>>>>
>>>>>>>>>> Thank you Adrian,
>>>>>>>>>> but then how to the theme loaded easily? The global ones are
>>>>>>>>>> already
>>>>>>>>>> loaded along the selected theme etc.
>>>>>>>>>>
>>>>>>>>>> -Bruno
>>>>>>>>>>
>>>>>>>>> Or you can combine the screen name and sceenlet id for the
>>>>>>>>> preference
>>>>>>>>> key,
>>>>>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>>>>>
>>>>>>>>> Bilgin
>>>>>>>>>
>>>>>>>>>
>>
>

Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
Group the screen settings by screen name. Use the user preferences 
services to get all settings for the current screen. The service returns 
a Map, where the key is the setting's name, and the value is the 
setting's value.

-Adrian


Bruno Busco wrote:
> Sorry, for sure I am missing something but...
> 
> if the prim-key is
>      <prim-key field="userLoginId"/>
>      <prim-key field="userPrefTypeId"/>
> and we want to use:
> 
> userLoginId -> to specify the user the setting belongs to (i.e. admin)
> userPrefTypeId -> to specify the screen setting name (i.e.
> ProductKeywordsPanel_collapsed)
> userPrefGroupTypeId -> to specify the screen where the settings
> belongs to, how can we have two settings (i.e. keywordsearchbox)
> 
> how can I have two different settings with the same name but different
> screen, that is what the change is all about?
> 
> -Bruno
> 
> 2009/12/8 Adrian Crum <ad...@hlmksw.com>:
>> No. The userPrefGroupTypeId field is optional, therefore it cannot be part
>> of the primary key. Use the user preference services to get preference
>> groups.
>>
>> I believe most (if not all) widget model classes have a getName() method.
>>
>> -Adrian
>>
>> Bruno Busco wrote:
>>> Hi Adrian,
>>> I am trying to implement as you suggested but I found two difficulties:
>>>
>>> 1) the entity UserPreference has the following prim-key:
>>>      <prim-key field="userLoginId"/>
>>>      <prim-key field="userPrefTypeId"/>
>>>
>>> while it should be
>>>      <prim-key field="userLoginId"/>
>>>      <prim-key field="userPrefGroupTypeId"/>
>>>      <prim-key field="userPrefTypeId"/>
>>>
>>> to do what you propose. Should we change it?
>>>
>>> 2) how to retrieve the screen name from a screenlet widget rendering code?
>>> I mean I need to pass the screen name to the ftl macro in the
>>> MacroScreenRendered.java like this:
>>> ...
>>>        StringWriter sr = new StringWriter();
>>>        sr.append("<@renderScreenletBegin ");
>>>        sr.append("screenName=\"");
>>>        sr.append(screen.name);
>>>        sr.append("\" id=\"");
>>>        sr.append(screenlet.getId(context));
>>>        sr.append("\" title=\"");
>>>        sr.append(title);
>>>        sr.append("\" collapsible=");
>>>        sr.append(Boolean.toString(collapsible));
>>> ...
>>> but how to retrieve the screen.name ?
>>>
>>> Many thanks for any help.
>>> -Bruno
>>>
>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>> Then do the same thing in the model widget code.
>>>>
>>>> -Adrian
>>>>
>>>> Bruno Busco wrote:
>>>>> This would mean to change all the screens! :-(
>>>>>
>>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>> <screen name="MyScreen">
>>>>>>  <section>
>>>>>>      <actions>
>>>>>>          <service service-name="getUserPreferenceGroup">
>>>>>>              <field-map field-name="userPrefGroupTypeId"
>>>>>> value="MyScreen"/>
>>>>>>          </service>
>>>>>>          <set field="screenSettings" from-field="userPrefMap"/>
>>>>>>      </actions>
>>>>>>      ...
>>>>>>  </section>
>>>>>> </screen>
>>>>>>
>>>>>>
>>>>>> Bruno Busco wrote:
>>>>>>> Adrian,
>>>>>>> sorry for the bad sentence, I couldn't even read myself.
>>>>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>>>>> ApplicationDecorator.
>>>>>>>
>>>>>>> So now we have two options to have screenlets with the same id saved
>>>>>>> indipendently:
>>>>>>> 1) Use a screen related userPrefGroupTypeId.
>>>>>>> 2) Combine the screen name for the preference key
>>>>>>>
>>>>>>> I will work on it...
>>>>>>>
>>>>>>> Thank you,
>>>>>>> -Bruno
>>>>>>>
>>>>>>>
>>>>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>>>> Bruno Busco wrote:
>>>>>>>>> Thank you Adrian,
>>>>>>>>> but then how to the theme loaded easily? The global ones are already
>>>>>>>>> loaded along the selected theme etc.
>>>>>>>>>
>>>>>>>>> -Bruno
>>>>>>>>>
>>>>>>>> Or you can combine the screen name and sceenlet id for the preference
>>>>>>>> key,
>>>>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>>>>
>>>>>>>> Bilgin
>>>>>>>>
>>>>>>>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Sorry, for sure I am missing something but...

if the prim-key is
     <prim-key field="userLoginId"/>
     <prim-key field="userPrefTypeId"/>
and we want to use:

userLoginId -> to specify the user the setting belongs to (i.e. admin)
userPrefTypeId -> to specify the screen setting name (i.e.
ProductKeywordsPanel_collapsed)
userPrefGroupTypeId -> to specify the screen where the settings
belongs to, how can we have two settings (i.e. keywordsearchbox)

how can I have two different settings with the same name but different
screen, that is what the change is all about?

-Bruno

2009/12/8 Adrian Crum <ad...@hlmksw.com>:
> No. The userPrefGroupTypeId field is optional, therefore it cannot be part
> of the primary key. Use the user preference services to get preference
> groups.
>
> I believe most (if not all) widget model classes have a getName() method.
>
> -Adrian
>
> Bruno Busco wrote:
>>
>> Hi Adrian,
>> I am trying to implement as you suggested but I found two difficulties:
>>
>> 1) the entity UserPreference has the following prim-key:
>>      <prim-key field="userLoginId"/>
>>      <prim-key field="userPrefTypeId"/>
>>
>> while it should be
>>      <prim-key field="userLoginId"/>
>>      <prim-key field="userPrefGroupTypeId"/>
>>      <prim-key field="userPrefTypeId"/>
>>
>> to do what you propose. Should we change it?
>>
>> 2) how to retrieve the screen name from a screenlet widget rendering code?
>> I mean I need to pass the screen name to the ftl macro in the
>> MacroScreenRendered.java like this:
>> ...
>>        StringWriter sr = new StringWriter();
>>        sr.append("<@renderScreenletBegin ");
>>        sr.append("screenName=\"");
>>        sr.append(screen.name);
>>        sr.append("\" id=\"");
>>        sr.append(screenlet.getId(context));
>>        sr.append("\" title=\"");
>>        sr.append(title);
>>        sr.append("\" collapsible=");
>>        sr.append(Boolean.toString(collapsible));
>> ...
>> but how to retrieve the screen.name ?
>>
>> Many thanks for any help.
>> -Bruno
>>
>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>
>>> Then do the same thing in the model widget code.
>>>
>>> -Adrian
>>>
>>> Bruno Busco wrote:
>>>>
>>>> This would mean to change all the screens! :-(
>>>>
>>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>>>
>>>>> <screen name="MyScreen">
>>>>>  <section>
>>>>>      <actions>
>>>>>          <service service-name="getUserPreferenceGroup">
>>>>>              <field-map field-name="userPrefGroupTypeId"
>>>>> value="MyScreen"/>
>>>>>          </service>
>>>>>          <set field="screenSettings" from-field="userPrefMap"/>
>>>>>      </actions>
>>>>>      ...
>>>>>  </section>
>>>>> </screen>
>>>>>
>>>>>
>>>>> Bruno Busco wrote:
>>>>>>
>>>>>> Adrian,
>>>>>> sorry for the bad sentence, I couldn't even read myself.
>>>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>>>> ApplicationDecorator.
>>>>>>
>>>>>> So now we have two options to have screenlets with the same id saved
>>>>>> indipendently:
>>>>>> 1) Use a screen related userPrefGroupTypeId.
>>>>>> 2) Combine the screen name for the preference key
>>>>>>
>>>>>> I will work on it...
>>>>>>
>>>>>> Thank you,
>>>>>> -Bruno
>>>>>>
>>>>>>
>>>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>>>
>>>>>>> Bruno Busco wrote:
>>>>>>>>
>>>>>>>> Thank you Adrian,
>>>>>>>> but then how to the theme loaded easily? The global ones are already
>>>>>>>> loaded along the selected theme etc.
>>>>>>>>
>>>>>>>> -Bruno
>>>>>>>>
>>>>>>> Or you can combine the screen name and sceenlet id for the preference
>>>>>>> key,
>>>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>>>
>>>>>>> Bilgin
>>>>>>>
>>>>>>>
>>
>

Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
No. The userPrefGroupTypeId field is optional, therefore it cannot be 
part of the primary key. Use the user preference services to get 
preference groups.

I believe most (if not all) widget model classes have a getName() method.

-Adrian

Bruno Busco wrote:
> Hi Adrian,
> I am trying to implement as you suggested but I found two difficulties:
> 
> 1) the entity UserPreference has the following prim-key:
>       <prim-key field="userLoginId"/>
>       <prim-key field="userPrefTypeId"/>
> 
> while it should be
>       <prim-key field="userLoginId"/>
>       <prim-key field="userPrefGroupTypeId"/>
>       <prim-key field="userPrefTypeId"/>
> 
> to do what you propose. Should we change it?
> 
> 2) how to retrieve the screen name from a screenlet widget rendering code?
> I mean I need to pass the screen name to the ftl macro in the
> MacroScreenRendered.java like this:
> ...
>         StringWriter sr = new StringWriter();
>         sr.append("<@renderScreenletBegin ");
>         sr.append("screenName=\"");
>         sr.append(screen.name);
>         sr.append("\" id=\"");
>         sr.append(screenlet.getId(context));
>         sr.append("\" title=\"");
>         sr.append(title);
>         sr.append("\" collapsible=");
>         sr.append(Boolean.toString(collapsible));
> ...
> but how to retrieve the screen.name ?
> 
> Many thanks for any help.
> -Bruno
> 
> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>> Then do the same thing in the model widget code.
>>
>> -Adrian
>>
>> Bruno Busco wrote:
>>> This would mean to change all the screens! :-(
>>>
>>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>> <screen name="MyScreen">
>>>>   <section>
>>>>       <actions>
>>>>           <service service-name="getUserPreferenceGroup">
>>>>               <field-map field-name="userPrefGroupTypeId"
>>>> value="MyScreen"/>
>>>>           </service>
>>>>           <set field="screenSettings" from-field="userPrefMap"/>
>>>>       </actions>
>>>>       ...
>>>>   </section>
>>>> </screen>
>>>>
>>>>
>>>> Bruno Busco wrote:
>>>>> Adrian,
>>>>> sorry for the bad sentence, I couldn't even read myself.
>>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>>> ApplicationDecorator.
>>>>>
>>>>> So now we have two options to have screenlets with the same id saved
>>>>> indipendently:
>>>>> 1) Use a screen related userPrefGroupTypeId.
>>>>> 2) Combine the screen name for the preference key
>>>>>
>>>>> I will work on it...
>>>>>
>>>>> Thank you,
>>>>> -Bruno
>>>>>
>>>>>
>>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>> Bruno Busco wrote:
>>>>>>> Thank you Adrian,
>>>>>>> but then how to the theme loaded easily? The global ones are already
>>>>>>> loaded along the selected theme etc.
>>>>>>>
>>>>>>> -Bruno
>>>>>>>
>>>>>> Or you can combine the screen name and sceenlet id for the preference
>>>>>> key,
>>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>>
>>>>>> Bilgin
>>>>>>
>>>>>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Hi Adrian,
I am trying to implement as you suggested but I found two difficulties:

1) the entity UserPreference has the following prim-key:
      <prim-key field="userLoginId"/>
      <prim-key field="userPrefTypeId"/>

while it should be
      <prim-key field="userLoginId"/>
      <prim-key field="userPrefGroupTypeId"/>
      <prim-key field="userPrefTypeId"/>

to do what you propose. Should we change it?

2) how to retrieve the screen name from a screenlet widget rendering code?
I mean I need to pass the screen name to the ftl macro in the
MacroScreenRendered.java like this:
...
        StringWriter sr = new StringWriter();
        sr.append("<@renderScreenletBegin ");
        sr.append("screenName=\"");
        sr.append(screen.name);
        sr.append("\" id=\"");
        sr.append(screenlet.getId(context));
        sr.append("\" title=\"");
        sr.append(title);
        sr.append("\" collapsible=");
        sr.append(Boolean.toString(collapsible));
...
but how to retrieve the screen.name ?

Many thanks for any help.
-Bruno

2009/12/7 Adrian Crum <ad...@hlmksw.com>:
> Then do the same thing in the model widget code.
>
> -Adrian
>
> Bruno Busco wrote:
>>
>> This would mean to change all the screens! :-(
>>
>> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>>>
>>> <screen name="MyScreen">
>>>   <section>
>>>       <actions>
>>>           <service service-name="getUserPreferenceGroup">
>>>               <field-map field-name="userPrefGroupTypeId"
>>> value="MyScreen"/>
>>>           </service>
>>>           <set field="screenSettings" from-field="userPrefMap"/>
>>>       </actions>
>>>       ...
>>>   </section>
>>> </screen>
>>>
>>>
>>> Bruno Busco wrote:
>>>>
>>>> Adrian,
>>>> sorry for the bad sentence, I couldn't even read myself.
>>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>>> ApplicationDecorator.
>>>>
>>>> So now we have two options to have screenlets with the same id saved
>>>> indipendently:
>>>> 1) Use a screen related userPrefGroupTypeId.
>>>> 2) Combine the screen name for the preference key
>>>>
>>>> I will work on it...
>>>>
>>>> Thank you,
>>>> -Bruno
>>>>
>>>>
>>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>>
>>>>> Bruno Busco wrote:
>>>>>>
>>>>>> Thank you Adrian,
>>>>>> but then how to the theme loaded easily? The global ones are already
>>>>>> loaded along the selected theme etc.
>>>>>>
>>>>>> -Bruno
>>>>>>
>>>>> Or you can combine the screen name and sceenlet id for the preference
>>>>> key,
>>>>> instead of  (screenlet.id+"_collapsed" )
>>>>>
>>>>> Bilgin
>>>>>
>>>>>
>>
>

Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
Then do the same thing in the model widget code.

-Adrian

Bruno Busco wrote:
> This would mean to change all the screens! :-(
> 
> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>> <screen name="MyScreen">
>>    <section>
>>        <actions>
>>            <service service-name="getUserPreferenceGroup">
>>                <field-map field-name="userPrefGroupTypeId"
>> value="MyScreen"/>
>>            </service>
>>            <set field="screenSettings" from-field="userPrefMap"/>
>>        </actions>
>>        ...
>>    </section>
>> </screen>
>>
>>
>> Bruno Busco wrote:
>>> Adrian,
>>> sorry for the bad sentence, I couldn't even read myself.
>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>> ApplicationDecorator.
>>>
>>> So now we have two options to have screenlets with the same id saved
>>> indipendently:
>>> 1) Use a screen related userPrefGroupTypeId.
>>> 2) Combine the screen name for the preference key
>>>
>>> I will work on it...
>>>
>>> Thank you,
>>> -Bruno
>>>
>>>
>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>> Bruno Busco wrote:
>>>>> Thank you Adrian,
>>>>> but then how to the theme loaded easily? The global ones are already
>>>>> loaded along the selected theme etc.
>>>>>
>>>>> -Bruno
>>>>>
>>>> Or you can combine the screen name and sceenlet id for the preference
>>>> key,
>>>> instead of  (screenlet.id+"_collapsed" )
>>>>
>>>> Bilgin
>>>>
>>>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Could we move this somehow in the screen widget?

2009/12/7 Bruno Busco <br...@gmail.com>:
> This would mean to change all the screens! :-(
>
> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>> <screen name="MyScreen">
>>    <section>
>>        <actions>
>>            <service service-name="getUserPreferenceGroup">
>>                <field-map field-name="userPrefGroupTypeId"
>> value="MyScreen"/>
>>            </service>
>>            <set field="screenSettings" from-field="userPrefMap"/>
>>        </actions>
>>        ...
>>    </section>
>> </screen>
>>
>>
>> Bruno Busco wrote:
>>>
>>> Adrian,
>>> sorry for the bad sentence, I couldn't even read myself.
>>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>>> ApplicationDecorator.
>>>
>>> So now we have two options to have screenlets with the same id saved
>>> indipendently:
>>> 1) Use a screen related userPrefGroupTypeId.
>>> 2) Combine the screen name for the preference key
>>>
>>> I will work on it...
>>>
>>> Thank you,
>>> -Bruno
>>>
>>>
>>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>>
>>>> Bruno Busco wrote:
>>>>>
>>>>> Thank you Adrian,
>>>>> but then how to the theme loaded easily? The global ones are already
>>>>> loaded along the selected theme etc.
>>>>>
>>>>> -Bruno
>>>>>
>>>> Or you can combine the screen name and sceenlet id for the preference
>>>> key,
>>>> instead of  (screenlet.id+"_collapsed" )
>>>>
>>>> Bilgin
>>>>
>>>>
>>>
>>
>

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
This would mean to change all the screens! :-(

2009/12/7 Adrian Crum <ad...@hlmksw.com>:
> <screen name="MyScreen">
>    <section>
>        <actions>
>            <service service-name="getUserPreferenceGroup">
>                <field-map field-name="userPrefGroupTypeId"
> value="MyScreen"/>
>            </service>
>            <set field="screenSettings" from-field="userPrefMap"/>
>        </actions>
>        ...
>    </section>
> </screen>
>
>
> Bruno Busco wrote:
>>
>> Adrian,
>> sorry for the bad sentence, I couldn't even read myself.
>> I meant that GLOBAL_PREFERENCES gets already loaded in the
>> ApplicationDecorator.
>>
>> So now we have two options to have screenlets with the same id saved
>> indipendently:
>> 1) Use a screen related userPrefGroupTypeId.
>> 2) Combine the screen name for the preference key
>>
>> I will work on it...
>>
>> Thank you,
>> -Bruno
>>
>>
>> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>>>
>>> Bruno Busco wrote:
>>>>
>>>> Thank you Adrian,
>>>> but then how to the theme loaded easily? The global ones are already
>>>> loaded along the selected theme etc.
>>>>
>>>> -Bruno
>>>>
>>> Or you can combine the screen name and sceenlet id for the preference
>>> key,
>>> instead of  (screenlet.id+"_collapsed" )
>>>
>>> Bilgin
>>>
>>>
>>
>

Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
<screen name="MyScreen">
     <section>
         <actions>
             <service service-name="getUserPreferenceGroup">
                 <field-map field-name="userPrefGroupTypeId" 
value="MyScreen"/>
             </service>
             <set field="screenSettings" from-field="userPrefMap"/>
         </actions>
         ...
     </section>
</screen>


Bruno Busco wrote:
> Adrian,
> sorry for the bad sentence, I couldn't even read myself.
> I meant that GLOBAL_PREFERENCES gets already loaded in the ApplicationDecorator.
> 
> So now we have two options to have screenlets with the same id saved
> indipendently:
> 1) Use a screen related userPrefGroupTypeId.
> 2) Combine the screen name for the preference key
> 
> I will work on it...
> 
> Thank you,
> -Bruno
> 
> 
> 2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
>> Bruno Busco wrote:
>>> Thank you Adrian,
>>> but then how to the theme loaded easily? The global ones are already
>>> loaded along the selected theme etc.
>>>
>>> -Bruno
>>>
>> Or you can combine the screen name and sceenlet id for the preference key,
>> instead of  (screenlet.id+"_collapsed" )
>>
>> Bilgin
>>
>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Adrian,
sorry for the bad sentence, I couldn't even read myself.
I meant that GLOBAL_PREFERENCES gets already loaded in the ApplicationDecorator.

So now we have two options to have screenlets with the same id saved
indipendently:
1) Use a screen related userPrefGroupTypeId.
2) Combine the screen name for the preference key

I will work on it...

Thank you,
-Bruno


2009/12/7 Bilgin Ibryam <bi...@gmail.com>:
> Bruno Busco wrote:
>>
>> Thank you Adrian,
>> but then how to the theme loaded easily? The global ones are already
>> loaded along the selected theme etc.
>>
>> -Bruno
>>
>
> Or you can combine the screen name and sceenlet id for the preference key,
> instead of  (screenlet.id+"_collapsed" )
>
> Bilgin
>
>

Re: 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/

Posted by Bilgin Ibryam <bi...@gmail.com>.
Bruno Busco wrote:
> Thank you Adrian,
> but then how to the theme loaded easily? The global ones are already
> loaded along the selected theme etc.
>
> -Bruno
>  

Or you can combine the screen name and sceenlet id for the preference 
key, instead of  (screenlet.id+"_collapsed" )

Bilgin


Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
Expanded/collapsed has nothing to do with themes.

-Adrian

Bruno Busco wrote:
> Thank you Adrian,
> but then how to the theme loaded easily? The global ones are already
> loaded along the selected theme etc.
> 
> -Bruno
> 
> 2009/12/7 Adrian Crum <ad...@hlmksw.com>:
>> Bruno,
>>
>> Don't forget the UserPreference entity also has a userPrefGroupTypeId field,
>> so you could group the collapsed settings by screen. That would solve the
>> shared id problem.
>>
>> -Adrian
>>
>> buscob@apache.org wrote:
>>> 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>
>>>
>>>
>>>
> 

Re: 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/

Posted by Bruno Busco <br...@gmail.com>.
Thank you Adrian,
but then how to the theme loaded easily? The global ones are already
loaded along the selected theme etc.

-Bruno

2009/12/7 Adrian Crum <ad...@hlmksw.com>:
> Bruno,
>
> Don't forget the UserPreference entity also has a userPrefGroupTypeId field,
> so you could group the collapsed settings by screen. That would solve the
> shared id problem.
>
> -Adrian
>
> buscob@apache.org wrote:
>>
>> 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>
>>
>>
>>
>

Re: 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/

Posted by Adrian Crum <ad...@hlmksw.com>.
Bruno,

Don't forget the UserPreference entity also has a userPrefGroupTypeId 
field, so you could group the collapsed settings by screen. That would 
solve the shared id problem.

-Adrian

buscob@apache.org wrote:
> 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>
> 
> 
>