Skip to content

Commit 28d6ad0

Browse files
committed
gpfup-count-files-groups.js: Added snippet to count files in groups.
1 parent a8200b0 commit 28d6ad0

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ var gpfupInstances = Object.keys(window).filter(function (key) {
1818
return key.startsWith('GPFUP_' + formId + '_');
1919
});
2020

21-
if (!gpfupInstances.length) {
22-
return;
23-
}
24-
2521
// Build reverse lookup: uploadFieldID => associated countFieldIDs
2622
var uploadToCountMap = {};
2723
Object.entries(countMapping).forEach(function ([countFieldID, uploadFieldIDs]) {
@@ -47,20 +43,22 @@ function updateAllCountFields() {
4743
});
4844
}
4945

50-
// Subscribe to relevant GPFUP fields
51-
gpfupInstances.forEach(function (key) {
52-
var parts = key.split('_');
53-
var fieldID = parseInt(parts[2]); // GPFUP_formId_fieldId
54-
var store = window[key].$store;
46+
if (gpfupInstances.length) {
47+
// Subscribe to relevant GPFUP fields
48+
gpfupInstances.forEach(function (key) {
49+
var parts = key.split('_');
50+
var fieldID = parseInt(parts[2]); // GPFUP_formId_fieldId
51+
var store = window[key].$store;
5552

56-
if (uploadToCountMap[fieldID]) {
57-
store.subscribe(function (mutation, state) {
58-
if (mutation.type === 'SET_FILES') {
59-
updateAllCountFields();
60-
}
61-
});
62-
}
63-
});
53+
if (uploadToCountMap[fieldID]) {
54+
store.subscribe(function (mutation, state) {
55+
if (mutation.type === 'SET_FILES') {
56+
updateAllCountFields();
57+
}
58+
});
59+
}
60+
});
61+
}
6462

6563
// Initial count on load
6664
updateAllCountFields();

0 commit comments

Comments
 (0)