You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by er...@apache.org on 2013/08/15 18:37:01 UTC

svn commit: r1514357 - in /rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources: PagesForRenderResource.js index.js

Author: erinnp
Date: Thu Aug 15 16:37:00 2013
New Revision: 1514357

URL: http://svn.apache.org/r1514357
Log:
Small updates

Modified:
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js?rev=1514357&r1=1514356&r2=1514357&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/PagesForRenderResource.js Thu Aug 15 16:37:00 2013
@@ -17,9 +17,39 @@
  * under the License.
  */
 
-define([], function(){
-    return ['$resource', function($resource){
-        return $resource('/portal/api/rest/pages/render/:context/:identifier/:id');
-    }];
+define(['underscore'], function (_) {
+    return ['$resource', 'Pages', 'Regions', 'RegionWidgets',
+        function ($resource, Pages, Regions, RegionWidgets) {
+            var res = $resource('/portal/api/rest/pages/render/:context/:identifier/:id', {},
+                {
+                    _query: { method: 'GET', isArray: true }
+                });
+
+            res.query = function (args, onSuccess, onError) {
+                return res._query.call(null, args).$then(function (res) {
+                    //TODO: check for error
+                    var pages = res.data;
+
+                    _.each(pages, function (page, k) {
+                        page = pages[k] = new Pages(page);
+
+                        console.log(page);
+
+                        _.each(page.regions, function (region, j) {
+                            region = page.regions[j] = new Regions(region);
+
+                            _.each(region.regionWidgets, function (regionWidget, i) {
+                                region.regionWidgets[i] = new RegionWidgets(regionWidget);
+                            });
+                        });
+                    });
+
+                    return onSuccess(pages);
+                });
+            }
+
+            return res;
+        }
+    ];
 })
 

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js?rev=1514357&r1=1514356&r2=1514357&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/resources/index.js Thu Aug 15 16:37:00 2013
@@ -37,11 +37,11 @@ define(['angular', './CategoriesResource
 
         resources.factory('Categories', categories);
         resources.factory('Pages', pages);
-        resources.factory('PagesForRender', pagesForRender);
         resources.factory('People', people);
         resources.factory('Regions', regions);
         resources.factory('RegionWidgets', regionWidgets);
         resources.factory('Users', users);
+        resources.factory('PagesForRender', pagesForRender);
 
         return resources;
     });