sr-npm 1.7.668 → 1.7.670
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 +106 -63
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
await loadJobs(_$w);
|
|
28
|
-
|
|
28
|
+
await loadFilters(_$w);
|
|
29
29
|
//selected values repeater on item ready
|
|
30
30
|
//await loadSelectedValuesRepeater(_$w);
|
|
31
31
|
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).onItemReady(($item, itemData) => {
|
|
@@ -124,88 +124,130 @@ async function loadJobs(_$w) {
|
|
|
124
124
|
try {
|
|
125
125
|
// 1) Load all categories (fields)
|
|
126
126
|
let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
127
|
+
|
|
127
128
|
fields.push({_id:"Location",title:"Location"});
|
|
128
|
-
|
|
129
|
+
console.log("fields: ",fields)
|
|
130
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).data = fields;
|
|
129
131
|
const cities=await getAllRecords(COLLECTIONS.CITIES);
|
|
130
132
|
for(const city of cities) {
|
|
131
133
|
valueToJobs[city._id]=city.jobIds;
|
|
132
134
|
}
|
|
133
135
|
// 2) Load all values once and group them by referenced field
|
|
134
|
-
|
|
136
|
+
let found=false;
|
|
135
137
|
let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
|
|
136
138
|
valuesByFieldId.set("Location",cities)
|
|
137
139
|
valuesByFieldIdGlobal = valuesByFieldId; // store globally
|
|
140
|
+
console.log("valuesByFieldId: ",valuesByFieldId)
|
|
141
|
+
|
|
142
|
+
for(const elemenet of Object.keys(valuesByFieldId)) {
|
|
143
|
+
for(const field of fields) {
|
|
144
|
+
if(field._id===elemenet && field.title==="Category") {
|
|
145
|
+
updateOptionsUI(_$w,field.title, field._id, ''); // no search query
|
|
146
|
+
console.log("field: ",field)
|
|
147
|
+
console.log("elemenet: ",elemenet)
|
|
148
|
+
console.log("valuesByFieldId.get(elemenet): ",valuesByFieldId.get(elemenet))
|
|
149
|
+
//_$w("#CategoryCheckBox").options = valuesByFieldId.get(elemenet);
|
|
150
|
+
_$w(`${field.title}CheckBox`).onChange(async (ev) => {
|
|
151
|
+
dontUpdateThisCheckBox=field._id;
|
|
152
|
+
const selected = ev.target.value; // array of selected value IDs
|
|
153
|
+
if (selected && selected.length) {
|
|
154
|
+
selectedByField.set(field._id, selected);
|
|
155
|
+
} else {
|
|
156
|
+
selectedByField.delete(field._id);
|
|
157
|
+
}
|
|
158
|
+
await applyJobFilters(_$w,field._id); // re-query jobs
|
|
159
|
+
// await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
160
|
+
// await updateSelectedValuesRepeater(_$w);
|
|
161
|
+
updateTotalJobsCountText(_$w);
|
|
162
|
+
});
|
|
163
|
+
const runFilter = debounce(() => {
|
|
164
|
+
const query = (_$w(`${field.title}input`).value || '').toLowerCase().trim();
|
|
165
|
+
updateOptionsUI(_$w, field.title, field._id, query);
|
|
166
|
+
}, 150);
|
|
167
|
+
_$w(`${field.title}input`).onInput(runFilter);
|
|
168
|
+
found=true;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if(found) {
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//
|
|
178
|
+
|
|
179
|
+
|
|
138
180
|
|
|
139
181
|
|
|
140
182
|
// 3) Bind each filter repeater item
|
|
141
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).onItemReady(async ($item, itemData) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).onItemReady(async ($item, itemData) => {
|
|
184
|
+
// // $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onClick(()=>{
|
|
185
|
+
// // $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).collapsed ? $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).expand() : $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).collapse()
|
|
186
|
+
// // })
|
|
187
|
+
// const fieldId = itemData._id;
|
|
146
188
|
|
|
147
|
-
|
|
148
|
-
|
|
189
|
+
// // Set the filter label (category name)
|
|
190
|
+
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).placeholder = itemData.title
|
|
149
191
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
192
|
+
// // Build CheckboxGroup options for this field
|
|
193
|
+
// const fieldValues = valuesByFieldId.get(fieldId) || [];
|
|
194
|
+
// let originalOptions=[];
|
|
195
|
+
// if(fieldId==="Location") {
|
|
196
|
+
// originalOptions=fieldValues.map(city=>({
|
|
197
|
+
// label: city.city,
|
|
198
|
+
// value: city._id
|
|
199
|
+
// }));
|
|
200
|
+
// }
|
|
201
|
+
// else{
|
|
202
|
+
// originalOptions=fieldValues
|
|
203
|
+
// }
|
|
162
204
|
|
|
163
|
-
|
|
164
|
-
|
|
205
|
+
// optionsByFieldId.set(fieldId, originalOptions);
|
|
206
|
+
// const counter={}
|
|
165
207
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
208
|
+
// for (const val of allvaluesobjects) {
|
|
209
|
+
// counter[val.title]=val.totalJobs
|
|
210
|
+
// }
|
|
211
|
+
// for(const city of cities) {
|
|
212
|
+
// counter[city.city]=city.count
|
|
213
|
+
// }
|
|
172
214
|
|
|
173
|
-
|
|
215
|
+
// countsByFieldId.set(fieldId, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
174
216
|
|
|
175
|
-
|
|
176
|
-
|
|
217
|
+
// // Initialize UI
|
|
218
|
+
// updateOptionsUI($item, fieldId, ''); // no search query
|
|
177
219
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
220
|
+
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).selectedIndices = []; // start empty
|
|
221
|
+
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).onChange(async (ev) => {
|
|
222
|
+
// dontUpdateThisCheckBox=fieldId;
|
|
223
|
+
// const selected = ev.target.value; // array of selected value IDs
|
|
224
|
+
// if (selected && selected.length) {
|
|
225
|
+
// selectedByField.set(fieldId, selected);
|
|
226
|
+
// } else {
|
|
227
|
+
// selectedByField.delete(fieldId);
|
|
228
|
+
// }
|
|
229
|
+
// await applyJobFilters(_$w,fieldId); // re-query jobs
|
|
230
|
+
// await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
231
|
+
// await updateSelectedValuesRepeater(_$w);
|
|
232
|
+
// updateTotalJobsCountText(_$w);
|
|
233
|
+
// });
|
|
192
234
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
235
|
+
// // Input typing -> only filter this list’s visible options (no Jobs query)
|
|
236
|
+
// const runFilter = debounce(() => {
|
|
237
|
+
// const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
238
|
+
// updateOptionsUI($item, fieldId, query);
|
|
239
|
+
// }, 150);
|
|
240
|
+
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onInput(runFilter);
|
|
241
|
+
// });
|
|
200
242
|
|
|
201
|
-
await refreshFacetCounts(_$w);
|
|
243
|
+
//await refreshFacetCounts(_$w);
|
|
202
244
|
// After counts are ready, re-render all items to show numbers
|
|
203
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
204
|
-
|
|
205
|
-
|
|
245
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
246
|
+
// const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
247
|
+
// updateOptionsUI($item, itemData._id, query);
|
|
206
248
|
|
|
207
249
|
|
|
208
|
-
});
|
|
250
|
+
// });
|
|
209
251
|
} catch (err) {
|
|
210
252
|
console.error('Failed to load filters:', err);
|
|
211
253
|
}
|
|
@@ -235,7 +277,7 @@ async function loadJobs(_$w) {
|
|
|
235
277
|
};
|
|
236
278
|
};
|
|
237
279
|
|
|
238
|
-
function updateOptionsUI($
|
|
280
|
+
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery) {
|
|
239
281
|
let base = optionsByFieldId.get(fieldId) || [];
|
|
240
282
|
const countsMap = countsByFieldId.get(fieldId) || new Map();
|
|
241
283
|
if(dontUpdateThisCheckBox===fieldId)
|
|
@@ -265,12 +307,13 @@ async function loadJobs(_$w) {
|
|
|
265
307
|
: withCounts;
|
|
266
308
|
|
|
267
309
|
// Preserve currently selected values that are still visible
|
|
268
|
-
|
|
310
|
+
// const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
|
|
311
|
+
const prevSelected = _$w(`${fieldTitle}CheckBox`).value || [];
|
|
269
312
|
const visibleSet = new Set(filtered.map(o => o.value));
|
|
270
313
|
const preserved = prevSelected.filter(v => visibleSet.has(v));
|
|
271
314
|
|
|
272
|
-
$
|
|
273
|
-
$
|
|
315
|
+
_$w(`${fieldTitle}CheckBox`).options = filtered;
|
|
316
|
+
_$w(`${fieldTitle}CheckBox`).value = preserved;
|
|
274
317
|
|
|
275
318
|
}
|
|
276
319
|
|