Skip to content

Commit

Permalink
Rename on***Fn (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
webda2l authored Aug 18, 2022
1 parent fd9c380 commit fcab6e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ a2lix_lib.sfCollection.init({
class: 'btn btn-primary btn-sm mt-2',
label: 'Add',
customFn: null,
onBeforeAddFn: null,
onAfterAddFn: null
onBeforeFn: null,
onAfterFn: null
},
remove: {
prototype:
'<button class="__class__" data-entry-action="remove">__label__</button>',
class: 'btn btn-danger btn-sm',
label: 'Remove',
customFn: null,
onAfterRemoveFn: null
onAfterFn: null
}
}
})
Expand Down Expand Up @@ -80,13 +80,13 @@ a2lix_lib.sfCollection.init({
add: {
label: 'Ajouter',
// customFn: (...args) => console.log('add', args),
// onBeforeAddFn: (...args) => console.log('add', args),
// onAfterAddFn: (...args) => console.log('add', args),
// onBeforeFn: (...args) => console.log('add', args),
// onAfterFn: (...args) => console.log('add', args),
},
remove: {
label: 'Supprimer',
// customFn: (...args) => console.log('remove', args),
// onAfterRemoveFn: (...args) => console.log('remove', args),
// onAfterFn: (...args) => console.log('remove', args),
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion dist/a2lix_sf_collection.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@a2lix/symfony-collection",
"version": "0.5.0",
"version": "0.5.1",
"description": "Manage your Symfony Form collection simply with vanilla JS",
"main": "src/a2lix_sf_collection.js",
"repository": {
Expand Down
20 changes: 6 additions & 14 deletions src/a2lix_sf_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ a2lix_lib.sfCollection = (() => {
class: 'btn btn-primary btn-sm mt-2',
label: 'Add',
customFn: null,
onBeforeAddFn: null,
onAfterAddFn: null
onBeforeFn: null,
onAfterFn: null
},
remove: {
prototype:
'<button class="__class__" data-entry-action="remove">__label__</button>',
class: 'btn btn-danger btn-sm',
label: 'Remove',
customFn: null,
onAfterRemoveFn: null
onAfterFn: null
}
}
}
Expand Down Expand Up @@ -166,25 +166,17 @@ a2lix_lib.sfCollection = (() => {
}

const addEntry = (collectionElt, entryAddElt, templateContentEntry, cfg) => {
cfg.entry.add.onBeforeAddFn?.(
collectionElt,
entryAddElt,
templateContentEntry
)
cfg.entry.add.onBeforeFn?.(collectionElt, entryAddElt, templateContentEntry)

entryAddElt.parentElement.insertBefore(templateContentEntry, entryAddElt)

cfg.entry.add.onAfterAddFn?.(
collectionElt,
entryAddElt,
templateContentEntry
)
cfg.entry.add.onAfterFn?.(collectionElt, entryAddElt, templateContentEntry)
}

const removeEntry = (collectionElt, entryRemoveElt, cfg) => {
entryRemoveElt.parentElement.remove()

cfg.entry.remove.onAfterRemoveFn?.(collectionElt, entryRemoveElt)
cfg.entry.remove.onAfterFn?.(collectionElt, entryRemoveElt)
}

/**
Expand Down

0 comments on commit fcab6e7

Please sign in to comment.