mod-build 3.6.94-beta.3 → 3.6.94-beta.5

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.
@@ -19,31 +19,41 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
19
19
  // Checking for seasonal variations in the template.js + updating content
20
20
  var checkSeasonalVariations = require('./check-seasonal-variations.js');
21
21
  const activeSeason = checkSeasonalVariations();
22
- const HVACInterestStepName = 'HVACInterest';
23
- const season = 'warmerWeather';
22
+ const HVAC_INTEREST = 'HVACInterest';
23
+ const SEASON = 'warmerWeather';
24
+ const CENTRAL_AC = 'Central AC';
25
+ const CENTRAL_HEATING = 'Central Heating';
24
26
  if (activeSeason.length !== 0) {
25
- if (activeSeason.includes(season)) {
27
+ if (activeSeason.includes(SEASON)) {
26
28
  const data = JSON.stringify(siteData, null, 4);
27
- const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
29
+ const heating = '(Heating|calentadores)';
28
30
  const and = '(&|and|y)';
29
- const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
31
+ const ac = '(AC|Cooling|aires.*?acondicionados)';
30
32
  const spaces = '.*?';
31
33
 
32
34
  const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
33
35
  // Find and reverse the required words in the string using regex group capture
34
36
  const processedData = data.replaceAll(regex, '$3 $2 $1');
35
- // console.log('processedData', processedData);
36
37
  // Convert data into JSON
37
38
  siteData = JSON.parse(processedData);
38
39
  // Find the HVACInterest step and reverse the options array
39
40
  if (siteData.steps && (siteData.steps.items && siteData.steps.items.length)) {
40
41
  siteData.steps.items.forEach(function(step) {
41
- const isHvacInterestStep = step && (step.stepName && step.stepName === HVACInterestStepName) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVACInterestStepName);
42
+ const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
42
43
  if (isHvacInterestStep) {
43
44
  const stepFields = step.fields || step.stepContent.fields;
44
45
  if (stepFields && stepFields.length) {
45
46
  stepFields.forEach(function(field) {
46
- field.options = field.options.reverse();
47
+ const firstOption = field.options[0];
48
+ const lastOption = field.options[field.options.length - 1];
49
+ const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
50
+ const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
51
+
52
+ if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
53
+ field.options[0] = lastOption;
54
+ field.options[field.options.length - 1] = firstOption;
55
+ }
56
+
47
57
  field.options.some(function(option) {
48
58
  if (option.checked) {
49
59
  option.checked = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.94-beta.3",
3
+ "version": "3.6.94-beta.5",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",