Ahh.  That makes sense.  I think there might be a way to simplify the
server side delete operation so that this wouldn't happen.  Specifically,
removing the need to pass the regionId and just use the regionWidgetId to
delete the widget.

-Matt

On 6/6/11 1:52 PM, "Marlon Pierce" <[email protected]> wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Trying to delete a gadget that you have moved on the page throws this
>error:Rave attempted to update the server with your recent changes,  but
>the changes were rejected by the server as invalid.
>
>On 6/6/11 1:46 PM, Franklin, Matthew B. wrote:
>> 
>> On 6/6/11 1:43 PM, "Marlon Pierce" <[email protected]> wrote:
>> 
>> I cleaned it up a bit already, but let me look at the init.  There is
>> still a bug associated with deleting gadgets that have been moved.
>> 
>>> Moved or deleted? Can you elaborate on the bug a bit?
>> 
>> 
>> 
>> 
>> Marlon
>> 
>> 
>> On 6/6/11 1:36 PM, Franklin, Matthew B. wrote:
>>>>> On 6/6/11 1:10 PM, "[email protected]" <[email protected]> wrote:
>>>>>
>>>>>> Author: mpierce
>>>>>> Date: Mon Jun  6 17:10:32 2011
>>>>>> New Revision: 1132706
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=1132706&view=rev
>>>>>> Log:
>>>>>> Reorganizing the widget deletion code (RAVE-41) so that most of the
>>>>>> action takes place in rave.js rather than home.jsp.  Probably this
>>>>>> needs
>>>>>> a better design pattern applied to it.
>>>>>
>>>>> Thanks for taking that on.  I haven't had a ton of time to look over
>>>>>the
>>>>> delete code yet, but from what I have seen, it looks like there
>>>>>should
>>>>> be
>>>>> no reason that we can't do what is left in the home.jsp in the
>>>>>ui.init
>>>>> function of rave.js (init the buttons for all widgets with one
>>>>> expression).  This would allow us to move the script includes for
>>>>> jquery,
>>>>> etc back to the bottom of the page, which is where we really want
>>>>>them.
>>>>>
>>>>> I can go ahead and make this change unless Marlon or others who have
>>>>> been
>>>>> working on it want to give it a go.
>>>>>
>>>>> -Matt
>>>>>
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>>>    
>>>>>> 
>>>>>>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.j
>>>>>>sp
>>>>>>    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
>>>>>>
>>>>>> Modified: 
>>>>>> 
>>>>>>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.j
>>>>>>sp
>>>>>> URL: 
>>>>>>
>>>>>> 
>>>>>>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/mai
>>>>>>n/w
>>>>>> eb
>>>>>> 
>>>>>>app/WEB-INF/views/home.jsp?rev=1132706&r1=1132705&r2=1132706&view=dif
>>>>>>f
>>>>>>
>>>>>> 
>>>>>>=====================================================================
>>>>>>===
>>>>>> ==
>>>>>> ====
>>>>>> --- 
>>>>>> 
>>>>>>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.j
>>>>>>sp
>>>>>> (original)
>>>>>> +++ 
>>>>>> 
>>>>>>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.j
>>>>>>sp
>>>>>> Mon Jun  6 17:10:32 2011
>>>>>> @@ -64,41 +64,35 @@
>>>>>>         <div class="widget-title-bar" >
>>>>>>             <span
>>>>>>
>>>>>> 
>>>>>>id="widget-${regionWidget.id}-title">${regionWidget.widget.title}</sp
>>>>>>an>
>>>>>>             
>>>>>> -            <span id="widget-${regionWidget.id}-toolbar"
>>>>>> style="float:right;">
>>>>>> -              <button id="widget-${regionWidget.id}-max"
>>>>>> class="widget-toolbar-btn"></button>
>>>>>> -                                                  <button 
>>>>>> id="widget-${regionWidget.id}-remove"
>>>>>> class="widget-toolbar-btn"></button>
>>>>>> -                                                  <script>
>>>>>> -              $("#widget-${regionWidget.id}-max").button({
>>>>>> -                text: false,
>>>>>> -                icons: {
>>>>>> -                  primary: "ui-icon-arrow-4-diag"
>>>>>> -                }
>>>>>> -              }).click(function() {
>>>>>> -                alert("not implemented yet.");
>>>>>> -              });
>>>>>> -                                                  
>>>>>> $("#widget-${regionWidget.id}-remove").button({
>>>>>> -                                              text: false,
>>>>>> -                                              icons: {
>>>>>> -                                                primary: "ui-icon-close"
>>>>>> -                                              }
>>>>>> -                                            
>>>>>> }).unbind("click").click(function() {
>>>>>> -                                                alert("remove gadget");
>>>>>> -                                              
>>>>>> rave.api.rpc.removeWidget({
>>>>>> -                                                  regionWidgetId: 
>>>>>> "${regionWidget.id}",
>>>>>> -                                                  pageId: 
>>>>>> "${defaultPage.id}",
>>>>>> -                                                  region: {
>>>>>> -                                                      id : 
>>>>>> rave.getGadgetRegion("${regionWidget.id}")
>>>>>> -                                                  },
>>>>>> -                                                  succCB: function() {
>>>>>> -                                                          
>>>>>> $("#widget-wrapper-${regionWidget.id}").remove();
>>>>>> -                                                  }
>>>>>> -                                                });
>>>>>> -                                            });
>>>>>> -                                                  
>>>>>> rave.mapGadgetToRegion("${regionWidget.id}",
>>>>>>"${region.id}");
>>>>>> -                                                  </script>
>>>>>> -                                                </span>
>>>>>> -           
>>>>>> -        </div>
>>>>>> +                                <!-- These are toolbar buttons -->
>>>>>> +                                <span 
>>>>>> id="widget-${regionWidget.id}-toolbar"
>>>>>>style="float:right;">
>>>>>> +                                  <button 
>>>>>> id="widget-${regionWidget.id}-max"
>>>>>> +                                                         
>>>>>> class="widget-toolbar-btn"
>>>>>> +                                                         
>>>>>> onclick="rave.toolbarMaximize(this)"></button>
>>>>>> +                                  <button 
>>>>>> id="widget-${regionWidget.id}-remove"
>>>>>> +                                                         
>>>>>> class="widget-toolbar-btn"
>>>>>> +                                                         
>>>>>>
>>>>>> 
>>>>>>onclick="rave.toolbarDelete(this,${regionWidget.id},${region.id},${de
>>>>>>fau
>>>>>> lt
>>>>>> Page.id})">
>>>>>> +                                  </button>
>>>>>> +                                  <script>
>>>>>> +                                         //This decorates the toolbar 
>>>>>> buttons.  As currently written,
>>>>>> +                                         //it needs to be in the 
>>>>>> forEach loop.
>>>>>> +                                         
>>>>>> $("#widget-${regionWidget.id}-max").button({
>>>>>> +                                         text: false,
>>>>>> +                                         icons: {
>>>>>> +                                         primary: "ui-icon-arrow-4-diag"
>>>>>> +                                         }
>>>>>> +                                         });
>>>>>> +
>>>>>> +                                         
>>>>>> $("#widget-${regionWidget.id}-remove").button({
>>>>>> +                                         text: false,
>>>>>> +                                         icons: {
>>>>>> +                                         primary: "ui-icon-close"
>>>>>> +                                         }
>>>>>> +                                         });
>>>>>> +                                  </script>
>>>>>> +
>>>>>> +                                </span>
>>>>>> +                  </div>
>>>>>>         <div class="widget" id="widget-${regionWidget.id}-body">
>>>>>>                   <!-- 
>>>>>>                                  Among other things, the render-widget 
>>>>>> tag will populate the
>>>>>> widgets[] array.
>>>>>>
>>>>>> Modified: 
>>>>>> incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
>>>>>> URL: 
>>>>>>
>>>>>> 
>>>>>>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/mai
>>>>>>n/w
>>>>>> eb
>>>>>> app/script/rave.js?rev=1132706&r1=1132705&r2=1132706&view=diff
>>>>>>
>>>>>> 
>>>>>>=====================================================================
>>>>>>===
>>>>>> ==
>>>>>> ====
>>>>>> --- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
>>>>>> (original)
>>>>>> +++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
>>>>>>Mon
>>>>>> Jun  6 17:10:32 2011
>>>>>> @@ -105,6 +105,36 @@ var rave = rave || (function() {
>>>>>>
>>>>>>     })();
>>>>>>
>>>>>> +         /**
>>>>>> +          * Group widget toolbar functions
>>>>>> +          */
>>>>>> +         var toolbar = (function() {
>>>>>> +                  function init(){
>>>>>> +                  }
>>>>>> +                  function maximizeAction(button){
>>>>>> +                                alert("Maximize: "+button.id+" not yet 
>>>>>> implemented.");
>>>>>> +                                
>>>>>> +                  };
>>>>>> +                  function
>>>>>> deleteAction(button,myRegionWidgetId,myRegionId,myPageId){
>>>>>> +//                              alert("Delete:"+button.id+" 
>>>>>> "+myRegionWidgetId+"
>>>>>>"+myRegionId+"
>>>>>> "+myPageId);
>>>>>> +                                rave.api.rpc.removeWidget({
>>>>>> +                                         regionWidgetId: 
>>>>>> myRegionWidgetId,
>>>>>> +                                         pageId : myPageId,
>>>>>> +                                         region: {
>>>>>> +                                                  id : myRegionId
>>>>>> +                                         },
>>>>>> +                                         succCB: function() {
>>>>>> +                                                  
>>>>>> $("#widget-wrapper-"+myRegionWidgetId).remove();
>>>>>> +                                         }
>>>>>> +                                });
>>>>>> +                                
>>>>>> rave.mapGadgetToRegion(myRegionWidgetId, myRegionId);
>>>>>> +                  };
>>>>>> +                  return {
>>>>>> +                                maximizeAction : maximizeAction,
>>>>>> +                                deleteAction : deleteAction
>>>>>> +                  }
>>>>>> +         })();
>>>>>> +
>>>>>>     function initializeProviders() {
>>>>>>            //Current providers are rave.wookie and rave.opensocial.
>>>>>>            //Providers register themselves when loaded, so
>>>>>> @@ -161,14 +191,6 @@ var rave = rave || (function() {
>>>>>>     }
>>>>>>   
>>>>>>   /**
>>>>>> -          * Deletes the gadget/widget from the display.
>>>>>> -     * TODO: must be implemented.
>>>>>> -          */
>>>>>> -         function deleteWidgetFromPage() {
>>>>>> -                  return null;
>>>>>> -         }
>>>>>> -         
>>>>>> -         /**
>>>>>>    * Map a widget to the region where it is located.
>>>>>>    * 
>>>>>>    * @param widgetId: id of the widget (not DOM id)
>>>>>> @@ -248,10 +270,6 @@ var rave = rave || (function() {
>>>>>>          */
>>>>>>         getContext: getContext,
>>>>>>
>>>>>> -        /**
>>>>>> -        * Remove a selected gadget from the page
>>>>>> -        */
>>>>>> -        deleteGadget : deleteWidgetFromPage,
>>>>>>
>>>>>>          /**
>>>>>>           * Change or delete gadget to region map entry.
>>>>>> @@ -261,6 +279,12 @@ var rave = rave || (function() {
>>>>>>          /**
>>>>>>           * Get the region where a widget/gadget belongs to.
>>>>>>           */
>>>>>> -        getGadgetRegion : getGadgetRegion
>>>>>> +          getGadgetRegion : getGadgetRegion,
>>>>>> +
>>>>>> +                  /**
>>>>>> +                        * These are exposed toolbar actions, associated 
>>>>>> with widget
>>>>>>toolbar
>>>>>> buttons
>>>>>> +                        */
>>>>>> +                  toolbarMaximize : toolbar.maximizeAction,
>>>>>> +                  toolbarDelete : toolbar.deleteAction
>>>>>>     }
>>>>>> })();
>>>>>> \ No newline at end of file
>>>>>>
>>>>>>
>>>>>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
>iQEcBAEBAgAGBQJN7RPQAAoJEEfVXEODPFIDaP4IAJeKwT0vBXiYKMYwD461ItqN
>D3Jzopd4H4/VTjmnJUbvwYhWTK6WmFth3vP2/kI2E14K+r6rMS426jKnYsFGwISy
>zrYTp2zx3499NV8+CObErSQ2RY+kPyIujT++KzjeO6Ca0UJe6eNqCDKwMhXj2Vtf
>ttUpT4OOKUqhq0V7HrS3P5WOPLrPax5EZG6G+mec3fLc0tSwNk3CBgxGn5Pwzzgr
>BYQpBP9VlximU7VJL6kYi62AGEmynnh7JMDzUnE7AP2NeOw6oms2q0LFmo/2qoJA
>jsnLOWiCtW+q/q4tFKcTMo1LEm9SvXJNZClIdpimelTj3kw5k8JK+HzwyyeFIag=
>=hFjv
>-----END PGP SIGNATURE-----

Reply via email to