Skip to content

Commit fcab6e7

Browse files
authored
Rename on***Fn (#17)
1 parent fd9c380 commit fcab6e7

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ a2lix_lib.sfCollection.init({
4141
class: 'btn btn-primary btn-sm mt-2',
4242
label: 'Add',
4343
customFn: null,
44-
onBeforeAddFn: null,
45-
onAfterAddFn: null
44+
onBeforeFn: null,
45+
onAfterFn: null
4646
},
4747
remove: {
4848
prototype:
4949
'<button class="__class__" data-entry-action="remove">__label__</button>',
5050
class: 'btn btn-danger btn-sm',
5151
label: 'Remove',
5252
customFn: null,
53-
onAfterRemoveFn: null
53+
onAfterFn: null
5454
}
5555
}
5656
})
@@ -80,13 +80,13 @@ a2lix_lib.sfCollection.init({
8080
add: {
8181
label: 'Ajouter',
8282
// customFn: (...args) => console.log('add', args),
83-
// onBeforeAddFn: (...args) => console.log('add', args),
84-
// onAfterAddFn: (...args) => console.log('add', args),
83+
// onBeforeFn: (...args) => console.log('add', args),
84+
// onAfterFn: (...args) => console.log('add', args),
8585
},
8686
remove: {
8787
label: 'Supprimer',
8888
// customFn: (...args) => console.log('remove', args),
89-
// onAfterRemoveFn: (...args) => console.log('remove', args),
89+
// onAfterFn: (...args) => console.log('remove', args),
9090
}
9191
}
9292
})

dist/a2lix_sf_collection.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@a2lix/symfony-collection",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Manage your Symfony Form collection simply with vanilla JS",
55
"main": "src/a2lix_sf_collection.js",
66
"repository": {

src/a2lix_sf_collection.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ a2lix_lib.sfCollection = (() => {
1313
class: 'btn btn-primary btn-sm mt-2',
1414
label: 'Add',
1515
customFn: null,
16-
onBeforeAddFn: null,
17-
onAfterAddFn: null
16+
onBeforeFn: null,
17+
onAfterFn: null
1818
},
1919
remove: {
2020
prototype:
2121
'<button class="__class__" data-entry-action="remove">__label__</button>',
2222
class: 'btn btn-danger btn-sm',
2323
label: 'Remove',
2424
customFn: null,
25-
onAfterRemoveFn: null
25+
onAfterFn: null
2626
}
2727
}
2828
}
@@ -166,25 +166,17 @@ a2lix_lib.sfCollection = (() => {
166166
}
167167

168168
const addEntry = (collectionElt, entryAddElt, templateContentEntry, cfg) => {
169-
cfg.entry.add.onBeforeAddFn?.(
170-
collectionElt,
171-
entryAddElt,
172-
templateContentEntry
173-
)
169+
cfg.entry.add.onBeforeFn?.(collectionElt, entryAddElt, templateContentEntry)
174170

175171
entryAddElt.parentElement.insertBefore(templateContentEntry, entryAddElt)
176172

177-
cfg.entry.add.onAfterAddFn?.(
178-
collectionElt,
179-
entryAddElt,
180-
templateContentEntry
181-
)
173+
cfg.entry.add.onAfterFn?.(collectionElt, entryAddElt, templateContentEntry)
182174
}
183175

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

187-
cfg.entry.remove.onAfterRemoveFn?.(collectionElt, entryRemoveElt)
179+
cfg.entry.remove.onAfterFn?.(collectionElt, entryRemoveElt)
188180
}
189181

190182
/**

0 commit comments

Comments
 (0)