roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [44/47] roller git commit: When new blogroll created, switch to it.
Date Fri, 27 May 2016 22:51:06 GMT
When new blogroll created, switch to it.


Project: http://git-wip-us.apache.org/repos/asf/roller/repo
Commit: http://git-wip-us.apache.org/repos/asf/roller/commit/8553cb55
Tree: http://git-wip-us.apache.org/repos/asf/roller/tree/8553cb55
Diff: http://git-wip-us.apache.org/repos/asf/roller/diff/8553cb55

Branch: refs/heads/bootstrap-ui
Commit: 8553cb5555474af199bd69b7036f28fa4f0ae655
Parents: f76eb9d
Author: Dave Johnson <snoopdave@gmail.com>
Authored: Sun Apr 3 11:40:50 2016 -0400
Committer: Dave Johnson <snoopdave@gmail.com>
Committed: Sun Apr 3 11:40:50 2016 -0400

----------------------------------------------------------------------
 .../weblogger/ui/struts2/editor/BookmarkEdit.java    |  4 ++++
 .../weblogger/ui/struts2/editor/Bookmarks.java       | 10 ++++++++++
 .../weblogger/ui/struts2/editor/FolderEdit.java      | 15 ++++++++++++++-
 .../main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp    | 15 ++++++++++++---
 4 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/roller/blob/8553cb55/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
index 725dcfd..461aec9 100644
--- a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
+++ b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/BookmarkEdit.java
@@ -27,8 +27,11 @@ import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.WeblogBookmark;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
+import org.apache.struts2.interceptor.ServletResponseAware;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
+import javax.servlet.http.HttpServletResponse;
+
 
 /**
  * Edit a new or existing bookmark (blogroll item).
@@ -147,4 +150,5 @@ public class BookmarkEdit extends UIAction {
     public WeblogBookmark getBookmark() {
         return bookmark;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/roller/blob/8553cb55/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
index 3b91677..6893915 100644
--- a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
+++ b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Bookmarks.java
@@ -157,7 +157,13 @@ public class Bookmarks extends UIAction {
         try {
             BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
             WeblogBookmarkFolder fd = bmgr.getFolder(getFolderId());
+
             if (fd != null) {
+
+                if ( "default".equals( fd.getName() ) ) {
+                    addError("Cannot delete default bookmark");
+                    return execute();
+                }
                 bmgr.removeFolder(fd);
 
                 // flush changes
@@ -170,6 +176,7 @@ public class Bookmarks extends UIAction {
                 setFolder(bmgr.getDefaultFolder(getActionWeblog()));
                 setFolderId(getFolder().getId());
             }
+
         } catch (WebloggerException ex) {
             log.error("Error deleting folder", ex);
         }
@@ -280,6 +287,9 @@ public class Bookmarks extends UIAction {
 
     public void setFolder(WeblogBookmarkFolder folder) {
         this.folder = folder;
+        if ( folder != null ) {
+            this.folderId = folder.getId();
+        }
     }
 
     public String getViewFolderId() {

http://git-wip-us.apache.org/repos/asf/roller/blob/8553cb55/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/FolderEdit.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/FolderEdit.java
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/FolderEdit.java
index 10a7201..bbecdfa 100644
--- a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/FolderEdit.java
+++ b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/FolderEdit.java
@@ -27,13 +27,16 @@ import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
+import org.apache.struts2.interceptor.ServletResponseAware;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
+import javax.servlet.http.HttpServletResponse;
+
 
 /**
  * Edit a new or existing folder.
  */
-public class FolderEdit extends UIAction {
+public class FolderEdit extends UIAction implements ServletResponseAware {
     
     private static Log log = LogFactory.getLog(FolderEdit.class);
 
@@ -46,6 +49,9 @@ public class FolderEdit extends UIAction {
     // the folder we are adding or editing
     private WeblogBookmarkFolder folder = null;
 
+    private HttpServletResponse httpServletResponse;
+
+
     public FolderEdit() {
         this.desiredMenu = "editor";
     }
@@ -72,6 +78,11 @@ public class FolderEdit extends UIAction {
         }
     }
 
+    @Override
+    public void setServletResponse(HttpServletResponse httpServletResponse) {
+        this.httpServletResponse = httpServletResponse;
+    }
+
     /**
      * Show folder edit page.
      */
@@ -112,6 +123,8 @@ public class FolderEdit extends UIAction {
                     addMessage("folderForm.updated");
                 }
 
+                httpServletResponse.addHeader("folderId", folderId );
+
                 return SUCCESS;
 
             } catch(Exception ex) {

http://git-wip-us.apache.org/repos/asf/roller/blob/8553cb55/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp
----------------------------------------------------------------------
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp b/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp
index 0ed4f00..d211877 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp
@@ -322,7 +322,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll
links and
 
     function deleteFolder() {
 
-        $('#boomarks_delete_folder_folderId').val('<s:text name="%{folder.id}"/>');
+        $('#boomarks_delete_folder_folderId').val( $('#bookmarks_folderId:first').val() );
 
         $('#deleteBlogrollName').html('<s:text name="%{folder.name}"/>');
 
@@ -437,7 +437,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll
links and
             data: $("#folderEditForm").serialize(),
             context: document.body
 
-        }).done(function (data) {
+        }).done(function (data, status, response) {
 
             // kludge: scrape response status from HTML returned by Struts
             var alertEnd = data.indexOf("ALERT_END");
@@ -449,7 +449,15 @@ We used to call them Bookmarks and Folders, now we call them Blogroll
links and
                 feedbackAreaBlogrollEdit.css("color", "green");
                 feedbackAreaBlogrollEdit.html('<s:text name="generic.success" />');
                 $('#blogroll-edit-modal').modal("hide");
-                location.reload(true);
+
+                // kludge get folderId from response header send back by Struts action
+                var newFolderId = response.getResponseHeader('folderId');
+                viewSelector.append( new Option('', newFolderId ));
+                $("#bookmarks_viewFolderId").val( newFolderId );
+
+                var bookmarksForm = $("#bookmarks")[0];
+                bookmarksForm.action = "bookmarks!view.rol";
+                bookmarksForm.submit();
             }
 
         }).error(function (data) {
@@ -727,6 +735,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll
links and
                 feedbackAreaEdit.css("color", "green");
                 feedbackAreaEdit.html('<s:text name="generic.success" />');
                 $('#category-edit-modal').modal("hide");
+
                 location.reload(true);
             }
 


Mime
View raw message