Skip to content

Commit

Permalink
Centralize zoning district primaryzone lookup code; rename
Browse files Browse the repository at this point in the history
  • Loading branch information
allthesignals committed Oct 26, 2021
1 parent a8665c3 commit 3281a3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions app/models/map-features/zoning-district.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ const zoningAbbr = {
BPC: 'bpc',
};

export const handleCommercialZoningExceptions = (primaryzone) => {
let url = '';

if ((primaryzone === 'c1') || (primaryzone === 'c2')) {
url = 'c1-c2';
} else if (primaryzone === 'c3') {
url = 'c3-c3a';
} else {
url = primaryzone;
}

return url;
};

const { attr } = DS;

// this model fragment structures the "properties"
Expand All @@ -94,8 +108,10 @@ export default class ZoningDistrictFragment extends MF.Fragment {
@computed('zonedist')
get primaryzone() {
const zonedist = this.get('zonedist');

// convert R6A to r6
const primary = zonedist.match(/\w\d*/)[0].toLowerCase();
const primary = handleCommercialZoningExceptions(zonedist.match(/\w\d*/)[0].toLowerCase());

return primary;
}

Expand All @@ -117,20 +133,4 @@ export default class ZoningDistrictFragment extends MF.Fragment {

return zoningDescriptions[zoneabbr];
}

@computed('primaryzone')
get primaryzoneURL() {
const primaryzone = this.get('primaryzone');
let url = '';

if ((primaryzone === 'c1') || (primaryzone === 'c2')) {
url = 'c1-c2';
} else if (primaryzone === 'c3') {
url = 'c3-c3a';
} else {
url = primaryzone;
}

return url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{#unless (eq this.model.zonedist "BPC")}}
<p>
<a
href="https://www1.nyc.gov/site/planning/zoning/districts-tools/{{this.model.primaryzoneURL}}.page"
href="https://www1.nyc.gov/site/planning/zoning/districts-tools/{{this.model.primaryzone}}.page"
target="_blank"
>
{{fa-icon "external-link-alt"}}
Expand Down

0 comments on commit 3281a3f

Please sign in to comment.