abmp-npm 2.0.80 → 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 +7 -19
- package/public/Utils/sharedUtils.js +35 -0
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -7,11 +7,10 @@ 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
|
-
findMainAddress,
|
|
11
10
|
formatPracticeAreasForDisplay,
|
|
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,24 +225,13 @@ const homePageOnReady = async ({
|
|
|
226
225
|
$item('#milesAwayText').text = '';
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
// 7) "Show maps" button -
|
|
228
|
+
// 7) "Show maps" button - only for members who selected "Show Full Address".
|
|
230
229
|
//
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
// coordinates
|
|
235
|
-
|
|
236
|
-
//
|
|
237
|
-
// Privacy is enforced in buildMapLink, not here - it delegates to
|
|
238
|
-
// formatAddress, which prints the street line only for full_address, and
|
|
239
|
-
// returns '' outright for dont_show. findMainAddress also excludes
|
|
240
|
-
// dont_show. A hidden street address can never reach a maps URL.
|
|
241
|
-
//
|
|
242
|
-
// Gate on the link rather than the address: buildMapLink returns '' when it
|
|
243
|
-
// can build neither an address nor a coordinate link, and handles being
|
|
244
|
-
// passed '' or undefined, so the button is never shown linking nowhere.
|
|
245
|
-
const mapAddress = findMainAddress(itemData.addressDisplayOption, addresses);
|
|
246
|
-
const mapLink = buildMapLink(mapAddress);
|
|
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);
|
|
247
235
|
|
|
248
236
|
if (mapLink) {
|
|
249
237
|
$item('#showMaps').enable();
|
|
@@ -155,6 +155,40 @@ function buildMapLink(address) {
|
|
|
155
155
|
return '';
|
|
156
156
|
}
|
|
157
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
|
+
|
|
158
192
|
/**
|
|
159
193
|
* @param {Array} addressDisplayOption
|
|
160
194
|
* @param {Array} addresses
|
|
@@ -266,6 +300,7 @@ module.exports = {
|
|
|
266
300
|
generateId,
|
|
267
301
|
formatAddress,
|
|
268
302
|
buildMapLink,
|
|
303
|
+
buildDirectionsLink,
|
|
269
304
|
isWixHostedImage,
|
|
270
305
|
normalizeExternalUrl,
|
|
271
306
|
normalizeEmail,
|