Author: erinnp
Date: Thu Aug 29 14:37:50 2013
New Revision: 1518662

URL: http://svn.apache.org/r1518662
Log:
RAVE - 1037: RegionWidget Directive. Applying patch from Dan Gornstein.

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

Added: 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
URL: 
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js?rev=1518662&view=auto
==============================================================================
--- 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
 (added)
+++ 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/RenderRegionWidget.js
 Thu Aug 29 14:37:50 2013
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * The RenderRegionWidget directive takes a regionWidget to be rendered in the 
region-widget="" attribute
+ * and renders that regionWidget at the location of the directive.
+ */
+
+define(['angular'], function(angular){
+    return [ 'constants', function(constants){
+        var renderRegionWidgetDirectiveDefinition = {
+            restrict: 'EA',
+            replace: true,
+            scope:{
+                regionWidget: '='
+            },
+            link: function (scope, element, attrs){
+                scope.$watch('regionWidget', function(){
+                    if(scope.regionWidget){
+                        //Make clone so watch does not cycle too many times
+                        var regionWidgetClone = 
angular.copy(scope.regionWidget);
+
+                        //Render the widget
+                        regionWidgetClone.render(element[0]);
+                    }
+                }, true);
+            }
+        }
+        return renderRegionWidgetDirectiveDefinition;
+    }]
+})
+

Modified: 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js
URL: 
http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js?rev=1518662&r1=1518661&r2=1518662&view=diff
==============================================================================
--- 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js
 (original)
+++ 
rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/common/directives/index.js
 Thu Aug 29 14:37:50 2013
@@ -17,12 +17,13 @@
  * under the License.
  */
 
-define(['angular', './Base'],
-    function (angular, base) {
+define(['angular', './Base', './RenderRegionWidget'],
+    function (angular, base, renderRegionWidget) {
         var directives = angular.module('common.directives', []);
 
         directives.directive('base', base);
+        directives.directive('renderRegionWidget', renderRegionWidget);
 
         return directives;
     }
-);
\ No newline at end of file
+);

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=1518662&r1=1518661&r2=1518662&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 29 14:37:50 2013
@@ -46,18 +46,27 @@ define(['underscore', 'rave'], function 
                         decomposePage(page);
                     });
 
-                    return onSuccess(pages);
+                    if(onSuccess){
+                        return onSuccess(pages);
+                    }else{
+                        return pages
+                    }
                 });
             }
 
             res.get = function (args, onSuccess, onError) {
-                return res.get.call(null, args).$then(function (res) {
+                return res._get.call(null, args).$then(function (res) {
                     //TODO: check for error
                     var page = res.data;
 
                     decomposePage(page);
 
-                    return onSuccess(page);
+                    if(onSuccess){
+                        return onSuccess(page);
+                    }else{
+                        return page
+                    }
+
                 });
             }
 


Reply via email to