mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Save and edit next button appears on documents without viewer as well.
Made the new recent correspondents filter optional. Disabled by default.
This commit is contained in:
		| @@ -94,6 +94,7 @@ class RecentCorrespondentFilter(admin.RelatedFieldListFilter): | |||||||
|  |  | ||||||
|     def field_choices(self, field, request, model_admin): |     def field_choices(self, field, request, model_admin): | ||||||
|         lookups = [] |         lookups = [] | ||||||
|  |         if settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS and settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS > 0: | ||||||
|             date_limit = datetime.now() - timedelta(days=365*settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS) |             date_limit = datetime.now() - timedelta(days=365*settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS) | ||||||
|             for c in Correspondent.objects.filter(documents__created__gte = date_limit).distinct(): |             for c in Correspondent.objects.filter(documents__created__gte = date_limit).distinct(): | ||||||
|                 lookups.append( (c.id, c.name) ) |                 lookups.append( (c.id, c.name) ) | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								src/documents/templates/admin/documents/document/change_form.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										7
									
								
								src/documents/templates/admin/documents/document/change_form.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
| {{ block.super }} | {{ block.super }} | ||||||
|  |  | ||||||
| {% if file_type in "pdf jpg png" %} | {% if file_type in "asd" %} | ||||||
|  |  | ||||||
| 	<div id="change_form_twocolumn_parent"> | 	<div id="change_form_twocolumn_parent"> | ||||||
| 		<div id="change_form_form_parent"></div> | 		<div id="change_form_form_parent"></div> | ||||||
| @@ -23,7 +23,9 @@ | |||||||
| 		django.jQuery("#content-main").append(django.jQuery("#change_form_twocolumn_parent")); | 		django.jQuery("#content-main").append(django.jQuery("#change_form_twocolumn_parent")); | ||||||
| 	</script> | 	</script> | ||||||
|  |  | ||||||
| 	{% if next_object %} | {% endif %} | ||||||
|  |  | ||||||
|  | {% if next_object %} | ||||||
| 	<script type="text/javascript">//<![CDATA[ | 	<script type="text/javascript">//<![CDATA[ | ||||||
| 		(function($){ | 		(function($){ | ||||||
| 			$('<input type="submit" value="Save and edit next" name="_saveandeditnext" />') | 			$('<input type="submit" value="Save and edit next" name="_saveandeditnext" />') | ||||||
| @@ -32,7 +34,6 @@ | |||||||
| 			.prependTo('div.submit-row'); | 			.prependTo('div.submit-row'); | ||||||
| 		})(django.jQuery); | 		})(django.jQuery); | ||||||
| 	//]]></script> | 	//]]></script> | ||||||
| 	{% endif %} |  | ||||||
| {% endif %} | {% endif %} | ||||||
|  |  | ||||||
| {% endblock content %} | {% endblock content %} | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ | |||||||
|         <input type="hidden" name="action" value="{{action}}"/> |         <input type="hidden" name="action" value="{{action}}"/> | ||||||
|         <input type="hidden" name="post" value="yes"/> |         <input type="hidden" name="post" value="yes"/> | ||||||
|         <p> |         <p> | ||||||
|             <input type="submit" value="{% trans " Confirm" %}" /> |             <input type="submit" value="{% trans "Confirm" %}" /> | ||||||
|             <a href="#" class="button cancel-link">{% trans "Go back" %}</a> |             <a href="#" class="button cancel-link">{% trans "Go back" %}</a> | ||||||
|         </p> |         </p> | ||||||
|     </div> |     </div> | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								src/documents/templates/admin/documents/document/viewers/viewer_image.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										1
									
								
								src/documents/templates/admin/documents/document/viewers/viewer_image.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -1,2 +1 @@ | |||||||
