mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-31 15:23:02 +00:00 
			
		
		
		
	Add bulk metadata edit button
This commit is contained in:
		 James Armstong
					James Armstong
				
			
				
					committed by
					
						 James Armstrong
						James Armstrong
					
				
			
			
				
	
			
			
			 James Armstrong
						James Armstrong
					
				
			
						parent
						
							4ed0633edf
						
					
				
				
					commit
					ecda717bed
				
			| @@ -96,6 +96,9 @@ $(function() { | ||||
|  | ||||
|                 $("#unread_selected_books").removeClass("disabled"); | ||||
|                 $("#unread_selected_books").attr("aria-disabled", false); | ||||
|  | ||||
|                 $("#edit_selected_books").removeClass("disabled"); | ||||
|                 $("#edit_selected_books").attr("aria-disabled", false); | ||||
|             } else { | ||||
|                 $("#delete_selected_books").addClass("disabled"); | ||||
|                 $("#delete_selected_books").attr("aria-disabled", true); | ||||
| @@ -111,6 +114,9 @@ $(function() { | ||||
|  | ||||
|                 $("#unread_selected_books").addClass("disabled"); | ||||
|                 $("#unread_selected_books").attr("aria-disabled", true); | ||||
|  | ||||
|                 $("#edit_selected_books").addClass("disabled"); | ||||
|                 $("#edit_selected_books").attr("aria-disabled", true); | ||||
|             } | ||||
|             if (selections.length < 1) { | ||||
|                 $("#delete_selection").addClass("disabled"); | ||||
| @@ -166,6 +172,68 @@ $(function() { | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $("#edit_selected_books").click(function(event) { | ||||
|         if ($(this).hasClass("disabled")) { | ||||
|             event.stopPropagation() | ||||
|         } else { | ||||
|             $('#edit_selected_modal').modal("show"); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     $("#edit_selected_confirm").click(function(event) { | ||||
|         let title = $("#title_input").val() | ||||
|         let title_sort = $("#title_sort_input").val() | ||||
|         let author_sort = $("#author_sort_input").val() | ||||
|         let authors = $("#authors_input").val() | ||||
|         let categories = $("#categories_input").val() | ||||
|         let series = $("#series_input").val() | ||||
|         let languages = $("#languages_input").val() | ||||
|         let publishers = $("#publishers_input").val() | ||||
|         let comments = $("#comments_input").val().toString() | ||||
|  | ||||
|         function loopThrough(param, value) | ||||
|         { | ||||
|             selections.forEach((book_id)  => { | ||||
|                 $.ajax({ | ||||
|                     method: "post", | ||||
|                     url: getPath() + "/ajax/editbooks/" + param, | ||||
|                     data: { pk: book_id, value: value }, | ||||
|                     error: function (data) { | ||||
|                         handleListServerResponse([ | ||||
|                             { type: "danger", message: data.responseText }, | ||||
|                         ]); | ||||
|                     }, | ||||
|                     success: function success(booTitles) { | ||||
|                         $("#books-table").bootstrapTable("refresh"); | ||||
|                         $("#books-table").bootstrapTable("uncheckAll"); | ||||
|  | ||||
|                         $("#title_input").value = ""; | ||||
|                         $("#title_sort_input").value = ""; | ||||
|                         $("#author_sort_input").value = ""; | ||||
|                         $("#authors_input").value = ""; | ||||
|                         $("#categories_input").value = ""; | ||||
|                         $("#series_input").value = ""; | ||||
|                         $("#languages_input").value = ""; | ||||
|                         $("#publishers_input").value = ""; | ||||
|                         $("#comments_input").value = ""; | ||||
|  | ||||
|                         handleListServerResponse; | ||||
|                     }, | ||||
|                 }); | ||||
|             }) | ||||
|         } | ||||
|  | ||||
|         if (title) loopThrough('title', title); | ||||
|         if (title_sort) loopThrough('title_sort', title_sort); | ||||
|         if (author_sort) loopThrough('author_sort', author_sort); | ||||
|         if (authors) loopThrough('authors', authors); | ||||
|         if (categories) loopThrough('tags', categories); | ||||
|         if (series) loopThrough('series', series); | ||||
|         if (languages) loopThrough('languages', languages); | ||||
|         if (publishers) loopThrough('publishers', publishers); | ||||
|         if (comments) loopThrough('comments', comments); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#archive_selected_books', function(event) { | ||||
|         if ($(this).hasClass("disabled")) { | ||||
|             event.stopPropagation() | ||||
|   | ||||
| @@ -58,6 +58,9 @@ | ||||
|           <div class="btn btn-default disabled" id="delete_selection" aria-disabled="true"> | ||||
|             {{_('Clear selections')}} | ||||
|           </div> | ||||
|           <div class="btn btn-default disabled" id="edit_selected_books" aria-disabled="true"> | ||||
|             {{_('Edit selected books')}} | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="row form-group"> | ||||
|             <div class="btn btn-default disabled" id="table_xchange" ><span class="glyphicon glyphicon-arrow-up"></span><span class="glyphicon glyphicon-arrow-down"></span>{{_('Exchange author and title')}}</div> | ||||
| @@ -258,6 +261,61 @@ | ||||
|     </div> | ||||
|   </div> | ||||
| </div> | ||||
|  | ||||
| <div class="modal fade" id="edit_selected_modal" role="dialog" aria-labelledby="metaEditSelectedLabel"> | ||||
|   <div class="modal-dialog"> | ||||
|     <div class="modal-content"> | ||||
|       <div class="modal-header text-center"> | ||||
|           <span>{{_('Edit Metadata')}}</span> | ||||
|       </div> | ||||
|       <div class="modal-body"> | ||||
|         <div class="text-left">{{_('Edit the fields you want changed. Blank fields will be ignored:')}}</div> | ||||
|             <br> | ||||
|             Title: | ||||
|             <input class="form-control" id="title_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Title Sort: | ||||
|             <input class="form-control" id="title_sort_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Author Sort: | ||||
|             <input class="form-control" id="author_sort_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Authors: | ||||
|             <input class="form-control" id="authors_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Categories: | ||||
|             <input class="form-control" id="categories_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Series: | ||||
|             <input class="form-control" id="series_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Languages: | ||||
|             <input class="form-control" id="languages_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Publishers: | ||||
|             <input class="form-control" id="publishers_input"> | ||||
|             <p></p> | ||||
|  | ||||
|             Comments: | ||||
|             <input class="form-control" id="comments_input"> | ||||
|             <p></p> | ||||
|       </div> | ||||
|  | ||||
|       <div class="modal-footer"> | ||||
|         <input id="edit_selected_confirm" type="button" class="btn btn-danger" value="{{_('Edit')}}" name="edit_selected_confirm" id="edit_selected_confirm" data-dismiss="modal"> | ||||
|         <button id="edit_selected_abort" type="button" class="btn btn-default" data-dismiss="modal">{{_('Cancel')}}</button> | ||||
|       </div> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| </div> | ||||
| {% endif %} | ||||
| {% endblock %} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user