Retain filter when changing region tag visibility
This commit is contained in:
		
							parent
							
								
									f149156def
								
							
						
					
					
						commit
						ea71efb5e6
					
				
					 3 changed files with 16 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,12 @@ html
 | 
			
		|||
                      .pl6 Region tags
 | 
			
		||||
                    #location-tags-loading
 | 
			
		||||
                    input(type="hidden" name="account" value=account)
 | 
			
		||||
                    if filter_field
 | 
			
		||||
                      input(type="hidden" name="filter_field" value=filter_field)
 | 
			
		||||
                    if filter
 | 
			
		||||
                      input(type="hidden" name="filter" value=filter)
 | 
			
		||||
                    if filter_fuzzy
 | 
			
		||||
                      input(type="hidden" name="filter_fuzzy" value=filter_fuzzy)
 | 
			
		||||
                    .s-toggle-switch.s-toggle-switch__multiple
 | 
			
		||||
                      - const locationTagsSetting = h3.getCookie(event, "bcex-location-tags") || "all"
 | 
			
		||||
                      input#location-tags-all(type="radio" name="location_tags" value="all" autocomplete="off" checked=(locationTagsSetting === "all"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,10 @@ const schema = {
 | 
			
		|||
	}),
 | 
			
		||||
	locationTags: z.object({
 | 
			
		||||
		location_tags: z.enum(["all", "hide", "only"]),
 | 
			
		||||
		account
 | 
			
		||||
		account,
 | 
			
		||||
		filter_field: z.enum(["band_name", "band_url", "item_title", "item_id", "tag", "why"]).optional(),
 | 
			
		||||
		filter: z.string().regex(/^[^%]+$/).optional(),
 | 
			
		||||
		filter_fuzzy: z.enum(["true"]).optional()
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,11 @@ router.post("/api/settings/inline-player", defineEventHandler(async event => {
 | 
			
		|||
}))
 | 
			
		||||
 | 
			
		||||
router.post("/api/settings/location-tags", defineEventHandler(async event => {
 | 
			
		||||
	const {location_tags, account} = await readValidatedBody(event, schema.schema.locationTags.parse)
 | 
			
		||||
	const {location_tags, account, filter, filter_field, filter_fuzzy} = await readValidatedBody(event, schema.schema.locationTags.parse)
 | 
			
		||||
	setCookie(event, "bcex-location-tags", location_tags)
 | 
			
		||||
	return sendRedirect(event, `/${account}/?arrange=tag&shape=grid`)
 | 
			
		||||
	const params = new URLSearchParams({arrange: "tag", shape: "grid"})
 | 
			
		||||
	if (filter) params.set("filter", filter)
 | 
			
		||||
	if (filter_field) params.set("filter_field", filter_field)
 | 
			
		||||
	if (filter_fuzzy) params.set("filter_fuzzy", filter_fuzzy)
 | 
			
		||||
	return sendRedirect(event, `/${account}/?${params}`)
 | 
			
		||||
}))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue