sr-npm 1.7.565 → 1.7.566
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 +6 -0
- package/backend/data.js +20 -9
- package/package.json +1 -1
- package/pages/careersPage.js +24 -16
|
@@ -7,6 +7,8 @@ const COLLECTIONS = {
|
|
|
7
7
|
BRANDS: 'Brands',
|
|
8
8
|
CUSTOM_VALUES:'CustomValues',
|
|
9
9
|
CUSTOM_FIELDS:'CustomFields',
|
|
10
|
+
SITE_CONFIGS: 'SiteConfigs',
|
|
11
|
+
|
|
10
12
|
}
|
|
11
13
|
const JOBS_COLLECTION_FIELDS = {
|
|
12
14
|
LOCATION: 'location',
|
|
@@ -86,6 +88,10 @@ const COLLECTIONS_FIELDS = {
|
|
|
86
88
|
TEMPLATE_TYPE: [
|
|
87
89
|
{key:'templateType', type: 'TEXT'},
|
|
88
90
|
],
|
|
91
|
+
SITE_CONFIGS: [
|
|
92
|
+
{key:'urlParams', type: 'TEXT'},
|
|
93
|
+
{key:'customFields', type: 'TEXT'},
|
|
94
|
+
],
|
|
89
95
|
SECRET_MANAGER_MIRROR: [
|
|
90
96
|
{key:'tokenName', type: 'TEXT'},
|
|
91
97
|
{key:'value', type: 'TEXT'},
|
package/backend/data.js
CHANGED
|
@@ -9,11 +9,16 @@ const { retrieveSecretVal, getTokenFromCMS } = require('./secretsData');
|
|
|
9
9
|
|
|
10
10
|
let jobToCustomValues = {}
|
|
11
11
|
let customValuesToJobs = {}
|
|
12
|
+
let siteconfig;
|
|
12
13
|
|
|
13
14
|
function getBrand(customField) {
|
|
14
15
|
return customField.find(field => field.fieldLabel === 'Brands')?.valueLabel;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
async function getSiteConfig() {
|
|
19
|
+
const queryresult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
20
|
+
siteconfig = queryresult.items[0];
|
|
21
|
+
}
|
|
17
22
|
function validatePosition(position) {
|
|
18
23
|
if (!position.id) {
|
|
19
24
|
throw new Error('Position id is required');
|
|
@@ -113,9 +118,13 @@ async function saveJobsDataToCMS() {
|
|
|
113
118
|
getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
|
|
114
119
|
return basicJob;
|
|
115
120
|
});
|
|
116
|
-
|
|
121
|
+
if(siteconfig===undefined) {
|
|
122
|
+
siteconfig = await getSiteConfig();
|
|
123
|
+
}
|
|
124
|
+
if (siteconfig.customFields==="true") {
|
|
117
125
|
await populateCustomFieldsCollection(customFieldsLabels);
|
|
118
126
|
await populateCustomValuesCollection(customFieldsValues);
|
|
127
|
+
}
|
|
119
128
|
// Sort jobs by title (ascending, case-insensitive, numeric-aware)
|
|
120
129
|
jobsData.sort((a, b) => {
|
|
121
130
|
const titleA = a.title || '';
|
|
@@ -189,15 +198,15 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
|
189
198
|
|
|
190
199
|
try {
|
|
191
200
|
let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
if (siteconfig.customFields==="true") {
|
|
202
|
+
let customValues=await getAllCustomValues();
|
|
203
|
+
console.log("inserting jobs references to custom values collection");
|
|
204
|
+
for (const value of customValues.items) {
|
|
205
|
+
await insertJobsReference(value._id);
|
|
206
|
+
}
|
|
207
|
+
console.log("inserted jobs references to custom values collection successfully");
|
|
197
208
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
209
|
+
|
|
201
210
|
let totalUpdated = 0;
|
|
202
211
|
let totalFailed = 0;
|
|
203
212
|
let totalProcessed = 0;
|
|
@@ -235,7 +244,9 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
|
235
244
|
referFriendLink: referFriendLink,
|
|
236
245
|
};
|
|
237
246
|
await wixData.update(COLLECTIONS.JOBS, updatedJob);
|
|
247
|
+
if (siteconfig.customFields==="true") {
|
|
238
248
|
await insertValuesReference(job._id);
|
|
249
|
+
}
|
|
239
250
|
return { success: true, jobId: job._id, title: job.title };
|
|
240
251
|
} catch (error) {
|
|
241
252
|
console.error(` ❌ Failed to update ${job.title} (${job._id}):`, error);
|
package/package.json
CHANGED
package/pages/careersPage.js
CHANGED
|
@@ -23,8 +23,13 @@ const {
|
|
|
23
23
|
let queryJobTypeVar;
|
|
24
24
|
let queryBrandVar;
|
|
25
25
|
let searchInputBlurredFirstTime=true;
|
|
26
|
-
let
|
|
26
|
+
let siteconfig;
|
|
27
|
+
|
|
27
28
|
async function careersPageOnReady(_$w,thisObject,queryParams) {
|
|
29
|
+
if(siteconfig===undefined) {
|
|
30
|
+
siteconfig = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
31
|
+
siteconfig = siteconfig.items[0];
|
|
32
|
+
}
|
|
28
33
|
console.log("queryParams: ", queryParams);
|
|
29
34
|
const { page, keyWord, department, location,jobType,brand } = queryParams;
|
|
30
35
|
queryPageVar=page;
|
|
@@ -96,21 +101,24 @@ async function handleUrlParams(_$w) {
|
|
|
96
101
|
if (queryKeyWordVar) {
|
|
97
102
|
await handleKeyWordParam(_$w,queryKeyWordVar);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
|
|
105
|
+
if (siteconfig.handleCareersUrlParams==="true") { // it is something else that is not TWG
|
|
106
|
+
if (queryPageVar) {
|
|
107
|
+
await handlePageParam(_$w);
|
|
108
|
+
}
|
|
109
|
+
if (queryDepartmentVar) {
|
|
110
|
+
await handleDepartmentParam(_$w,queryDepartmentVar);
|
|
111
|
+
}
|
|
112
|
+
if (queryLocationVar) {
|
|
113
|
+
await handleLocationParam(_$w,queryLocationVar);
|
|
114
|
+
}
|
|
115
|
+
if (queryJobTypeVar) {
|
|
116
|
+
await handleJobTypeParam(_$w,queryJobTypeVar);
|
|
117
|
+
}
|
|
118
|
+
if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
|
|
119
|
+
await handleBrandParam(_$w,queryBrandVar);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
114
122
|
await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
|
|
115
123
|
}
|
|
116
124
|
|