Skip to content

Commit 5e02037

Browse files
committed
gpfup-count-files-groups.js: Added snippet to count files in groups.
1 parent 68c80f2 commit 5e02037

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gp-file-upload-pro/gpfup-count-files-groups.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ Object.entries(countMapping).forEach(([countFieldID, uploadFieldIDs]) => {
3030
});
3131

3232
// Function to update all relevant count fields
33-
function updateAllCountFields() {
34-
Object.entries(countMapping).forEach(([countFieldID, uploadFieldIDs]) => {
33+
function updateCountFields(countFieldIDs = Object.keys(countMapping)) {
34+
countFieldIDs.forEach((countFieldID) => {
35+
const uploadFieldIDs = countMapping[countFieldID];
3536
const total = uploadFieldIDs.reduce((sum, uploadFieldID) => {
3637
const key = 'GPFUP_' + formId + '_' + uploadFieldID;
3738
const store = window[key]?.$store;
@@ -56,12 +57,12 @@ if (gpfupInstances.length) {
5657
if (uploadToCountMap[fieldID]) {
5758
store.subscribe((mutation, state) => {
5859
if (mutation.type === 'SET_FILES') {
59-
updateAllCountFields();
60+
updateCountFields(uploadToCountMap[fieldID]);
6061
}
6162
});
6263
}
6364
});
6465
}
6566

66-
// Initial count on load
67-
updateAllCountFields();
67+
// Initial count on load for all fields
68+
updateCountFields();

0 commit comments

Comments
 (0)