-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bulk create quotas redo without validityperiodform
- Loading branch information
Showing
5 changed files
with
234 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const addNewForm = (event) => { | ||
event.preventDefault(); | ||
|
||
let numForms = document.querySelectorAll(".quota-definition-row").length; | ||
let fieldset = document.querySelector(".quota-definition-row"); | ||
let formset = fieldset.parentNode; | ||
let newForm = fieldset.cloneNode(true); | ||
|
||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="volume_0"', 'name="volume_' + numForms + '"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="start_date_0_0"', 'name="start_date_' + numForms + '_0"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="start_date_0_1"', 'name="start_date_' + numForms + '_1"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="start_date_0_2"', 'name="start_date_' + numForms + '_2"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="end_date_0_0"', 'name="end_date_' + numForms + '_0"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="end_date_0_1"', 'name="end_date_' + numForms + '_1"'); | ||
newForm.innerHTML = newForm.innerHTML.replaceAll('name="end_date_0_2"', 'name="end_date_' + numForms + '_2"'); | ||
|
||
let formFields = newForm.querySelectorAll("input"); | ||
for (let field of formFields.values()) { | ||
field.value = ""; | ||
} | ||
|
||
let submitButton = document.getElementById("submit-id-submit"); | ||
formset.insertBefore(newForm, submitButton); | ||
|
||
let addNewButton = document.querySelector("#add-new-definition"); | ||
addNewButton.scrollIntoView(false); | ||
} | ||
|
||
const initAddNewDefinition = () => { | ||
const btn = document.querySelector("#add-new-definition"); | ||
|
||
if (btn) { | ||
btn.addEventListener("click", addNewForm); | ||
} | ||
} | ||
|
||
export { initAddNewDefinition } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.