forked from omicron/d2warehouse
		
	Add select all feature to stash tabs
This commit is contained in:
		
							
								
								
									
										13
									
								
								d2warehouse/app/static/helpers.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								d2warehouse/app/static/helpers.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | function toggleSelectAll(tabIndex) { | ||||||
|  |     const tab = document.querySelector(`[data-tab="${tabIndex}"]`); | ||||||
|  |     const checkboxes = tab.querySelectorAll('input[type="checkbox"]'); | ||||||
|  |  | ||||||
|  |    if (checkboxes.length === 0) | ||||||
|  |         return; | ||||||
|  |  | ||||||
|  |     const allSelected = Array.from(checkboxes).every(cb => cb.checked); | ||||||
|  |  | ||||||
|  |     checkboxes.forEach(cb => { | ||||||
|  |         cb.checked = !allSelected; | ||||||
|  |     }); | ||||||
|  | } | ||||||
| @@ -4,13 +4,14 @@ | |||||||
|     <meta charset="utf-8"> |     <meta charset="utf-8"> | ||||||
|     <title>Shared Stash</title> |     <title>Shared Stash</title> | ||||||
|     <link rel="stylesheet" href="/static/style.css" /> |     <link rel="stylesheet" href="/static/style.css" /> | ||||||
|  |     <script src="/static/helpers.js"></script> | ||||||
|   <head> |   <head> | ||||||
|   <body> |   <body> | ||||||
|     <form action="/stash/{{stash_name}}/store" method="POST"> |     <form action="/stash/{{stash_name}}/store" method="POST"> | ||||||
|     {% for tab in stash.tabs %} |     {% for tab in stash.tabs %} | ||||||
|       {% set tabloop = loop %} |       {% set tabloop = loop %} | ||||||
|       <h2>Tab {{tabloop.index}}</h2> |       <h2>Tab {{tabloop.index}} <button type="button" onclick="toggleSelectAll({{tabloop.index}})">Select All</button> </h2> | ||||||
|       <div class="stash-tab"> |       <div class="stash-tab" data-tab="{{tabloop.index}}"> | ||||||
|         {% for item in tab.items %} |         {% for item in tab.items %} | ||||||
|         {% set itemloop = loop %} |         {% set itemloop = loop %} | ||||||
|         {% include "item.html" %} |         {% include "item.html" %} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user