sr-npm 1.7.572 → 1.7.573
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +138 -0
- package/pages/careersPage.js +7 -3
- package/pages/index.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
async function careersMultiBoxesPageOnReady(_$w) {
|
|
5
|
+
// await loadJobs(_$w);
|
|
6
|
+
// await loadFilters(_$w);
|
|
7
|
+
console.log("careersMultiBoxesPageOnReady");
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function loadJobs(_$w) {
|
|
12
|
+
_$w('#jobsReapter').onItemReady(($item, itemData) => {
|
|
13
|
+
$item('#jobTitle').text = itemData.title || '';
|
|
14
|
+
$item('#locationLabel').text=itemData.location.fullLocation
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return wixData.query(COLLECTIONS.JOBS)
|
|
18
|
+
.find()
|
|
19
|
+
.then((res) => {
|
|
20
|
+
$w('#jobsReapter').data = res.items;
|
|
21
|
+
})
|
|
22
|
+
.catch((err) => {
|
|
23
|
+
console.error('Failed to load jobs:', err);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function loadFilters() {
|
|
28
|
+
try {
|
|
29
|
+
|
|
30
|
+
// 1) Load all categories (fields)
|
|
31
|
+
const fields = await getAllRecords(CUSTOM_FIELDS_COLLECTION);
|
|
32
|
+
$w(FILTER_REPEATER_ID).data = fields;
|
|
33
|
+
|
|
34
|
+
// 2) Load all values once and group them by referenced field
|
|
35
|
+
const values = await getAllRecords(CUSTOM_VALUES_COLLECTION);
|
|
36
|
+
const valuesByFieldId = groupValuesByField(values, VALUES_REF_FIELD_KEY);
|
|
37
|
+
valuesByFieldIdGlobal = valuesByFieldId; // store globally
|
|
38
|
+
|
|
39
|
+
// Simple debounce helper so we don't re-render on every keystroke
|
|
40
|
+
const debounce = (fn, ms = 150) => {
|
|
41
|
+
let t;
|
|
42
|
+
return (...args) => {
|
|
43
|
+
clearTimeout(t);
|
|
44
|
+
t = setTimeout(() => fn(...args), ms);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// 3) Bind each filter repeater item
|
|
49
|
+
$w(FILTER_REPEATER_ID).onItemReady(async ($item, itemData) => {
|
|
50
|
+
$item(FILTER_LABEL_ID).onClick(()=>{
|
|
51
|
+
$item('#FilterCheckBoxContainer').collapsed ? $item('#FilterCheckBoxContainer').expand() : $item('#FilterCheckBoxContainer').collapse()
|
|
52
|
+
})
|
|
53
|
+
const fieldId = itemData._id;
|
|
54
|
+
|
|
55
|
+
// Set the filter label (category name)
|
|
56
|
+
// Use the correct field from CustomFields for the label (e.g., title/name/label)
|
|
57
|
+
const label = itemData.title || itemData.name || itemData.label || 'Filter';
|
|
58
|
+
$item(FILTER_LABEL_ID).placeholder = label;
|
|
59
|
+
|
|
60
|
+
// Build CheckboxGroup options for this field
|
|
61
|
+
const fieldValues = valuesByFieldId.get(fieldId) || [];
|
|
62
|
+
console.log("fieldValues : ",fieldValues)
|
|
63
|
+
const originalOptions = fieldValues.map(v => ({
|
|
64
|
+
label: v.title ,
|
|
65
|
+
value: v._id
|
|
66
|
+
}));
|
|
67
|
+
console.log("options: ",originalOptions)
|
|
68
|
+
optionsByFieldId.set(fieldId, originalOptions);
|
|
69
|
+
const counter={}
|
|
70
|
+
for (const val of fieldValues) {
|
|
71
|
+
const result=await wixData.queryReferenced('CustomValues', val, 'multiRefJobsCustomValues')
|
|
72
|
+
console.log("result: ",result)
|
|
73
|
+
counter[val.title]=result._totalCount
|
|
74
|
+
}
|
|
75
|
+
console.log("counter: ",counter)
|
|
76
|
+
countsByFieldId.set(fieldId, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
77
|
+
|
|
78
|
+
// Initialize UI
|
|
79
|
+
updateOptionsUI($item, fieldId, ''); // no search query
|
|
80
|
+
|
|
81
|
+
//$item(CHECKBOX_GROUP_ID).options = originalOptions;
|
|
82
|
+
$item(CHECKBOX_GROUP_ID).selectedIndices = []; // start empty
|
|
83
|
+
$item(CHECKBOX_GROUP_ID).onChange((ev) => {
|
|
84
|
+
const selected = ev.target.value; // array of selected value IDs
|
|
85
|
+
if (selected && selected.length) {
|
|
86
|
+
selectedByField.set(fieldId, selected);
|
|
87
|
+
} else {
|
|
88
|
+
selectedByField.delete(fieldId);
|
|
89
|
+
}
|
|
90
|
+
applyJobFilters(); // re-query jobs
|
|
91
|
+
refreshFacetCounts(); // recompute and update counts in all lists
|
|
92
|
+
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
// $item(FILTER_LABEL_ID).onInput(() => {
|
|
97
|
+
// const query = ($item(FILTER_LABEL_ID).value || '').toLowerCase().trim();
|
|
98
|
+
// const base = optionsByFieldId.get(fieldId) || [];
|
|
99
|
+
// const filtered = query
|
|
100
|
+
// ? base.filter(o => (o.label || '').toLowerCase().includes(query))
|
|
101
|
+
// : base.slice();
|
|
102
|
+
|
|
103
|
+
// // Preserve selections that are still visible
|
|
104
|
+
// const prevSelected = $item(CHECKBOX_GROUP_ID).value || [];
|
|
105
|
+
// const visibleValues = new Set(filtered.map(o => o.value));
|
|
106
|
+
// const preserved = prevSelected.filter(v => visibleValues.has(v));
|
|
107
|
+
|
|
108
|
+
// $item(CHECKBOX_GROUP_ID).options = filtered;
|
|
109
|
+
// $item(CHECKBOX_GROUP_ID).value = preserved; // do NOT call applyJobFilters here
|
|
110
|
+
// });
|
|
111
|
+
|
|
112
|
+
// Input typing -> only filter this list’s visible options (no Jobs query)
|
|
113
|
+
const runFilter = debounce(() => {
|
|
114
|
+
const query = ($item(FILTER_LABEL_ID).value || '').toLowerCase().trim();
|
|
115
|
+
updateOptionsUI($item, fieldId, query);
|
|
116
|
+
}, 150);
|
|
117
|
+
$item(FILTER_LABEL_ID).onInput(runFilter);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await refreshFacetCounts();
|
|
121
|
+
// After counts are ready, re-render all items to show numbers
|
|
122
|
+
$w(FILTER_REPEATER_ID).forEachItem(($item, itemData) => {
|
|
123
|
+
const query = ($item(FILTER_LABEL_ID).value || '').toLowerCase().trim();
|
|
124
|
+
updateOptionsUI($item, itemData._id, query);
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
});
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error('Failed to load filters:', err);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
module.exports = {
|
|
137
|
+
careersMultiBoxesPageOnReady
|
|
138
|
+
};
|
package/pages/careersPage.js
CHANGED
|
@@ -4,7 +4,7 @@ const { window } = require('@wix/site-window');
|
|
|
4
4
|
const { query,queryParams,onChange} = require("wix-location-frontend");
|
|
5
5
|
const { location } = require("@wix/site-location");
|
|
6
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
7
|
-
|
|
7
|
+
const { careersMultiBoxesPageOnReady } = require('./careersMultiBoxesPage');
|
|
8
8
|
const {
|
|
9
9
|
debounce,
|
|
10
10
|
getFilter,
|
|
@@ -30,6 +30,10 @@ if(siteconfig===undefined) {
|
|
|
30
30
|
const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
31
31
|
siteconfig = queryResult.items[0];
|
|
32
32
|
}
|
|
33
|
+
if(siteconfig.customFields==="true") {
|
|
34
|
+
await careersMultiBoxesPageOnReady(_$w);
|
|
35
|
+
}
|
|
36
|
+
else{
|
|
33
37
|
console.log("queryParams: ", queryParams);
|
|
34
38
|
const { page, keyWord, department, location,jobType,brand } = queryParams;
|
|
35
39
|
queryPageVar=page;
|
|
@@ -46,7 +50,7 @@ await init(_$w);
|
|
|
46
50
|
await handleBrandDropdown(_$w);
|
|
47
51
|
await handleUrlParams(_$w);
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
|
|
@@ -510,7 +514,7 @@ async function handleBrandDropdown(_$w){
|
|
|
510
514
|
console.log("showing brand dropdown");
|
|
511
515
|
_$w('#dropdownBrand').show();
|
|
512
516
|
}
|
|
513
|
-
}
|
|
517
|
+
}
|
|
514
518
|
module.exports = {
|
|
515
519
|
careersPageOnReady,
|
|
516
520
|
};
|