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/04/30 00:23:08 UTC

svn commit: r1477384 - in /rave/branches/angular/rave-portal-resources/src/main/webapp: WEB-INF/jsp/views/ static/html/portal/ static/html/portal/partials/ static/script/angular-portal/

Author: erinnp
Date: Mon Apr 29 22:23:07 2013
New Revision: 1477384

URL: http://svn.apache.org/r1477384
Log:
Got moving of widgets to save, added templates for layouts

Added:
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_1.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2wn.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3_newuser.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn_1_bottom.html
      - copied, changed from r1464166, rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/layouts/columns_3nwn_1_bottom.jsp
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_4.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html
Modified:
    rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js
    rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp?rev=1477384&r1=1477383&r2=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/angular.jsp Mon Apr 29 22:23:07 2013
@@ -5,6 +5,7 @@
 <head>
     <base href="/portal/app/angular/portal/">
     <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
+    <link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="stylesheet">
     <link rel="stylesheet" href="/portal/static/css/rave.css"/>
 </head>
 <body>
@@ -15,8 +16,9 @@
 <script src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
 <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
 <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
+<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
-<script src="http://code.angularjs.org/1.1.4/angular-resource.js"></script>
+<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>
 <script src="https://raw.github.com/angular-ui/bootstrap/gh-pages/ui-bootstrap-0.2.0.min.js"></script>
 <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.3/bootstrap.min.js"></script>
 

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_1.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_1.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_1.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_1.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2wn.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2wn.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2wn.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_2wn.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3_newuser.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3_newuser.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3_newuser.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3_newuser.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,28 @@
+<div class="columns_3_newuser_static">
+    This is the default page layout for new users. We suggest you play with some of the Rave features:
+    <ul>
+        <li>Rename this page and change the widget layout</li>
+        <li>Add a new page</li>
+        <li>Add widgets from the Widget Store</li>
+        <li>Edit the preferences for a widget</li>
+        <li>Move widgets around on a page</li>
+        <li>Collapse and restore a widget</li>
+        <li>much more...</li>
+    </ul>
+</div>
+
+<div class="columns_3_newuser_widgets">
+    <div class="columns_3_newuser_subtitle">We have provided a few sample widgets for you to try out. Click on the
+        Widget Store link above to add more widgets!
+    </div>
+    <div class="widgetRow upperRow">
+        <div ng-repeat="region in page.regions.slice(0,2)">
+            <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+        </div>
+    </div>
+    <div class="widgetRow bottomRow">
+        <div ng-repeat="region in page.regions.slice(2)">
+            <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+        </div>
+    </div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Copied: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn_1_bottom.html (from r1464166, rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/layouts/columns_3nwn_1_bottom.jsp)
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn_1_bottom.html?p2=rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn_1_bottom.html&p1=rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/layouts/columns_3nwn_1_bottom.jsp&r1=1464166&r2=1477384&rev=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/WEB-INF/jsp/layouts/columns_3nwn_1_bottom.jsp (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_3nwn_1_bottom.html Mon Apr 29 22:23:07 2013
@@ -1,29 +1,11 @@
-<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
-<%--
-  ~ 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.
-  --%>
-
 <div class="widgetRow upperRow">
-    <rave:region region="${page.regions[0]}" regionIdx="1"  />
-    <rave:region region="${page.regions[1]}" regionIdx="2"  />
-    <rave:region region="${page.regions[2]}" regionIdx="3"  />
+    <div ng-repeat="region in page.regions.slice(0,3)">
+        <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+    </div>
 </div>
 
 <div class="widgetRow bottomRow">
-    <rave:region region="${page.regions[3]}" regionIdx="4"  />
+    <div ng-repeat="region in page.regions.slice(3)">
+        <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+    </div>
 </div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_4.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_4.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_4.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/columns_4.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,3 @@
+<div ng-repeat="region in page.regions">
+    <div ng-include="'/portal/static/html/portal/partials/region.html'"></div>
+</div>
\ No newline at end of file

Added: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html?rev=1477384&view=auto
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html (added)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/partials/region.html Mon Apr 29 22:23:07 2013
@@ -0,0 +1,71 @@
+<!-- TODO: page.regions.indexOf - view logic and embedded js. That sucks. -->
+<div ng-class="{regionDragging:dragging, regionNonDragging:!dragging}"
+     class="region {{page.pageLayoutCode}}_{{page.regions.indexOf(region)+1}}"
+     ui-sortable="sortingOpts" ng-model="region.regionWidgets">
+    <div ng-repeat="regionWidget in region.regionWidgets">
+        <div class="widget-wrapper" ng-controller="WidgetController">
+            <div class="widget-title-bar widget-title-bar-draggable">
+                <div class="widget-toolbar-toggle-collapse" title="Collapse/Restore Widget">
+                    <i ng-class="{'icon-chevron-down':!regionWidget.collapsed, 'icon-chevron-up':regionWidget.collapsed}"
+                       ng-click="toggleCollapse()"></i>
+                </div>
+                <div class="widget-title">
+                    {{regionWidget.widgetUrl}}
+                </div>
+                <div class="widget-toolbar ">
+                    <div class="dropdown widget-menu-wrapper" style="">
+                        <a class="dropdown-toggle" data-toggle="dropdown">
+                            <i class="icon-cog"></i>
+                        </a>
+                        <ul class="dropdown-menu widget-menu">
+                            <li class="">
+                                <a ng-click="showPrefs=true">
+                                    Edit Preferences
+                                </a>
+                            </li>
+                            <li>
+                                <a href="#">
+                                    Maximize
+                                </a>
+                            </li>
+                            <li>
+                                <a href="#">
+                                    Move to Page
+                                </a>
+                            </li>
+                            <li>
+                                <a href="#">
+                                    Delete Widget
+                                </a>
+                            </li>
+                            <li class="divider"></li>
+                            <li>
+                                <a href="#">
+                                    About this Widget
+                                </a>
+                            </li>
+                            <li>
+                                <a href="#">
+                                    Comment on this Widget
+                                </a>
+                            </li>
+                            <li>
+                                <a href="#">
+                                    Rate this Widget
+                                </a>
+                            </li>
+                        </ul>
+                    </div>
+                            <span class="widget-toolbar-btn widget-toolbar-btn-min">
+                                <i class="icon-resize-small"></i>
+                            </span>
+                </div>
+            </div>
+
+            <div class="widget-prefs" ng-show="showPrefs">Edit Prefs Pane</div>
+            <div class="widget" render-widget="regionWidget.id" ng-hide="regionWidget.collapsed">
+
+            </div>
+        </div>
+    </div>
+</div>
\ No newline at end of file

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html?rev=1477384&r1=1477383&r2=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/html/portal/tabs.html Mon Apr 29 22:23:07 2013
@@ -33,116 +33,74 @@
     </nav>
     <div class="row-fluid">
         <div class="tab-content" ng-show="selectedPageId == page.id" ng-repeat="page in pages">
-            <div ng-repeat="(regionIndex, region) in page.regions" ng-class="page.pageLayoutCode+'_'+regionIndex"
-                 class="region regionNonDragging">
-                <div ng-repeat="regionWidget in region.regionWidgets">
-                    <div class="widget-wrapper" ng-controller="WidgetController">
-                        <div class="widget-title-bar widget-title-bar-draggable">
-                            <div class="widget-toolbar-toggle-collapse" title="Collapse/Restore Widget">
-                                <i ng-class="{'icon-chevron-down':!regionWidget.collapsed, 'icon-chevron-up':regionWidget.collapsed}"
-                                   ng-click="toggleCollapse()"></i>
-                            </div>
-                            <div class="widget-title">
-                                {{regionWidget.widgetUrl}}
-                            </div>
-                            <div class="widget-toolbar ">
-                                <div class="dropdown widget-menu-wrapper" style="">
-                                    <a class="dropdown-toggle" data-toggle="dropdown">
-                                        <i class="icon-cog"></i>
-                                    </a>
-                                    <ul class="dropdown-menu widget-menu">
-                                        <li class="">
-                                            <a ng-click="showPrefs=true">
-                                                Edit Preferences
-                                            </a>
-                                        </li>
-                                        <li>
-                                            <a href="#">
-                                                Maximize
-                                            </a>
-                                        </li>
-                                        <li>
-                                            <a href="#">
-                                                Move to Page
-                                            </a>
-                                        </li>
-                                        <li>
-                                            <a href="#">
-                                                Delete Widget
-                                            </a>
-                                        </li>
-                                        <li class="divider"></li>
-                                        <li>
-                                            <a href="#">
-                                                About this Widget
-                                            </a>
-                                        </li>
-                                        <li>
-                                            <a href="#">
-                                                Comment on this Widget
-                                            </a>
-                                        </li>
-                                        <li>
-                                            <a href="#">
-                                                Rate this Widget
-                                            </a>
-                                        </li>
-                                    </ul>
-                                </div>
-                            <span class="widget-toolbar-btn widget-toolbar-btn-min">
-                                <i class="icon-resize-small"></i>
-                            </span>
-                            </div>
-                        </div>
-
-                        <div class="widget-prefs" ng-show="showPrefs">Edit Prefs Pane</div>
-                        <div class="widget" render-widget="regionWidget.id" ng-hide="regionWidget.collapsed">
-
-                        </div>
-                    </div>
+            <div id="emptyPageMessageWrapper" class="emptyPageMessageWrapper">
+                <div class="emptyPageMessage" ng-hide="hasWidgets(page)">
+                    <a href="/portal/app/store">Add widgets to this page</a>
                 </div>
             </div>
+            <div ng-include="'/portal/static/html/portal/partials/'+page.pageLayoutCode+'.html'"></div>
         </div>
     </div>
 </div>
 
 <script type="text/ng-template" id="editPageModal">
-        <div class="modal-header">
-            <a class="close" ng-click="close()">&times;</a>
-
-            <h3 id="pageMenuDialogHeader">Add New Page</h3>
-        </div>
-        <div class="modal-body">
-            <form id="pageForm" class="form-horizontal">
-                <input type="hidden" name="tab_id" id="tab_id" value=""/>
-                <fieldset>
-                    <div class="control-group error">
-                        <label id="pageFormErrors" class="control-label"></label>
+    <form class="form-horizontal modal-form"  ng-submit="savePage()" >
+    <div class="modal-header">
+        <a class="close" ng-click="close()">&times;</a>
+        <h3>Add New Page</h3>
+    </div>
+    <div class="modal-body">
+            <fieldset>
+                <div class="control-group">
+                    <label class="control-label" for="tab_title">Title </label>
+
+                    <div class="controls">
+                        <input id="tab_title" class="input-xlarge focused" type="text" ng-model="page.name" required
+                               ng-class="{'ng-invalid':errorMsg}"/>
+                        <span class="error">{{errorMsg}}</span>
                     </div>
-                    <div class="control-group">
-                        <label class="control-label" for="tab_title">Title </label>
+                </div>
+                <div class="control-group">
+                    <label class="control-label" for="pageLayout">Select Layout </label>
 
-                        <div class="controls">
-                            <input id="tab_title" class="input-xlarge focused" type="text" ng-model="page.name" required
-                                   ng-class="{'ng-invalid':errorMsg}"/>
-                            <span class="error">{{errorMsg}}</span>
-                        </div>
+                    <div class="controls">
+                        <select id="pageLayout" ng-model="page.pageLayoutCode" ng-options="l.value as l.label for l in layouts">
+                        </select>
                     </div>
-                    <div class="control-group" id="pageLayoutGroup">
-                        <label class="control-label" for="pageLayout">Select Layout </label>
+                </div>
+            </fieldset>
+    </div>
+    <div class="modal-footer">
+        <button class="btn" type="button" ng-click="close()">Cancel</button>
+        <button class="btn btn-primary" type="submit">Save</button>
+    </div>
+    </form>
+</script>
+
+<script type="text/ng-template" id="movePageModal">
+    <div class="modal-header">
+        <a class="close" ng-click="close()">&times;</a>
 
-                        <div class="controls">
-                            <select id="pageLayout" ng-model="page.pageLayoutCode" ng-options="l.value as l.label for l in layouts">
-                            </select>
-                        </div>
+        <h3 id="pageMenuDialogHeader">Move This Page</h3>
+    </div>
+    <div class="modal-body">
+        <form id="pageForm" class="form-horizontal">
+            <fieldset>
+                <div class="control-group" id="pageLayoutGroup">
+                    <label class="control-label" for="pageLocation">Move to </label>
+
+                    <div class="controls">
+                        <select id="pageLocation" ng-model="newLocation" ng-options="l.value as l.label for l in locations">
+                        </select>
                     </div>
-                </fieldset>
-            </form>
-        </div>
-        <div class="modal-footer">
-            <a id="pageMenuCloseButton" class="btn" ng-click="close()">Cancel</a>
-            <a id="pageMenuUpdateButton" class="btn btn-primary" ng-click="savePage()">Save</a>
-        </div>
+                </div>
+            </fieldset>
+        </form>
+    </div>
+    <div class="modal-footer">
+        <a id="pageMenuCloseButton" class="btn" ng-click="close()">Cancel</a>
+        <a id="pageMenuUpdateButton" class="btn btn-primary" ng-click="movePage()">Move Page</a>
+    </div>
 </script>
 
 

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js?rev=1477384&r1=1477383&r2=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/controllers.js Mon Apr 29 22:23:07 2013
@@ -1,4 +1,4 @@
-angular.module('rave.controller', ['ui.bootstrap'])
+angular.module('rave.controller', ['ui.bootstrap', 'ui'])
     .config(['$dialogProvider',
         function ($dialogProvider) {
             $dialogProvider.options({
@@ -14,6 +14,25 @@ angular.module('rave.controller', ['ui.b
             $scope.portalPrefs;
             $scope.pages = Pages.get('portal', '@self');
             $scope.selectedPageId = $routeParams.tabId;
+            $scope.dragging = false;
+            $scope.sortingOpts = {
+                connectWith: '.region', // defines which regions are dnd-able
+                scroll: true, // whether to scroll the window if the user goes outside the areas
+                opacity: 0.5, // the opacity of the object being dragged
+                revert: true, // smooth snap animation
+                cursor: 'move', // the cursor to show while dnd
+                handle: '.widget-title-bar-draggable', // the draggable handle
+                tolerance: 'pointer', // change dnd drop zone on mouse-over
+                start: function (e, ui) {
+                    ui.placeholder.height(ui.item.height());
+                    $scope.dragging = true;
+                    $scope.$apply();
+                },
+                stop: function (e, ui) {
+                    $scope.dragging = false;
+                    $scope.$apply();
+                }
+            }
 
             if (_.isUndefined($scope.selectedPageId)) {
                 $scope.pages.then(function (pages) {
@@ -21,8 +40,10 @@ angular.module('rave.controller', ['ui.b
                 });
             }
             $scope.pages.then(registerWidgetsForPages);
+            $scope.pages.then(watchForMove)
+
 
-            //TODO: this does not fire on first load?
+            //TODO: this does not fire on first load - why?
             $scope.$on('$routeChangeSuccess', function (oldRoute, newRoute) {
                 if (_.isUndefined(newRoute.params.tabId)) {
                     $scope.pages.then(function (pages) {
@@ -34,16 +55,51 @@ angular.module('rave.controller', ['ui.b
             });
 
             function registerWidgetsForPages(pages) {
-                //TODO
                 rave.init();
                 var widgets = _.chain(pages).pluck('regions').flatten().pluck('regionWidgets').flatten().value();
-                var i = 0;
                 _.each(widgets, function (widget) {
+                    //TODO: this is a fix for a bug in the api
                     widget.metadata = JSON.parse(widget.metadata);
                     rave.registerWidget(widget);
                 });
             }
 
+            function watchForMove(pages) {
+                $scope.$watch(function () {
+                    return _.chain(pages)
+                        .where({id: $scope.selectedPageId})
+                        .pluck('regions').flatten()
+                        .map(function (region, regionIndex) {
+                            return _.map(region.regionWidgets, function (widget, index) {
+                                return  {
+                                    id: widget.id,
+                                    //TODO: it's dumb that region index is 1-based
+                                    regionId: regionIndex + 1,
+                                    index: index
+                                }
+                            });
+                        })
+                        .flatten().value();
+                }, function (newValue, oldValue) {
+                    var oldRegion;
+
+                    var movedWidget = _.find(newValue, function (widget) {
+                        var isChanged = !_.any(oldValue, function (val) {
+                            return _.isEqual(widget, val);
+                        });
+
+                        if (isChanged) {
+                            return widget;
+                        }
+                    });
+
+                    if(movedWidget) {
+                        oldRegion = _.findWhere(oldValue, {id: movedWidget.id}).regionId;
+                        rave.getWidget(movedWidget.id).moveToRegion(oldRegion, movedWidget.regionId, movedWidget.index);
+                    }
+                }, true)
+            }
+
             $scope.addPage = function () {
                 $dialog.dialog({
                     templateUrl: 'editPageModal',
@@ -55,12 +111,15 @@ angular.module('rave.controller', ['ui.b
                     }
                 }).open();
             }
+
+            $scope.hasWidgets = function (page) {
+                return _.chain(page.regions).pluck('regionWidgets').flatten().value().length > 0;
+            }
         }
     ])
     .controller('CurrentPageController', ['$scope', 'Pages', '$dialog', '$location',
         function ($scope, Pages, $dialog, $location) {
 
-
             $scope.edit = function () {
                 $dialog.dialog({
                     templateUrl: 'editPageModal',
@@ -73,7 +132,18 @@ angular.module('rave.controller', ['ui.b
                 }).open();
             }
             $scope.move = function () {
-
+                $dialog.dialog({
+                    templateUrl: 'movePageModal',
+                    controller: 'MovePageController',
+                    resolve: {
+                        pages: function () {
+                            return angular.copy($scope.pages);
+                        },
+                        page: function () {
+                            return angular.copy($scope.page);
+                        }
+                    }
+                }).open();
             }
             $scope.delete = function () {
                 Pages.delete($scope.page.id).then(function () {
@@ -106,8 +176,8 @@ angular.module('rave.controller', ['ui.b
             }
         }
     ])
-    .controller('EditPageController', ['$scope', 'Pages', 'dialog', 'page',
-        function ($scope, Pages, dialog, page) {
+    .controller('EditPageController', ['$scope', 'Pages', 'dialog', 'page', '$location',
+        function ($scope, Pages, dialog, page, $location) {
             //TODO: layouts needs to come from a service
             $scope.layouts = [
                 {label: 'One Column',
@@ -151,6 +221,7 @@ angular.module('rave.controller', ['ui.b
                 $scope.savePage = function () {
                     Pages.add($scope.page.name, $scope.page.pageLayoutCode).then(function (result) {
                         dialog.close();
+                        $location.path(result.id);
                     }, function () {
                         $scope.errorMsg = 'A page with that name already exists';
                     });
@@ -158,4 +229,30 @@ angular.module('rave.controller', ['ui.b
             }
 
         }
+    ])
+    //TODO: try drag&drop for moving pages?
+    .controller('MovePageController', [ '$scope', 'Pages', 'dialog', 'page', 'pages',
+        function ($scope, Pages, dialog, page, pages) {
+            $scope.pages = pages;
+            $scope.page = page;
+            $scope.locations = [
+                {label: '', value: ''}
+            ];
+            $scope.newLocation = $scope.locations[0].value;
+
+            $scope.close = function () {
+                dialog.close();
+            }
+
+            $scope.movePage = function () {
+                Pages.move(page.id, newLocationId);
+                dialog.close();
+            }
+
+        }
+    ])
+    .controller('SharePageController', ['$scope', 'Pages',
+        function () {
+
+        }
     ]);
\ No newline at end of file

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js?rev=1477384&r1=1477383&r2=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/directives.js Mon Apr 29 22:23:07 2013
@@ -1,10 +1,23 @@
 angular.module('rave.directive', [])
-    .directive('renderWidget', ['rave', '$parse', function (rave, $parse) {
-        return function postLink(scope, el, attrs) {
-            var fn = $parse(attrs.renderWidget);
-            var renderWidgetId = fn(scope);
-            if(!_.isUndefined(renderWidgetId)){
-                rave.getWidget(renderWidgetId).render(el[0]);
+    .directive('renderWidget', ['rave', '$parse',
+        function (rave, $parse) {
+            return function postLink(scope, el, attrs) {
+                var fn = $parse(attrs.renderWidget);
+                var renderWidgetId = fn(scope);
+                if (!_.isUndefined(renderWidgetId)) {
+                    rave.getWidget(renderWidgetId).render(el[0]);
+                }
             }
         }
-    }]);
\ No newline at end of file
+    ])
+    .directive('sortable', [
+        function(){
+            return {
+                link: function(scope, element, attrs, ngModel) {
+                    var opts = scope.$eval(attrs.sortable);
+
+                    element.sortable(opts);
+                }
+            }
+        }
+    ]);
\ No newline at end of file

Modified: rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js
URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js?rev=1477384&r1=1477383&r2=1477384&view=diff
==============================================================================
--- rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js (original)
+++ rave/branches/angular/rave-portal-resources/src/main/webapp/static/script/angular-portal/services.js Mon Apr 29 22:23:07 2013
@@ -1,4 +1,4 @@
-angular.module('rave.service', ['ngResource'])
+angular.module('rave.service', [])
     .value('rave', rave)
     .service('Pages', ['$http', '$interpolate', '$q', '$rootScope', 'rave',
         function ($http, $interpolate, $q, $rootScope, rave) {
@@ -35,9 +35,14 @@ angular.module('rave.service', ['ngResou
                         else {
                             var newPage = result.result;
                             pages.then(function (pages) {
+                                /*
+                                TODO: newPage object returned by rpc api is different format from rest api,
+                                screws up pagelayout code and possibly more
+                                 */
+                                newPage.pageLayoutCode = newPage.pageLayout.code;
                                 pages.push(newPage);
                             });
-                            $rootScope.$apply(deferred.resolve(result));
+                            $rootScope.$apply(deferred.resolve(newPage));
                         }
                     }
                 });
@@ -52,6 +57,13 @@ angular.module('rave.service', ['ngResou
                     pageId: pageId,
                     moveAfterPageId: afterPageId,
                     successCallback: function (result) {
+                        pages.then(function (pages) {
+                            var movingPage =  _.findWhere(pages, {id: pageId})
+                            var fromIdx = _.indexOf(pages, movingPage);
+                            var toIdx = _.indexOf(pages, _.findWhere(pages, {id: afterPageId}));
+                            pages.splice(fromIdx,1)
+                            pages.splice(toIdx, 0, movingPage);
+                        });
                         $rootScope.$apply(deferred.resolve(result));
                     }
                 });
@@ -100,16 +112,30 @@ angular.module('rave.service', ['ngResou
                 return deferred.promise;
             }
 
+            Pages.share = function(pageId, userId, role){}
+
             return Pages;
         }
     ])
-    .service('settings', ['$resource',
-        function () {
+    .service('user', ['$q',
+        function($q){
+            var deferred = $q.defer();
+
+            deferred.resolve({
 
+            });
+
+            return deferred.promise;
         }
     ])
-    .service('popups', [
+    .service('users', [function(){}])
+    .service('settings', [
         function () {
 
         }
+    ])
+    .service('views', [
+        function () {
+            //TODO: write a view service to be more robust than ng-include, probably with a corresponding directive
+        }
     ])
\ No newline at end of file