1- import { DELETE , POST } from '../modules/fetch.ts' ;
1+ import { POST } from '../modules/fetch.ts' ;
22import { addDelegatedEventListener , hideElem , queryElems , showElem , toggleElem } from '../utils/dom.ts' ;
33import { fomanticQuery } from '../modules/fomantic/base.ts' ;
44import { camelize } from 'vue' ;
@@ -17,7 +17,8 @@ export function initGlobalDeleteButton(): void {
1717 // Some model/form elements will be filled by `data-id` / `data-name` / `data-data-xxx` attributes.
1818 // If there is a form defined by `data-form`, then the form will be submitted as-is (without any modification).
1919 // If there is no form, then the data will be posted to `data-url`.
20- // TODO: it's not encouraged to use this method. `show-modal` does far better than this.
20+ // TODO: do not use this method in new code. `show-modal` / `link-action(data-modal-confirm)` does far better than this.
21+ // FIXME: all legacy `delete-button` should be refactored to use `show-modal` or `link-action`
2122 for ( const btn of document . querySelectorAll < HTMLElement > ( '.delete-button' ) ) {
2223 btn . addEventListener ( 'click' , ( e ) => {
2324 e . preventDefault ( ) ;
@@ -62,10 +63,7 @@ export function initGlobalDeleteButton(): void {
6263 }
6364 }
6465
65- const method = btn . getAttribute ( 'data-method' ) ?. toUpperCase ( ) || 'POST' ;
66- const response = method === 'DELETE' ?
67- await DELETE ( btn . getAttribute ( 'data-url' ) ) :
68- await POST ( btn . getAttribute ( 'data-url' ) , { data : postData } ) ;
66+ const response = await POST ( btn . getAttribute ( 'data-url' ) , { data : postData } ) ;
6967 if ( response . ok ) {
7068 const data = await response . json ( ) ;
7169 window . location . href = data . redirect ;
0 commit comments