sr-npm 3.1.2 → 3.1.4

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.
@@ -14,6 +14,7 @@ const COLLECTIONS = {
14
14
  const JOBS_COLLECTION_FIELDS = {
15
15
  LOCATION: 'location',
16
16
  TITLE: 'title',
17
+ SLUG: 'slug',
17
18
  LOCATION_ADDRESS: 'locationAddress',
18
19
  COUNTRY: 'country',
19
20
  DEPARTMENT: 'department',
@@ -77,6 +78,7 @@ const COLLECTIONS_FIELDS = {
77
78
  JOBS: [
78
79
  {key:'location', type: 'OBJECT'},
79
80
  {key:'title', type: 'TEXT'},
81
+ {key:'slug', type: 'TEXT'},
80
82
  {key:'locationAddress', type: 'ADDRESS'},
81
83
  {key:'country', type: 'TEXT'},
82
84
  {key:'department', type: 'TEXT'},
package/backend/data.js CHANGED
@@ -1,10 +1,17 @@
1
1
  const { items: wixData } = require('@wix/data');
2
2
  const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
3
3
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
4
- const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME,CUSTOM_VALUES_COLLECTION_FIELDS } = require('./collectionConsts');
5
- const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeString} = require('./utils');
4
+
6
5
  const { getAllPositions } = require('./queries');
7
6
  const { retrieveSecretVal, getTokenFromCMS ,getApiKeys} = require('./secretsData');
7
+ const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME,CUSTOM_VALUES_COLLECTION_FIELDS } = require('./collectionConsts');
8
+ const { chunkedBulkOperation,
9
+ countJobsPerGivenField,
10
+ fillCityLocationAndLocationAddress,
11
+ prepareToSaveArray,
12
+ normalizeString,
13
+ generateSlug}
14
+ = require('./utils');
8
15
 
9
16
  let customValuesToJobs = {}
10
17
  let locationToJobs = {}
@@ -110,7 +117,7 @@ async function saveJobsDataToCMS() {
110
117
  const customFieldsLabels = {}
111
118
  const customFieldsValues = {}
112
119
 
113
- const {companyId,templateType} = await getApiKeys();
120
+ const {companyId ,templateType} = await getApiKeys();
114
121
  if(siteconfig===undefined) {
115
122
  await getSiteConfig();
116
123
  }
@@ -120,6 +127,7 @@ async function saveJobsDataToCMS() {
120
127
  const basicJob = {
121
128
  _id: position.id,
122
129
  title: position.name || '',
130
+ slug: generateSlug(position.name || ''),
123
131
  department: position.department?.label || 'Other',
124
132
  cityText: normalizeString(position.location?.city),
125
133
  location: position.location && Object.keys(position.location).length > 0
package/backend/utils.js CHANGED
@@ -65,6 +65,12 @@ function normalizeString(str) {
65
65
  .trim();
66
66
  }
67
67
 
68
+ function generateSlug(title){
69
+ return title
70
+ .replace(/[^a-zA-Z0-9-]+/g, "-") // allow uppercase AND lowercase letters
71
+ .replace(/-+/g, "-") // collapse multiple hyphens
72
+ .replace(/^-|-$/g, ""); // remove leading/trailing hyphens
73
+ }
68
74
 
69
75
 
70
76
  module.exports = {
@@ -74,5 +80,5 @@ module.exports = {
74
80
  fillCityLocationAndLocationAddress,
75
81
  prepareToSaveArray,
76
82
  normalizeString,
77
-
83
+ generateSlug,
78
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/pages/homePage.js CHANGED
@@ -15,13 +15,16 @@ async function homePageOnReady(_$w,thisObject=null) {
15
15
 
16
16
  const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
17
17
  const siteconfig = queryResult.items[0];
18
- if(siteconfig.categorySearch==="true") {
18
+ if(siteconfig.twg) {
19
19
  const allJobs=await getAllRecords(COLLECTIONS.JOBS);
20
20
  const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
21
21
  bindPrimarySearch(_$w,allvaluesobjects,allJobs);
22
22
  loadPrimarySearchRepeater(_$w)
23
+ console.log("siteconfig.twg: ",siteconfig.twg);
24
+ if(siteconfig.twg==="external") {
23
25
  bindTeamRepeater(_$w)
24
26
  bindViewAllButton(_$w)
27
+ }
25
28
  }
26
29
  else{
27
30
 
@@ -93,9 +93,17 @@ function loadPrimarySearchRepeater(_$w) {
93
93
  (item) => item._id === event.context.itemId,
94
94
 
95
95
  );
96
- console.log("clickedItemData: ",clickedItemData);
97
- console.log("clickedItemData['link-jobs-title']: ",clickedItemData["link-jobs-title"]);
98
- location.to(clickedItemData["link-jobs-title"]);
96
+ // 'link-jobs-title' or 'link-copy-of-jobs-title'
97
+ const linkKey = Object.keys(clickedItemData).find(
98
+ key => key.startsWith('link') && key.includes('jobs') && key.includes('title')
99
+ );
100
+ if (linkKey && clickedItemData[linkKey] ) {
101
+ if(clickedItemData[linkKey].includes("copy-of-jobs")) {
102
+ clickedItemData[linkKey]=clickedItemData[linkKey].replace("copy-of-jobs","jobs")
103
+ }
104
+ location.to(clickedItemData[linkKey]);
105
+ }
106
+
99
107
  });
100
108
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
101
109
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
@@ -13,7 +13,7 @@ const {
13
13
 
14
14
 
15
15
  async function positionPageOnReady(_$w) {
16
-
16
+ console.log("positionPageOnReady called");
17
17
  await bind(_$w);
18
18
 
19
19
 
@@ -32,6 +32,7 @@ async function getCategoryValue(customValues) {
32
32
 
33
33
 
34
34
  async function bind(_$w) {
35
+ console.log("bind called");
35
36
  _$w('#datasetJobsItem').onReady(async () => {
36
37
 
37
38
  const item = await _$w('#datasetJobsItem').getCurrentItem();