abmp-npm 2.0.79 → 2.0.81
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/Home.js +8 -21
- package/public/Utils/sharedUtils.js +41 -0
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -3,15 +3,14 @@ const { location: wixLocation } = require('@wix/site-location');
|
|
|
3
3
|
const { window: wixWindow, rendering } = require('@wix/site-window');
|
|
4
4
|
const { withWarmUpData } = require('psdev-utils/frontend');
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
|
|
7
7
|
const { createHomepageUtils } = require('../public/Utils/homePage.js');
|
|
8
8
|
const {
|
|
9
9
|
getMainAddress,
|
|
10
10
|
formatPracticeAreasForDisplay,
|
|
11
|
-
checkAddressIsVisible,
|
|
12
11
|
isWixHostedImage,
|
|
13
12
|
normalizeExternalUrl,
|
|
14
|
-
|
|
13
|
+
buildDirectionsLink,
|
|
15
14
|
} = require('../public/Utils/sharedUtils.js');
|
|
16
15
|
|
|
17
16
|
let filter = JSON.parse(JSON.stringify(DEFAULT_FILTER));
|
|
@@ -226,25 +225,13 @@ const homePageOnReady = async ({
|
|
|
226
225
|
$item('#milesAwayText').text = '';
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
// 7) "Show maps" button
|
|
230
|
-
const visible = checkAddressIsVisible(addresses);
|
|
231
|
-
const fullAddressWithValidCoords = visible.find(
|
|
232
|
-
addr =>
|
|
233
|
-
addr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
|
|
234
|
-
addr.latitude &&
|
|
235
|
-
addr.longitude
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
// Links to the street address rather than the stored coordinates, which are
|
|
239
|
-
// unreliable for some members. The full-address filter above is what keeps
|
|
240
|
-
// this safe: members set to state_city_zip or dont_show never reach here, so
|
|
241
|
-
// a hidden street address is never put in a maps URL.
|
|
228
|
+
// 7) "Show maps" button - only for members who selected "Show Full Address".
|
|
242
229
|
//
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
//
|
|
247
|
-
const mapLink =
|
|
230
|
+
// buildDirectionsLink owns the rule and returns '' when the button should be
|
|
231
|
+
// hidden: city/state/ZIP and hidden members get nothing, and a full-address
|
|
232
|
+
// member gets a link built from their address text rather than their NetForum
|
|
233
|
+
// coordinates, which are unreliable (Monday 12596102059).
|
|
234
|
+
const mapLink = buildDirectionsLink(itemData.addressDisplayOption, addresses);
|
|
248
235
|
|
|
249
236
|
if (mapLink) {
|
|
250
237
|
$item('#showMaps').enable();
|
|
@@ -137,6 +137,12 @@ function formatAddress(item) {
|
|
|
137
137
|
function buildMapLink(address) {
|
|
138
138
|
if (!address) return '';
|
|
139
139
|
|
|
140
|
+
// A member set to dont_show has opted out of publishing their location at all.
|
|
141
|
+
// formatAddress returns '' for them, so without this guard they would fall
|
|
142
|
+
// through to the coordinate fallback below and have their exact position put
|
|
143
|
+
// into an outbound maps URL - worse than the street line they chose to hide.
|
|
144
|
+
if (address.addressStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) return '';
|
|
145
|
+
|
|
140
146
|
const query = formatAddress(address);
|
|
141
147
|
if (query) {
|
|
142
148
|
return `https://maps.google.com/?q=${encodeURIComponent(query)}`;
|
|
@@ -149,6 +155,40 @@ function buildMapLink(address) {
|
|
|
149
155
|
return '';
|
|
150
156
|
}
|
|
151
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Builds the directions-button link for a member, or '' when no button should show.
|
|
160
|
+
*
|
|
161
|
+
* PAC's rule (Monday 12596102059, confirmed by Richard Visser): directions appear
|
|
162
|
+
* only for members who selected "Show Full Address". Members displaying
|
|
163
|
+
* city/state/ZIP, and members who hid their address, get no button at all. An
|
|
164
|
+
* earlier pass relaxed this to city-level members and had to be reverted, so the
|
|
165
|
+
* rule lives here with tests around it rather than inline in the page code.
|
|
166
|
+
*
|
|
167
|
+
* The address is resolved with findMainAddress, so the button is always tied to
|
|
168
|
+
* the same address as the location text rendered beside it. A member whose
|
|
169
|
+
* displayed address is city-level gets no button even when a fuller address exists
|
|
170
|
+
* elsewhere on their record - the button must not point somewhere other than what
|
|
171
|
+
* is on screen.
|
|
172
|
+
*
|
|
173
|
+
* Coordinates are deliberately not required: buildMapLink navigates from the
|
|
174
|
+
* address text, so a member with missing or wrong NetForum coordinates still gets
|
|
175
|
+
* a working button where previously they got none. Distance ranking and the
|
|
176
|
+
* "XX miles away" figure keep using the coordinates and are unaffected.
|
|
177
|
+
*
|
|
178
|
+
* @param {Array} addressDisplayOption
|
|
179
|
+
* @param {Array} addresses
|
|
180
|
+
* @returns {string} map URL, or '' when the button should be hidden
|
|
181
|
+
*/
|
|
182
|
+
function buildDirectionsLink(addressDisplayOption = [], addresses = []) {
|
|
183
|
+
const address = findMainAddress(addressDisplayOption, addresses);
|
|
184
|
+
|
|
185
|
+
if (address?.addressStatus !== ADDRESS_STATUS_TYPES.FULL_ADDRESS) {
|
|
186
|
+
return '';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return buildMapLink(address);
|
|
190
|
+
}
|
|
191
|
+
|
|
152
192
|
/**
|
|
153
193
|
* @param {Array} addressDisplayOption
|
|
154
194
|
* @param {Array} addresses
|
|
@@ -260,6 +300,7 @@ module.exports = {
|
|
|
260
300
|
generateId,
|
|
261
301
|
formatAddress,
|
|
262
302
|
buildMapLink,
|
|
303
|
+
buildDirectionsLink,
|
|
263
304
|
isWixHostedImage,
|
|
264
305
|
normalizeExternalUrl,
|
|
265
306
|
normalizeEmail,
|