Champ Repetition dossier editor
This commit is contained in:
parent
a4a421a91a
commit
071448e1d9
17 changed files with 225 additions and 7 deletions
24
app/javascript/new_design/champs/repetition.js
Normal file
24
app/javascript/new_design/champs/repetition.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { delegate } from '@utils';
|
||||
|
||||
const BUTTON_SELECTOR = '.button.remove-row';
|
||||
const DESTROY_INPUT_SELECTOR = 'input[type=hidden][name*=_destroy]';
|
||||
const CHAMP_SELECTOR = '.editable-champ';
|
||||
|
||||
addEventListener('turbolinks:load', () => {
|
||||
delegate('click', BUTTON_SELECTOR, evt => {
|
||||
evt.preventDefault();
|
||||
|
||||
const row = evt.target.closest('.row');
|
||||
|
||||
for (let input of row.querySelectorAll(DESTROY_INPUT_SELECTOR)) {
|
||||
input.disabled = false;
|
||||
input.value = true;
|
||||
}
|
||||
for (let champ of row.querySelectorAll(CHAMP_SELECTOR)) {
|
||||
champ.remove();
|
||||
}
|
||||
|
||||
evt.target.remove();
|
||||
row.classList.remove('row');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue