Author: rbaxter85
Date: Fri Sep  2 13:34:43 2011
New Revision: 1164527

URL: http://svn.apache.org/viewvc?rev=1164527&view=rev
Log:
SHINDIG-1607
Committed For Dan Dumont.
Allow actions to be executed in more than one view.

Modified:
    
shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
    
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js

Modified: 
shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml?rev=1164527&r1=1164526&r2=1164527&view=diff
==============================================================================
--- 
shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
 (original)
+++ 
shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
 Fri Sep  2 13:34:43 2011
@@ -24,9 +24,9 @@
 <Optional feature="actions">
 <Param name="action-contributions"><![CDATA[<actions>
 <action id="org.samplevoip.chatwithperson" dataType="opensocial.Person" 
-               label="Chat" tooltip="Chat" view="DialByPerson" />
+               label="Chat" tooltip="Chat" />
 <action id="org.samplevoip.callbyperson" dataType="opensocial.Person" 
-               label="Call" tooltip="Call" view="DialByPerson" />
+               label="Call" tooltip="Call" />
 <action id="org.samplevoip.navLink" path="container/navigationLinks" 
label="Call Person" tooltip="Dial a Number"/>
 </actions>]]></Param>
 </Optional>

Modified: 
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/actions/actions_container.js?rev=1164527&r1=1164526&r2=1164527&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
 Fri Sep  2 13:34:43 2011
@@ -271,16 +271,31 @@
     };
 
     /**
-     * Returns the gadget site associated with the specified action object.
+     * Return the gadget sites associated with the specified action object.
      *
      * @param {Object}
      *          actionId The id of the action.
-     * @return {osapi.container.GadgetSite} The gadget site instance associated
-     *         with the action object.
+     * @return {Array} An array of the gadget site instances associated
+     *         with the action object, or undefined if there are none.
      */
-    this.getGadgetSite = function(actionId) {
-      var url = this.actionToUrl[actionId];
-      var sites = this.urlToSite[url];
+    this.getGadgetSites = function(actionId) {
+      var action = this.getItemById(actionId);
+
+      var url = this.actionToUrl[actionId],
+          sites,
+          candidates;
+
+      if (candidates = this.urlToSite[url]) {
+        // Return subset of matching sites (gadget view matches declared 
action view,
+        // if the action declared a view) Do not modify existing array.
+        for (var i = 0, site; site = candidates[i]; i++) {
+          var holder = site.getActiveGadgetHolder();
+          if (!action.view || (holder && holder.getView() === action.view)) {
+            (sites = sites || []).push(site);
+          }
+        }
+      }
+
       return sites;
     };
 
@@ -406,12 +421,18 @@
     if (!selection && container_ && container_.selection) {
       actionData.selectionObj = container_.selection.getSelection();
     }
-    // make rpc call to get gadget to run callback based on action id
-    var gadgetSites = registry.getGadgetSite(actionId);
-    if (gadgetSites && gadgetSites.length > 0) {
-      var frameId = gadgetSites[0].getActiveGadgetHolder().getIframeId();
+
+    // make rpc call to get gadgets to run callback based on action id
+    var gadgetSites = registry.getGadgetSites(actionId);
+    if (gadgetSites) {
+      for (var i = 0, site; site = gadgetSites[i]; i++) {
+        var holder = site.getActiveGadgetHolder();
+        if (holder) {
+          var frameId = holder.getIframeId();
+          gadgets.rpc.call(frameId, 'actions', null, 'runAction', actionData);
+        }
+      }
     }
-    gadgets.rpc.call(frameId, 'actions', null, 'runAction', actionData);
   };
 
   /**
@@ -677,18 +698,13 @@
         if (action) {
           // if gadget site has not been registered yet
           // the gadget needs to be rendered
-          var gadgetSite = registry.getGadgetSite(actionId);
-          if (!gadgetSite) {
+          var gadgetSites = registry.getGadgetSites(actionId);
+          if (!gadgetSites) {
             var gadgetUrl = registry.getUrl(actionId);
             pendingActions[actionId] = {
-              selection: container_.selection.getSelection()
+              selection: opt_selection || container_.selection.getSelection()
             };
 
-            // set selection
-           if (opt_selection != null) {
-             pendingActions[actionId].selection = opt_selection;
-           }
-
             // set optional params
             var opt_params = {};
             if (action.view) {


Reply via email to