Update rails/ujs delegate method usage (#27538)
		
	This commit is contained in:
		
					parent
					
						
							
								134de736dc
							
						
					
				
			
			
				commit
				
					
						bc3afb6311
					
				
			
		
					 2 changed files with 24 additions and 24 deletions
				
			
		|  | @ -2,7 +2,7 @@ import './public-path'; | |||
| import React from 'react'; | ||||
| import { createRoot } from 'react-dom/client'; | ||||
| 
 | ||||
| import delegate from '@rails/ujs'; | ||||
| import Rails from '@rails/ujs'; | ||||
| 
 | ||||
| import ready from '../mastodon/ready'; | ||||
| 
 | ||||
|  | @ -20,7 +20,7 @@ const setAnnouncementEndsAttributes = (target) => { | |||
|   } | ||||
| }; | ||||
| 
 | ||||
| delegate(document, 'input[type="datetime-local"]#announcement_starts_at', 'change', ({ target }) => { | ||||
| Rails.delegate(document, 'input[type="datetime-local"]#announcement_starts_at', 'change', ({ target }) => { | ||||
|   setAnnouncementEndsAttributes(target); | ||||
| }); | ||||
| 
 | ||||
|  | @ -43,7 +43,7 @@ const hideSelectAll = () => { | |||
|   hiddenField.value = '0'; | ||||
| }; | ||||
| 
 | ||||
| delegate(document, '#batch_checkbox_all', 'change', ({ target }) => { | ||||
| Rails.delegate(document, '#batch_checkbox_all', 'change', ({ target }) => { | ||||
|   const selectAllMatchingElement = document.querySelector('.batch-table__select-all'); | ||||
| 
 | ||||
|   [].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => { | ||||
|  | @ -59,7 +59,7 @@ delegate(document, '#batch_checkbox_all', 'change', ({ target }) => { | |||
|   } | ||||
| }); | ||||
| 
 | ||||
| delegate(document, '.batch-table__select-all button', 'click', () => { | ||||
| Rails.delegate(document, '.batch-table__select-all button', 'click', () => { | ||||
|   const hiddenField = document.querySelector('#select_all_matching'); | ||||
|   const active = hiddenField.value === '1'; | ||||
|   const selectedMsg = document.querySelector('.batch-table__select-all .selected'); | ||||
|  | @ -76,7 +76,7 @@ delegate(document, '.batch-table__select-all button', 'click', () => { | |||
|   } | ||||
| }); | ||||
| 
 | ||||
| delegate(document, batchCheckboxClassName, 'change', () => { | ||||
| Rails.delegate(document, batchCheckboxClassName, 'change', () => { | ||||
|   const checkAllElement = document.querySelector('#batch_checkbox_all'); | ||||
|   const selectAllMatchingElement = document.querySelector('.batch-table__select-all'); | ||||
| 
 | ||||
|  | @ -94,19 +94,19 @@ delegate(document, batchCheckboxClassName, 'change', () => { | |||
|   } | ||||
| }); | ||||
| 
 | ||||
| delegate(document, '.media-spoiler-show-button', 'click', () => { | ||||
| Rails.delegate(document, '.media-spoiler-show-button', 'click', () => { | ||||
|   [].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => { | ||||
|     element.click(); | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
| delegate(document, '.media-spoiler-hide-button', 'click', () => { | ||||
| Rails.delegate(document, '.media-spoiler-hide-button', 'click', () => { | ||||
|   [].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => { | ||||
|     element.click(); | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
| delegate(document, '.filter-subset--with-select select', 'change', ({ target }) => { | ||||
| Rails.delegate(document, '.filter-subset--with-select select', 'change', ({ target }) => { | ||||
|   target.form.submit(); | ||||
| }); | ||||
| 
 | ||||
|  | @ -123,7 +123,7 @@ const onDomainBlockSeverityChange = (target) => { | |||
|   } | ||||
| }; | ||||
| 
 | ||||
| delegate(document, '#domain_block_severity', 'change', ({ target }) => onDomainBlockSeverityChange(target)); | ||||
| Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => onDomainBlockSeverityChange(target)); | ||||
| 
 | ||||
| const onEnableBootstrapTimelineAccountsChange = (target) => { | ||||
|   const bootstrapTimelineAccountsField = document.querySelector('#form_admin_settings_bootstrap_timeline_accounts'); | ||||
|  | @ -140,7 +140,7 @@ const onEnableBootstrapTimelineAccountsChange = (target) => { | |||
|   } | ||||
| }; | ||||
| 
 | ||||
| delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target)); | ||||
| Rails.delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target)); | ||||
| 
 | ||||
| const onChangeRegistrationMode = (target) => { | ||||
|   const enabled = target.value === 'approved'; | ||||
|  | @ -177,7 +177,7 @@ const convertLocalDatetimeToUTC = (value) => { | |||
|   return fullISO8601.slice(0, fullISO8601.indexOf('T') + 6); | ||||
| }; | ||||
| 
 | ||||
| delegate(document, '#form_admin_settings_registrations_mode', 'change', ({ target }) => onChangeRegistrationMode(target)); | ||||
| Rails.delegate(document, '#form_admin_settings_registrations_mode', 'change', ({ target }) => onChangeRegistrationMode(target)); | ||||
| 
 | ||||
| ready(() => { | ||||
|   const domainBlockSeverityInput = document.getElementById('domain_block_severity'); | ||||
|  | @ -214,7 +214,7 @@ ready(() => { | |||
|     } | ||||
|   }); | ||||
| 
 | ||||
|   delegate(document, 'form', 'submit', ({ target }) => { | ||||
|   Rails.delegate(document, 'form', 'submit', ({ target }) => { | ||||
|     [].forEach.call(target.querySelectorAll('input[type="datetime-local"]'), element => { | ||||
|       if (element.value && element.validity.valid) { | ||||
|         element.value = convertLocalDatetimeToUTC(element.value); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue