Skip to content

Commit

Permalink
review fixes pt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bozatko committed Nov 6, 2024
1 parent 9914801 commit 94565f7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function (doc, ibexa) {
const sourceInputs = doc.querySelectorAll('[data-autogenerate-identifier-target-selector]');

const initAutogenerator = (elements, shouldAutogenerateValue = false) => {
const initAutogenerator = (elements, shouldAutogenerateValue) => {
elements.forEach((sourceInput) => {
const { autogenerateIdentifierTargetSelector } = sourceInput.dataset;
const targetInput = doc.querySelector(autogenerateIdentifierTargetSelector);
const identifierAutogenerator = new ibexa.core.SlugValueInputAutogenerator({
sourceInput,
targetInput,
shouldAutogenerateValue,
shouldAutogenerateValue: shouldAutogenerateValue || !targetInput.value,
});

identifierAutogenerator.init();
Expand All @@ -20,9 +20,9 @@
'ibexa-autogenerate-identifier:init',
(event) => {
const { fieldNode, shouldAutogenerateValue } = event.detail;
const sourceInputs = fieldNode.querySelectorAll('[data-autogenerate-identifier-target-selector]');
const sourceFields = fieldNode.querySelectorAll('[data-autogenerate-identifier-target-selector]');

initAutogenerator(sourceInputs, shouldAutogenerateValue);
initAutogenerator(sourceFields, shouldAutogenerateValue);
},
false,
);
Expand Down

0 comments on commit 94565f7

Please sign in to comment.