Blogroll rename implemented
Project: http://git-wip-us.apache.org/repos/asf/roller/repo Commit: http://git-wip-us.apache.org/repos/asf/roller/commit/dec85591 Tree: http://git-wip-us.apache.org/repos/asf/roller/tree/dec85591 Diff: http://git-wip-us.apache.org/repos/asf/roller/diff/dec85591 Branch: refs/heads/bootstrap-ui Commit: dec85591ee84f620e9c31d5c2606188879f84989 Parents: 8553cb5 Author: Dave Johnson <[email protected]> Authored: Sun Apr 3 12:49:50 2016 -0400 Committer: Dave Johnson <[email protected]> Committed: Sun Apr 3 12:49:50 2016 -0400 ---------------------------------------------------------------------- .../resources/ApplicationResources.properties | 6 +- .../webapp/WEB-INF/jsps/editor/Bookmarks.jsp | 141 ++++++++++++------- 2 files changed, 96 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/roller/blob/dec85591/app/src/main/resources/ApplicationResources.properties ---------------------------------------------------------------------- diff --git a/app/src/main/resources/ApplicationResources.properties b/app/src/main/resources/ApplicationResources.properties index 45b1e2c..f24c31f 100644 --- a/app/src/main/resources/ApplicationResources.properties +++ b/app/src/main/resources/ApplicationResources.properties @@ -89,8 +89,8 @@ bookmarksForm.newBlogroll=New blogroll... bookmarksForm.addBookmark=Add blogroll link bookmarksForm.addFolder=New blogroll bookmarksForm.delete=Delete selected -bookmarksForm.delete.confirm=Delete selected blogroll links? -bookmarksForm.deleteFolder.confirm=Delete entire blogroll including all its links? +bookmarksForm.delete.confirm=Confirm Selected Link Delete +bookmarksForm.delete.areYouSure=Are you sure you want to delete the selected blogroll links? bookmarksForm.url=URL bookmarksForm.feedurl=Newsfeed URL bookmarksForm.folder=Blogroll @@ -112,7 +112,7 @@ bookmarksForm.editBlogroll.title=Edit Blogroll bookmarksForm.blogroll.requiredFields=You must specify a blogroll name blogrollDeleteOK.removeBlogroll=Confirm Blogroll Delete -blogrollDeleteOK.areYouSure=Are you sure you want to delete blogroll +blogrollDeleteOK.areYouSure=Are you sure you want to delete blogroll and all of its links? # --------------------------------------------------------- Bookmarks import.jsp http://git-wip-us.apache.org/repos/asf/roller/blob/dec85591/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 d211877..89e8b58 100644 --- a/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp +++ b/app/src/main/webapp/WEB-INF/jsps/editor/Bookmarks.jsp @@ -186,7 +186,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and <input id="delete_selected" value="<s:text name="bookmarksForm.delete"/>" type="button" class="btn btn-danger" style="float:right; margin-right: 0.5em" - onclick="deleteFolder();return false;"/> + onclick="confirmDeleteSelected();return false;"/> </s:if> @@ -213,7 +213,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and <s:submit value="%{getText('bookmarksForm.deleteFolder')}" theme="simple" cssClass="btn btn-danger" cssStyle="float:right; clear:left; margin-top:2em" action="bookmarks!deleteFolder" - onclick="deleteFolder();return false;"/> + onclick="confirmDeleteFolder();return false;"/> </s:if> @@ -259,21 +259,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and new Option( '<s:text name="bookmarksForm.newBlogroll"/>', "new_blogroll" )); }); - function nameChanged() { - var newName = $("#bookmarks_folder_name:first").val(); - if ( newName != originalName ) { - renameButton.attr("disabled", false ); - renameButton.addClass("btn-success"); - - renameCancel.attr("disabled", false ); - } else { - renameButton.attr("disabled", true ); - renameButton.removeClass("btn-success"); - - renameCancel.attr("disabled", true ); - } - } function selectionChanged() { var checked = false; @@ -304,8 +290,53 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and } } - function renameFolder( event ) { - event.preventDefault(); + function nameChanged() { + var newName = $("#bookmarks_folder_name:first").val(); + if ( newName != originalName && newName.trim().length > 0 ) { + renameButton.attr("disabled", false ); + renameButton.addClass("btn-success"); + + renameCancel.attr("disabled", false ); + + } else { + renameButton.attr("disabled", true ); + renameButton.removeClass("btn-success"); + + renameCancel.attr("disabled", true ); + } + } + + function renameFolder() { + + var newName = $("#bookmarks_folder_name:first").val(); + $("#folderEditForm_bean_name").val(newName); + + var folderId = $("#bookmarks_folderId").val(); + $("#folderEditForm_bean_id").val(folderId); + + // post blogroll via AJAX + var folderEditForm = $("#folderEditForm")[0]; + $.ajax({ + method: 'post', + url: folderEditForm.attributes["action"].value, + data: $("#folderEditForm").serialize(), + context: document.body + + }).done(function (data, status, response) { + + // kludge: scrape response status from HTML returned by Struts + var alertEnd = data.indexOf("ALERT_END"); + if (data.indexOf('<s:text name="bookmarkForm.error.duplicateName" />') < alertEnd) { + alert('<s:text name="bookmarkForm.error.duplicateName" />'); + + } else { + originalName = newName; + nameChanged(); + } + + }).error(function (data) { + alert('<s:text name="generic.error.check.logs" />'); + }); } function cancelRenameFolder( event ) { @@ -313,35 +344,22 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and nameChanged(); } - function confirmDelete() { - // TODO: do not use plain old DHTML confirm here - if (confirm("<s:text name='bookmarksForm.delete.confirm' />")) { - document.bookmarks.submit(); - } + function confirmDeleteSelected() { + $('#delete-links-modal').modal({show: true}); } - function deleteFolder() { + function deleteSelected() { + document.bookmarks[0].submit(); + } + function confirmDeleteFolder() { $('#boomarks_delete_folder_folderId').val( $('#bookmarks_folderId:first').val() ); - $('#deleteBlogrollName').html('<s:text name="%{folder.name}"/>'); - $('#delete-blogroll-modal').modal({show: true}); - - <%-- - if (confirm("<s:text name='bookmarksForm.deleteFolder.confirm' />")) { - document.bookmarks.action = '<s:url action="bookmarks!deleteFolder" />'; - document.bookmarks.submit(); - } - --%> } function onMoveToFolder() { - // TODO: do not use plain old DHTML confirm here - if (confirm("<s:text name='bookmarksForm.move.confirm' />")) { - document.bookmarks.action = '<s:url action="bookmarks!move" />'; - document.bookmarks.submit(); - } + $('#move-links-modal').modal({show: true}); } function viewChanged() { @@ -473,6 +491,43 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and <%-- delete blogroll confirmation modal --%> +<div id="delete-links-modal" class="modal fade delete-links-modal" tabindex="-1" role="dialog"> + + <div class="modal-dialog modal-lg"> + + <div class="modal-content"> + + <div class="modal-header"> + <h3> + <s:text name="bookmarksForm.delete.confirm" /> + </h3> + </div> + + <s:form theme="bootstrap" cssClass="form-horizontal"> + <div class="modal-body"> + <s:text name="bookmarksForm.delete.areYouSure"></s:text> + </div> + + <div class="modal-footer"> + <button type="button" class="btn" value="%{getText('generic.yes')}" onclick="deleteSelected()"> + <s:text name="generic.yes" /> + </button> + + <button type="button" class="btn btn-default btn-primary" data-dismiss="modal"> + <s:text name="generic.no" /> + </button> + </div> + </s:form> + + </div> + </div> +</div> + + +<%-- ========================================================================================== --%> + +<%-- delete blogroll confirmation modal --%> + <div id="delete-blogroll-modal" class="modal fade delete-blogroll-modal" tabindex="-1" role="dialog"> <div class="modal-dialog modal-lg"> @@ -509,16 +564,6 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and </div> </div> -<script> - - function showBlogrollDeleteModal( id, name ) { - $('#blogrollRemove_removeId').val(id); - $('#blogroll-name').html(name); - $('#delete-remove-modal').modal({show: true}); - } - -</script> - <%-- ================================================================================================ --%>
