(e1)
| 173 | }; |
| 174 | |
| 175 | const inlineDeleteHandler = function (e1) { |
| 176 | e1.preventDefault(); |
| 177 | const deleteButton = $(e1.target); |
| 178 | const row = deleteButton.closest("." + options.formCssClass); |
| 179 | const inlineGroup = row.closest(".inline-group"); |
| 180 | // Remove the parent form containing this button, |
| 181 | // and also remove the relevant row with non-field errors: |
| 182 | const prevRow = row.prev(); |
| 183 | if (prevRow.length && prevRow.hasClass("row-form-errors")) { |
| 184 | prevRow.remove(); |
| 185 | } |
| 186 | row.remove(); |
| 187 | nextIndex -= 1; |
| 188 | // Pass the deleted form to the post-delete callback, if provided. |
| 189 | if (options.removed) { |
| 190 | options.removed(row); |
| 191 | } |
| 192 | document.dispatchEvent( |
| 193 | new CustomEvent("formset:removed", { |
| 194 | detail: { |
| 195 | formsetName: options.prefix, |
| 196 | }, |
| 197 | }), |
| 198 | ); |
| 199 | // Update the TOTAL_FORMS form count. |
| 200 | const forms = $("." + options.formCssClass); |
| 201 | $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length); |
| 202 | // Show add button again once below maximum number. |
| 203 | if (maxForms.val() === "" || maxForms.val() - forms.length > 0) { |
| 204 | addButton.parent().show(); |
| 205 | } |
| 206 | // Hide the remove buttons if at min_num. |
| 207 | toggleDeleteButtonVisibility(inlineGroup); |
| 208 | // Also, update names and ids for all remaining form controls so |
| 209 | // they remain in sequence: |
| 210 | let i, formCount; |
| 211 | const updateElementCallback = function () { |
| 212 | updateElementIndex(this, options.prefix, i); |
| 213 | }; |
| 214 | for (i = 0, formCount = forms.length; i < formCount; i++) { |
| 215 | updateElementIndex($(forms).get(i), options.prefix, i); |
| 216 | $(forms.get(i)).find("*").each(updateElementCallback); |
| 217 | } |
| 218 | }; |
| 219 | |
| 220 | const toggleDeleteButtonVisibility = function (inlineGroup) { |
| 221 | if ( |
nothing calls this directly
no test coverage detected