Skip to content

Commit

Permalink
Merge pull request #221 from MAPC/develop
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
iangmhill authored Jul 17, 2018
2 parents f1fc9df + dc1f9bf commit d5d5d07
Show file tree
Hide file tree
Showing 45 changed files with 631 additions and 340 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resolves # .

# Why is this change necessary?

# How does it address the issue?

# What side effects does it have?
68 changes: 33 additions & 35 deletions ember/app/components/development-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default class extends Component {

this.changes = false;
this.proposedChanges = {};
this.editing = this.get('model').toJSON();
this.filters = filters;
this.fulfilled = false;

Expand Down Expand Up @@ -74,6 +73,12 @@ export default class extends Component {
this.criteria = { base, proposed, groundBroken };

Ember.run.later(this, () => this.updateFieldRequirements(), 500);
const lng = this.get('editing.longitude');
const lat = this.get('editing.latitude');
if (lng && lat && lng != 0 && lat != 0) {
this.set('map.jumpToSelectedCoordinates', true);
this.set('map.selectedCoordinates', [lng, lat])
}
this.get('map').addObserver('selectedCoordinates', this, 'updateCoordinates');
}

Expand All @@ -83,10 +88,8 @@ export default class extends Component {

updateCoordinates(mapService) {
const coordinates = mapService.get('selectedCoordinates');
this.set('editing.longitude', coordinates[0]);
this.set('editing.latitude', coordinates[1]);
this.checkForUpdated('latitude');
this.checkForUpdated('longitude');
this.handleUpdate('latitude', coordinates[1]);
this.handleUpdate('longitude', coordinates[0]);
}


Expand All @@ -98,7 +101,7 @@ export default class extends Component {

@action
updateStatus() {
this.checkForUpdated('status');
this.handleUpdate('status');
this.updateFieldRequirements();
}

Expand Down Expand Up @@ -130,30 +133,23 @@ export default class extends Component {

@action
updateHu(fieldName) {
this.checkForUpdated(fieldName);

this.set('editing.hu', this.sumProperties(...this.get('huFields'), 'editing.unknownhu'));
this.checkForUpdated('hu');
this.handleUpdate(fieldName);
this.handleUpdate('hu', this.sumProperties(...this.get('huFields'), 'editing.unknownhu'));
}


@action
updateAffrdUnit(fieldName) {
this.checkForUpdated(fieldName);

this.set('editing.affrdUnit', this.sumProperties(...this.get('affrdUnitFields'), 'editing.affUnknown'));
this.checkForUpdated('affrdUnit');
this.handleUpdate(fieldName);
this.handleUpdate('affrdUnit', this.sumProperties(...this.get('affrdUnitFields'), 'editing.affUnknown'));
}


@action
updateCommsf(fieldName) {
this.checkForUpdated(fieldName);

this.handleUpdate(fieldName);
const sum = this.sumProperties(...this.get('commsfFields'), 'editing.unkSqft');

this.set('editing.commsf', sum);
this.checkForUpdated('commsf');
this.handleUpdate('commsf', sum);
}


Expand Down Expand Up @@ -194,38 +190,40 @@ export default class extends Component {
}
}


@action
checkForUpdated(fieldName) {
this.handleUpdate(fieldName)
}

handleUpdate(fieldName, calculatedValue) {
const modeled = this.get(`model.${fieldName}`);
let edited = this.get(`editing.${fieldName}`);
let edited = calculatedValue || this.get(`editing.${fieldName}`);

// Adjust values if nonstandard
if (fieldName === 'status') {
edited = document.querySelector(`select[name="${fieldName}"]`).value;
this.set(`editing.${fieldName}`, edited);
}
else if (fieldName === 'parkType') {
edited = Array.from(document.querySelectorAll(`input.field-${fieldName}`))
.filter(x => x.checked)
.map(x => x.name);

this.set('selectedParkTypes', edited);
this.set(`editing.${fieldName}`, edited.join(','));
}

if (typeof edited === 'boolean') {
edited = !edited;
}

if (
(
modeled === undefined
&& (edited !== '' && edited !== null && edited !== undefined)
)
|| (
modeled !== undefined
&& String(modeled) !== String(edited)
)
) {
// Send updates to controller state
this.sendAction('updateEditing', { [fieldName]: edited });

// If value changed, set proposedChanges
if ((
modeled === undefined
&& (edited !== '' && edited !== null && edited !== undefined)
) || (
modeled !== undefined
&& String(modeled) !== String(edited)
)) {
this.set(`proposedChanges.${fieldName}`, edited);
this.set('changes', true);
}
Expand Down
63 changes: 0 additions & 63 deletions ember/app/components/goto-bar.js

This file was deleted.

5 changes: 2 additions & 3 deletions ember/app/components/login-subpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { action, computed } from 'ember-decorators/object';
export default class extends Component {

@service session


constructor() {
super();
Expand All @@ -22,7 +22,7 @@ export default class extends Component {
}


@computed('username', 'password')
@computed('username', 'password')
get submittable() {
return ['username','password'].every(field => this.get(field) !== '');
}
Expand All @@ -42,7 +42,6 @@ export default class extends Component {
session
.authenticate('authenticator:devise', username, password)
.catch(e => {
console.log(e);
if (e.message && e.message === 'Disabled user') {
this.set('errorMessage', `This account was disabled by an admin. Please contact ${config.admin.email} for more information.`);
}
Expand Down
52 changes: 35 additions & 17 deletions ember/app/components/mapbox-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export default class extends Component {
// CSS transitions make dynamically calculating the width of the left panel
// difficult because it becomes time sensitive. Since the width and left
// properties of the panel are set in pixels we can set that here as a constant.
const mapWidth = parseInt(this.$().css('width'));
if (mapWidth < 1180) {
return 480;
if (this.get('map.showingLeftPanel')) {
const mapWidth = parseInt(this.$().css('width'));
if (mapWidth < 1180) {
return 480;
}
return 700;
}
return 700;
return 0;
}

didInsertElement() {
Expand All @@ -44,18 +47,15 @@ export default class extends Component {
this.mapboxglMap = new mapboxgl.Map({
container: this.get('element'),
style: mapStyle,
// maxBounds: [[-75.5, 39], [-67, 45]],
center: [-71.061391, 42.355107],
zoom: 10,
maxBounds: [[-100, 20], [-40, 60]],
dragRotate: false,
pitchWithRotate: false,
touchZoomRotate: false,
minZoom: 6,
});
this.mapboxglMap.on('load', () => {

this.mapboxglMap.on('styledata', () => {
this.draw(mapService);
});
this.mapboxglMap.on('zoom', (e) => {
// If a user attempts to abort a zoom, stop the animation.
if (e.originalEvent) {
Expand All @@ -69,7 +69,8 @@ export default class extends Component {
mapService.addObserver('baseMap', this, 'setStyle');
mapService.addObserver('zoomCommand', this, 'actOnZoomCommand');
mapService.addObserver('viewing', this, 'jumpTo');
mapService.addObserver('selectionMode', this, 'selectionModeChangeHandler');
mapService.addObserver('markerVisible', this, 'markerVisibleChangeHandler')
mapService.addObserver('followMode', this, 'followModeChangeHandler');
mapService.addObserver('selectedCoordinates', this, 'drawSelectedCoordinates');

if (mapService.get('stored').length) {
Expand All @@ -79,8 +80,10 @@ export default class extends Component {
if (mapService.get('viewing')) {
this.jumpTo(mapService);
}
if (mapService.get('selectionMode')) {
if (mapService.get('markerVisible')) {
this.drawSelector(mapService);
}
if (mapService.get('followMode')) {
this.updateSelection(true);
}
});
Expand All @@ -101,20 +104,28 @@ export default class extends Component {
mapService.removeObserver('baseMap', this, 'setStyle');
mapService.removeObserver('zoomCommand', this, 'actOnZoomCommand');
mapService.removeObserver('viewing', this, 'jumpTo');
mapService.removeObserver('selectionMode', this, 'selectionModeChangeHandler');
mapService.removeObserver('markerVisible', this, 'markerVisibleChangeHandler');
mapService.removeObserver('followMode', this, 'followModeChangeHandler');
mapService.removeObserver('selectedCoordinates', this, 'drawSelectedCoordinates');
this.mapboxglMap.remove();
}

selectionModeChangeHandler(mapService) {
markerVisibleChangeHandler(mapService) {
this.draw(mapService);
this.drawSelector(mapService);
}

followModeChangeHandler(mapService) {
this.draw(mapService);
this.set('previousCoordinatesKey', null);
this.set('previousParcel', null);
this.updateSelection(true);
}

updateSelection(notFromFitBounds) {
// If the user triggered the drag or zoom...
if (notFromFitBounds
&& this.get('map.followMode')
&& this.mapboxglMap
&& this.mapboxglMap.getSource('selector')
&& Ember.$('.left-panel-layer')
Expand Down Expand Up @@ -159,6 +170,7 @@ export default class extends Component {
}

drawSelectedCoordinates(mapService) {

if (this.mapboxglMap
&& this.mapboxglMap.getSource('selector')) {
const coordinates = mapService.get('selectedCoordinates');
Expand Down Expand Up @@ -197,7 +209,7 @@ export default class extends Component {
this.set('lastRequest', Date.now());
this.get('store').query('parcel', { lng: coordinates[0], lat: coordinates[1] }).then((results) => {
const parcels = results.toArray();
const newCoordinates = this.get('map').get('selectedCoordinates');
const newCoordinates = this.get('map.selectedCoordinates');
if (parcels.length) {
const parcel = parcels[0];
if (pointInPolygon.default({ type: 'Point', coordinates: newCoordinates }, parcel.get('geojson'))
Expand Down Expand Up @@ -244,6 +256,12 @@ export default class extends Component {

setStyle(mapService) {
const newBaseMap = mapService.get('baseMap');
const redrawOnStyleReload = () => {
this.markerVisibleChangeHandler(mapService);
this.followModeChangeHandler(mapService);
this.mapboxglMap.off('styledata', redrawOnStyleReload);
};
this.mapboxglMap.on('styledata', redrawOnStyleReload);
if (newBaseMap == 'light') {
this.mapboxglMap.setStyle('mapbox://styles/mapbox/light-v9');
} else if (newBaseMap == 'satellite') {
Expand All @@ -262,9 +280,9 @@ export default class extends Component {
}

drawSelector(mapService) {
const selectionMode = mapService.get('selectionMode');
const markerVisible = mapService.get('markerVisible');
const satelliteMap = mapService.get('baseMap') != 'light';
if (selectionMode && !this.mapboxglMap.getLayer('selector')) {
if (markerVisible && !this.mapboxglMap.getLayer('selector')) {
this.mapboxglMap.addLayer({
id: 'selector',
type: 'circle',
Expand Down Expand Up @@ -383,7 +401,7 @@ export default class extends Component {
? mapService.get('remainder')
: mapService.get('stored'));
const satelliteMap = mapService.get('baseMap') != 'light';
const isMuted = mapService.get('selectionMode');
const isMuted = mapService.get('followMode');

if (this.mapboxglMap.getLayer('all')) {
this.mapboxglMap.getSource('all').setData({
Expand Down
Loading

0 comments on commit d5d5d07

Please sign in to comment.