-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 OK, Gerald's right and I found and corrected the broken parts of my changes to his code. As per chat with Matt however, we probably want to revisit some of this.
Marlon On 6/6/11 5:15 PM, Zhenhua (Gerald) Guo wrote: > In Javascript, I have a widget-to-region map which tracks in which > region a widget is located. Every time a widget is moved, added or > deleted, the map is updated to be consistent with server-side data. > > Gerald > > On Mon, Jun 6, 2011 at 2:11 PM, Marlon Pierce <[email protected]> wrote: > Deletion doesn't work if you move a gadget from one column to another: the > regionId on client and server are not in synch until you refresh the page or > logout/login. We'll have to revisit to remove the dependency of regionId on > the client side. > > > Marlon > > > On 6/6/11 5:08 PM, Zhenhua (Gerald) Guo wrote: >>>> I committed some code to fix the gadget deletion bug several days ago. >>>> I tested it and it worked. >>>> It still does not work for you guys? >>>> >>>> Gerald >>>> >>>> On Mon, Jun 6, 2011 at 11:34 AM, Marlon Pierce <[email protected]> >>>> wrote: >>>> Sorry, computer crash. Sure--go ahead or describe the solution and I'll >>>> do it. Deleting the RegionWidget from Region's list was the only way I >>>> saw to do the delete. >>>> >>>> >>>> Marlon >>>> >>>> >>>> On 6/6/11 1:55 PM, Franklin, Matthew B. wrote: >>>>>>> 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: >>>>>>> >>>>>>> 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/ iQEcBAEBAgAGBQJN7VGxAAoJEEfVXEODPFIDmM8IAIQ6ZTkBkfvDgYz0SLmNjbR3 DCgSERF8TS5Yp5p/pQMSJf3KWvOg+iLc9j1IzIy4ajpJlU0UDzSsKe5lctE+8QDL eZc/sTHbh70jV6dgB0MoC10yrg2VRq3wuu+vYwYMlWcEKjlpFALNqI/M3LycgyAD X48RzSY/GOyXG94zbrZV83/eNw44cvk88id40WTapu55EBxqrkXAymm+LsZERK5b /KBSD06R/z/8R6D/jZTT2K2iUVazvgG+yeNxcn2GiU9/JOqICPFWiCL0sGt9urfn V3efN2wWh+el/a5MhAFdZPVk5hlqM5Q7SwR3AWjS0A2Nepjnw9+DiG6E31kItkw= =gXcZ -----END PGP SIGNATURE-----