| <img src="{{download_url}}" style="max-width: 100%"> | <img src="{{download_url}}" style="max-width: 100%"> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										69
									
								
								src/documents/templates/admin/documents/document/viewers/viewer_pdf.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										69
									
								
								src/documents/templates/admin/documents/document/viewers/viewer_pdf.html
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -11,12 +11,13 @@ | |||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <div style="width: 100%; overflow: auto;"> | <div style="width: 100%; overflow: auto;"> | ||||||
| <canvas id="the-canvas"></canvas> |     <canvas id="the-canvas"></canvas> | ||||||
|     </div> | </div> | ||||||
| <script type="text/javascript" src="{% static 'documents/js/pdf.js' %}"></script> | <script type="text/javascript" src="{% static 'documents/js/pdf.js' %}"></script> | ||||||
| <script type="text/javascript" src="{% static 'documents/js/pdf.worker.js' %}"></script> | <script type="text/javascript" src="{% static 'documents/js/pdf.worker.js' %}"></script> | ||||||
| 	{# Load and display PDF document#} |  | ||||||
| 	<script> | {# Load and display PDF document#} | ||||||
|  | <script> | ||||||
| var pdfjsLib = window['pdfjs-dist/build/pdf']; | var pdfjsLib = window['pdfjs-dist/build/pdf']; | ||||||
|  |  | ||||||
| var pdfDoc = null, | var pdfDoc = null, | ||||||
| @@ -31,7 +32,7 @@ var pdfDoc = null, | |||||||
|  * Get page info from document, resize canvas accordingly, and render page. |  * Get page info from document, resize canvas accordingly, and render page. | ||||||
|  * @param num Page number. |  * @param num Page number. | ||||||
|  */ |  */ | ||||||
|   function renderPage(num) { | function renderPage(num) { | ||||||
|     pageRendering = true; |     pageRendering = true; | ||||||
|     // Using promise to fetch the page |     // Using promise to fetch the page | ||||||
|     pdfDoc.getPage(num).then(function(page) { |     pdfDoc.getPage(num).then(function(page) { | ||||||
| @@ -56,64 +57,74 @@ var pdfDoc = null, | |||||||
|     }); |     }); | ||||||
|     // Update page counters |     // Update page counters | ||||||
|     document.getElementById('page_num').textContent = num; |     document.getElementById('page_num').textContent = num; | ||||||
|   } | } | ||||||
|   /** |  | ||||||
|  | /** | ||||||
|  * If another page rendering in progress, waits until the rendering is |  * If another page rendering in progress, waits until the rendering is | ||||||
|  * finised. Otherwise, executes rendering immediately. |  * finised. Otherwise, executes rendering immediately. | ||||||
|  */ |  */ | ||||||
|   function queueRenderPage(num) { | function queueRenderPage(num) { | ||||||
|     if (pageRendering) { |     if (pageRendering) { | ||||||
|         pageNumPending = num; |         pageNumPending = num; | ||||||
|     } else { |     } else { | ||||||
|         renderPage(num); |         renderPage(num); | ||||||
|     } |     } | ||||||
|   } | } | ||||||
|   /** |  | ||||||
|  | /** | ||||||
|  * Displays previous page. |  * Displays previous page. | ||||||
|  */ |  */ | ||||||
|   function onPrevPage() { | function onPrevPage() { | ||||||
|     if (pageNum <= 1) { |     if (pageNum <= 1) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     pageNum--; |     pageNum--; | ||||||
|     queueRenderPage(pageNum); |     queueRenderPage(pageNum); | ||||||
|   } | } | ||||||
|   document.getElementById('prev').addEventListener('click', onPrevPage); |  | ||||||
|   /** | document.getElementById('prev').addEventListener('click', onPrevPage); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  * Displays next page. |  * Displays next page. | ||||||
|  */ |  */ | ||||||
|   function onNextPage() { | function onNextPage() { | ||||||
|     if (pageNum >= pdfDoc.numPages) { |     if (pageNum >= pdfDoc.numPages) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     pageNum++; |     pageNum++; | ||||||
|     queueRenderPage(pageNum); |     queueRenderPage(pageNum); | ||||||
|   } | } | ||||||
|   document.getElementById('next').addEventListener('click', onNextPage); |  | ||||||
|   /** | document.getElementById('next').addEventListener('click', onNextPage); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  * Displays next page. |  * Displays next page. | ||||||
|  */ |  */ | ||||||
|   function onZoomIn() { | function onZoomIn() { | ||||||
|     scale *= 1.2; |     scale *= 1.2; | ||||||
|     queueRenderPage(pageNum); |     queueRenderPage(pageNum); | ||||||
|   } | } | ||||||
|   document.getElementById('zoomin').addEventListener('click', onZoomIn); |  | ||||||
|   /** | document.getElementById('zoomin').addEventListener('click', onZoomIn); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  * Displays next page. |  * Displays next page. | ||||||
|  */ |  */ | ||||||
|   function onZoomOut() { | function onZoomOut() { | ||||||
|     scale /= 1.2; |     scale /= 1.2; | ||||||
|     queueRenderPage(pageNum); |     queueRenderPage(pageNum); | ||||||
|   } | } | ||||||
|   document.getElementById('zoomout').addEventListener('click', onZoomOut); |  | ||||||
|   /** | document.getElementById('zoomout').addEventListener('click', onZoomOut); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  * Asynchronously downloads PDF. |  * Asynchronously downloads PDF. | ||||||
|  */ |  */ | ||||||
|   pdfjsLib.getDocument("{{download_url}}").then(function (pdfDoc_) { | pdfjsLib.getDocument("{{download_url}}").then(function (pdfDoc_) { | ||||||
|     pdfDoc = pdfDoc_; |     pdfDoc = pdfDoc_; | ||||||
|     document.getElementById('page_count').textContent = pdfDoc.numPages; |     document.getElementById('page_count').textContent = pdfDoc.numPages; | ||||||
|     // Initial/first page rendering |     // Initial/first page rendering | ||||||
|     renderPage(pageNum); |     renderPage(pageNum); | ||||||
|   }); | }); | ||||||
| 	</script> | </script> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -298,4 +298,8 @@ FY_END = os.getenv("PAPERLESS_FINANCIAL_YEAR_END") | |||||||
| # Specify the default date order (for autodetected dates) | # Specify the default date order (for autodetected dates) | ||||||
| DATE_ORDER = os.getenv("PAPERLESS_DATE_ORDER", "DMY") | DATE_ORDER = os.getenv("PAPERLESS_DATE_ORDER", "DMY") | ||||||
|  |  | ||||||
| PAPERLESS_RECENT_CORRESPONDENT_YEARS = int(os.getenv("PAPERLESS_RECENT_CORRESPONDENT_YEARS", 1)) | # Specify for how many years a correspondent is considered recent. Recent | ||||||
|  | # correspondents will be shown in a separate "Recent correspondents" filter as | ||||||
|  | # well. Set to 0 to disable this filter. | ||||||
|  | PAPERLESS_RECENT_CORRESPONDENT_YEARS = int(os.getenv( | ||||||
|  |     "PAPERLESS_RECENT_CORRESPONDENT_YEARS", 0)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler