sr-npm 1.7.520 → 1.7.525
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/backend/collectionConsts.js +2 -0
- package/backend/data.js +4 -4
- package/backend/queries.js +9 -0
- package/package.json +1 -1
- package/pages/careersPage.js +20 -9
|
@@ -23,6 +23,7 @@ const JOBS_COLLECTION_FIELDS = {
|
|
|
23
23
|
REFER_FRIEND_LINK: 'referFriendLink',
|
|
24
24
|
BRAND: 'brand',
|
|
25
25
|
BRAND_REF: 'brandRef',
|
|
26
|
+
CUSTOM_FIELDS:'customFields',
|
|
26
27
|
}
|
|
27
28
|
const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
|
|
28
29
|
TITLE: 'title',
|
|
@@ -69,6 +70,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
69
70
|
{key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT } } },
|
|
70
71
|
{key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CITIES } } },
|
|
71
72
|
{key:'brandRef', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.BRANDS } } },
|
|
73
|
+
{ key: 'customFields', type: 'ARRAY' },
|
|
72
74
|
{ key: 'image', type: 'IMAGE' },
|
|
73
75
|
],
|
|
74
76
|
TEMPLATE_TYPE: [
|
package/backend/data.js
CHANGED
|
@@ -56,12 +56,12 @@ function addCustomFields(basicJob, position) {
|
|
|
56
56
|
const customFieldsArray = Array.isArray(position?.customField) ? position.customField : [];
|
|
57
57
|
const customFields = {};
|
|
58
58
|
for (const field of customFieldsArray) {
|
|
59
|
-
const label = field.fieldLabel
|
|
59
|
+
const label = field.fieldLabel==="Brands" ? "brand" : field.fieldLabel
|
|
60
60
|
const key = normalizeString(label);
|
|
61
61
|
const value = field.valueLabel
|
|
62
62
|
customFields[key] = value;
|
|
63
63
|
}
|
|
64
|
-
return { ...basicJob, customFields };
|
|
64
|
+
return { ...basicJob, ...customFields,customFieldsNames:Object.keys(customFields) };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
async function saveJobsDataToCMS() {
|
|
@@ -92,8 +92,8 @@ async function saveJobsDataToCMS() {
|
|
|
92
92
|
// brand: getBrand(position.customField),
|
|
93
93
|
jobDescription: null, // Will be filled later
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
return basicJob
|
|
95
|
+
|
|
96
|
+
return addCustomFields(basicJob,position)
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// Sort jobs by title (ascending, case-insensitive, numeric-aware)
|
package/backend/queries.js
CHANGED
|
@@ -18,7 +18,16 @@ async function getPositionsByField(field, value) {
|
|
|
18
18
|
.then(result => result.items);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
async function getCutomFieldKeys() {
|
|
22
|
+
return wixData
|
|
23
|
+
.query(COLLECTIONS.JOBS)
|
|
24
|
+
.limit(1)
|
|
25
|
+
.find()
|
|
26
|
+
.then(result => result.items.customFieldsNames);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
module.exports = {
|
|
22
30
|
getAllPositions,
|
|
23
31
|
getPositionsByField,
|
|
32
|
+
getCutomFieldKeys
|
|
24
33
|
};
|
package/package.json
CHANGED
package/pages/careersPage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getAllPositions } = require('../backend/queries');
|
|
1
|
+
const { getAllPositions,getCutomFieldKeys } = require('../backend/queries');
|
|
2
2
|
const {wixData} = require('wix-data');
|
|
3
3
|
const { window } = require('@wix/site-window');
|
|
4
4
|
const { query,queryParams,onChange} = require("wix-location-frontend");
|
|
@@ -22,17 +22,12 @@ const {
|
|
|
22
22
|
let queryLocationVar;
|
|
23
23
|
let queryJobTypeVar;
|
|
24
24
|
let queryBrandVar;
|
|
25
|
+
let queryCustomFields;
|
|
25
26
|
let searchInputBlurredFirstTime=true;
|
|
26
27
|
let deletedParam=false;
|
|
27
28
|
async function careersPageOnReady(_$w,thisObject,queryParams) {
|
|
28
29
|
console.log("queryParams: ", queryParams);
|
|
29
|
-
|
|
30
|
-
queryPageVar=page;
|
|
31
|
-
queryKeyWordVar=keyWord;
|
|
32
|
-
queryDepartmentVar=department;
|
|
33
|
-
queryLocationVar=location;
|
|
34
|
-
queryJobTypeVar=jobType;
|
|
35
|
-
queryBrandVar=brand;
|
|
30
|
+
await retrieveQueryParams(queryParams);
|
|
36
31
|
thisObjectVar=thisObject;
|
|
37
32
|
allJobs=await getAllPositions();
|
|
38
33
|
await activateAutoLoad(_$w);
|
|
@@ -44,7 +39,23 @@ await handleUrlParams(_$w);
|
|
|
44
39
|
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
|
|
42
|
+
async function retrieveQueryParams(queryParams){
|
|
43
|
+
const { page, keyWord, department, location,jobType,brand } = queryParams;
|
|
44
|
+
queryPageVar=page;
|
|
45
|
+
queryKeyWordVar=keyWord;
|
|
46
|
+
queryDepartmentVar=department;
|
|
47
|
+
queryLocationVar=location;
|
|
48
|
+
queryJobTypeVar=jobType;
|
|
49
|
+
queryBrandVar=brand;
|
|
50
|
+
const customFieldKeys=await getCutomFieldKeys()
|
|
51
|
+
console.log(customFieldKeys)
|
|
52
|
+
for(const customFieldKey of customFieldKeys)
|
|
53
|
+
{
|
|
54
|
+
queryCustomFields[customFieldKey]=queryParams[customFieldKey]
|
|
55
|
+
}
|
|
56
|
+
console.log("queryCustomFields",queryCustomFields)
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
function activateAutoLoad(_$w)
|
|
49
60
|
{
|
|
50
61
|
_$w("#jobsDataset").onReady(() => {
|