Author: jablko
Date: Wed Oct 27 20:35:16 2010
New Revision: 8596

Log:
Simplify relationTableMap

Modified:
   trunk/js/dialog.js
   
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/_relatedAuthorityRecord.php
   
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/templates/_relatedFunction.php

Modified: trunk/js/dialog.js
==============================================================================
--- trunk/js/dialog.js  Wed Oct 27 20:09:36 2010        (r8595)
+++ trunk/js/dialog.js  Wed Oct 27 20:35:16 2010        (r8596)
@@ -245,20 +245,18 @@
                 {
                   if (undefined !== thisDialog.options.relationTableMap)
                   {
-                    return { results: 
[thisDialog.options.relationTableMap(response)] };
+                    response = 
thisDialog.options.relationTableMap.call(thisDialog, response);
                   }
-                  else
-                  {
-                    var dataMap = function (response)
+
+                  var dataMap = function (response)
+                    {
+                      for (name in response)
                       {
-                        for (name in response)
-                        {
-                          this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
-                        }
+                        this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
                       }
+                    }
 
-                    return { results: [new dataMap(response)] };
-                  }
+                  return { results: [new dataMap(response)] };
                 }
 
               dataSource.sendRequest(null, {

Modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/_relatedAuthorityRecord.php
==============================================================================
--- 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/_relatedAuthorityRecord.php
     Wed Oct 27 20:09:36 2010        (r8595)
+++ 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/_relatedAuthorityRecord.php
     Wed Oct 27 20:35:16 2010        (r8596)
@@ -110,29 +110,15 @@
         }
 
       // Map relation table data to dialog fields
-      var relationTableMap = function (data)
+      var relationTableMap = function (response)
         {
-          var output = {};
-          for (col in data)
+          response.resource = response.object;
+          if ('$url' === response.resource)
           {
-            switch (col)
-            {
-              case 'subject':
-              case 'object':
-
-                if ('$url' != data[col])
-                {
-                  output[dialog.fieldPrefix + '[resource]'] = data[col];
-                }
-
-                break;
-
-              default:
-                output[dialog.fieldPrefix + '[' + col + ']'] = data[col];
-            }
+            response.resource = response.subject;
           }
 
-          return output;
+          return response;
         }
 
       // Define dialog

Modified: 
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/templates/_relatedFunction.php
==============================================================================
--- 
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/templates/_relatedFunction.php  
    Wed Oct 27 20:09:36 2010        (r8595)
+++ 
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/templates/_relatedFunction.php  
    Wed Oct 27 20:35:16 2010        (r8596)
@@ -111,29 +111,15 @@
   attach: function (context)
     {
       // Map relation table data to dialog fields
-      var relationTableMap = function (data)
+      var relationTableMap = function (response)
         {
-          var output = {};
-          for (col in data)
+          response.resource = response.object;
+          if ('$url' === response.resource)
           {
-            switch (col)
-            {
-              case 'subject':
-              case 'object':
-
-                if ('$url' != data[col])
-                {
-                  output[dialog.fieldPrefix + '[resource]'] = data[col];
-                }
-
-                break;
-
-              default:
-                output[dialog.fieldPrefix + '[' + col + ']'] = data[col];
-            }
+            response.resource = response.subject;
           }
 
-          return output;
+          return response;
         }
 
       // Define dialog

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to