Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORMS-1580 - Required Field Flag #1549

Open
wants to merge 132 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
be33825
Initial Skeleton
RyanBirtch-aot May 23, 2024
814fa7c
component creation reference
abhilash-aot May 23, 2024
a1b7ccb
Merge branch 'component-reference' of https://github.com/abhilash-aot…
RyanBirtch-aot May 23, 2024
74eb54e
SMK Skeleton Integration
RyanBirtch-aot May 27, 2024
1a31453
Added map component changes
RyanBirtch-aot May 27, 2024
9c7733e
Init Leaflet Component
RyanBirtch-aot May 28, 2024
9c73981
Fixed marker bug, reduced options to point and circle, prelim work on…
RyanBirtch-aot May 29, 2024
6e91baf
refactor map component
RyanBirtch-aot May 31, 2024
a878ac4
refactoring intermediate step
RyanBirtch-aot Jun 3, 2024
00b4953
Typescript conversion
RyanBirtch-aot Jun 3, 2024
183e48d
fixed Unknown Component Render issue
abhilash-aot Jun 4, 2024
a236b63
Merge pull request #1 from abhilash-aot/leaflet-skeleton
RyanBirtch-aot Jun 4, 2024
c12741a
Fixes for js->ts conversion, fixes for webpack css import
RyanBirtch-aot Jun 4, 2024
36d590d
fix for multi map on one page
RyanBirtch-aot Jun 5, 2024
ec49043
map settings form work
RyanBirtch-aot Jun 11, 2024
96605cb
added limits on map pointer submission and popups showing lat lng
RyanBirtch-aot Jun 11, 2024
3a7cab0
settings fix
RyanBirtch-aot Jun 17, 2024
fd4ef17
Settings for radio button with draw options
RyanBirtch-aot Jun 20, 2024
397362b
Points fix
RyanBirtch-aot Jun 24, 2024
2110455
fixes for marker
RyanBirtch-aot Jun 24, 2024
11dfd07
Map zoom fix
RyanBirtch-aot Jun 24, 2024
4371b95
mapsubmission settings
abhilash-aot Jun 25, 2024
7f1ff5e
set map zoom fix
RyanBirtch-aot Jun 25, 2024
c9a46ac
set map zoom fix2
RyanBirtch-aot Jun 25, 2024
d8fb68a
added debug and other drawoptions
abhilash-aot Jun 25, 2024
c68a567
Merged to base branch
abhilash-aot Jun 25, 2024
b90fd13
Merge pull request #3 from RyanBirtch-aot/mapsubmission-settings
RyanBirtch-aot Jun 26, 2024
93fa6c2
Revert back to fieldComponent
RyanBirtch-aot Jun 26, 2024
97f9c28
Fixes for multi input limits
RyanBirtch-aot Jun 28, 2024
75fd4dc
fixes for pr
RyanBirtch-aot Jun 28, 2024
602bde6
Removed unused packages
abhilash-aot Jun 28, 2024
5dd1e7d
Merge pull request #5 from RyanBirtch-aot/map-adding-points
abhilash-aot Jul 2, 2024
8e8ce89
Fix to non-interactive default map in settings page
RyanBirtch-aot Jul 3, 2024
4b08982
Added Read Only functionality
RyanBirtch-aot Jul 3, 2024
e97fedd
Merge branch 'map-adding-points' of https://github.com/RyanBirtch-aot…
RyanBirtch-aot Jul 3, 2024
868365c
Merge pull request #6 from RyanBirtch-aot/map-adding-points
abhilash-aot Jul 3, 2024
a13b329
Merged with main
abhilash-aot Jul 4, 2024
58fdf65
map service update
abhilash-aot Jul 4, 2024
8258064
Settings Updated
abhilash-aot Jul 5, 2024
300441f
Settings text updated
abhilash-aot Jul 5, 2024
c260fe2
Merge pull request #8 from RyanBirtch-aot/map-bug-fix
RyanBirtch-aot Jul 8, 2024
8001826
initial custom center
RyanBirtch-aot Jul 8, 2024
dc9f60a
Merge from feat-map
RyanBirtch-aot Jul 8, 2024
f82e707
Added customizing default map center
RyanBirtch-aot Jul 8, 2024
a1c2da1
Merge pull request #9 from RyanBirtch-aot/settings-default-center
RyanBirtch-aot Jul 8, 2024
c290076
Readonly in view submission mode
abhilash-aot Jul 10, 2024
2637740
Updated for Map data Submission to be an Json
abhilash-aot Jul 16, 2024
13a4ae6
reorganized map settings, set new default center
RyanBirtch-aot Jul 16, 2024
6257065
Merge pull request #10 from RyanBirtch-aot/map-layer
abhilash-aot Jul 16, 2024
4df8c98
Merge branch 'feat-map' into settings-reorg
RyanBirtch-aot Jul 16, 2024
3c65a7f
Merge pull request #11 from RyanBirtch-aot/settings-reorg
RyanBirtch-aot Jul 16, 2024
3402359
Merge branch 'bcgov:main' into feat-map
RyanBirtch-aot Jul 16, 2024
ba671ba
Fixed default bug
RyanBirtch-aot Jul 24, 2024
f824346
Merge branch 'feat-map' into default-value-bug
RyanBirtch-aot Jul 24, 2024
01cb3d5
Merge pull request #12 from RyanBirtch-aot/default-value-bug
abhilash-aot Jul 25, 2024
e11174f
map broken in Map Settings Page fixed
abhilash-aot Jul 25, 2024
b5afae5
Merge pull request #13 from RyanBirtch-aot/map-layer
RyanBirtch-aot Jul 26, 2024
062e9eb
init, added marker png to component folder
RyanBirtch-aot Jul 29, 2024
f459450
Added custom marker, placeholder marker image
RyanBirtch-aot Jul 31, 2024
6decb87
Added fixes for marker centering
RyanBirtch-aot Aug 1, 2024
174dfb1
Removed comments, and logs
RyanBirtch-aot Aug 1, 2024
47b8da9
Merge pull request #14 from RyanBirtch-aot/marker-image-bug
abhilash-aot Aug 1, 2024
beeb35e
Added fix for marker drag
RyanBirtch-aot Aug 6, 2024
8c436e2
Merge branch 'feat-map' into marker-image-bug
RyanBirtch-aot Aug 7, 2024
876b622
Merge pull request #15 from RyanBirtch-aot/marker-image-bug
abhilash-aot Aug 7, 2024
dac5c6d
Merge error
RyanBirtch-aot Aug 7, 2024
f9a8f66
Merge pull request #16 from RyanBirtch-aot/marker-image-bug
abhilash-aot Aug 7, 2024
de9d6e4
Merge from pop
RyanBirtch-aot Aug 7, 2024
25f8638
Changes from main
abhilash-aot Aug 7, 2024
65301b7
Merge from pop
RyanBirtch-aot Aug 7, 2024
7a5b17f
Revert "Merge error"
RyanBirtch-aot Aug 7, 2024
37716bf
Commit fixes
RyanBirtch-aot Aug 8, 2024
b9dfc6b
Merge branch 'feat-map' into marker-image-bug
RyanBirtch-aot Aug 8, 2024
c9b8579
Fixes for marker dragging
RyanBirtch-aot Aug 13, 2024
a54184b
Cleanup
RyanBirtch-aot Aug 13, 2024
dfb98c1
removed extra node installs, vue etc...
RyanBirtch-aot Aug 13, 2024
c3510da
Merge pull request #18 from RyanBirtch-aot/marker-image-bug
abhilash-aot Aug 13, 2024
ae2bae0
Merge pull request #17 from RyanBirtch-aot/map-layer
abhilash-aot Aug 13, 2024
b47b3d8
marker edit fix
RyanBirtch-aot Aug 19, 2024
89fa94a
Merge pull request #19 from RyanBirtch-aot/marker-edit-bug-deletion
abhilash-aot Aug 19, 2024
d23d0fd
Merge branch 'bcgov:main' into feat-map
RyanBirtch-aot Aug 20, 2024
a61aafa
Merge from feat-map
RyanBirtch-aot Aug 26, 2024
a360390
updated Map Component Settings
abhilash-aot Sep 4, 2024
1ecab43
Merge pull request #20 from RyanBirtch-aot/map-layer
abhilash-aot Sep 4, 2024
4998ac2
Vue fix recant
RyanBirtch-aot Sep 4, 2024
92e7431
zoom bug fix,disable zoom animation
RyanBirtch-aot Sep 9, 2024
f4cfe7e
cleanup
RyanBirtch-aot Sep 9, 2024
69ec9a7
restructure the display tab
abhilash-aot Sep 11, 2024
e80cdfd
Merge remote-tracking branch 'ryan/feat-map' into map-layer
abhilash-aot Sep 11, 2024
db9a6c2
updated Display tab Settings in Map component
abhilash-aot Sep 11, 2024
984f613
Merge pull request #21 from RyanBirtch-aot/map-layer
RyanBirtch-aot Sep 11, 2024
aecf199
Added zoom animations only for read-only maps
RyanBirtch-aot Sep 16, 2024
d7dadcd
Merge branch 'feat-map' into map-zoom-bug
RyanBirtch-aot Sep 16, 2024
4fcc8d5
Merge pull request #22 from RyanBirtch-aot/map-zoom-bug
abhilash-aot Sep 17, 2024
5a41d02
Added My Location button
RyanBirtch-aot Sep 23, 2024
73395f5
linting fixes
RyanBirtch-aot Sep 23, 2024
638bbd0
Merge pull request #23 from RyanBirtch-aot/my-location-button
abhilash-aot Sep 23, 2024
10ba795
updated for polygon change
abhilash-aot Sep 24, 2024
a550238
Merge pull request #24 from RyanBirtch-aot/map-layer
abhilash-aot Sep 24, 2024
518b568
added reorganization to settings page
RyanBirtch-aot Sep 24, 2024
03d20e4
Added multiple marker type options, default to add input map
RyanBirtch-aot Sep 26, 2024
1235e4c
Merge in feat-map
RyanBirtch-aot Sep 26, 2024
34d0867
Added default interactivity
RyanBirtch-aot Sep 26, 2024
aad9842
Merge pull request #25 from RyanBirtch-aot/my-location-button
abhilash-aot Sep 27, 2024
47d32a5
Geocoder working for BC
RyanBirtch-aot Oct 11, 2024
04a7d2f
Adding form and location popups
RyanBirtch-aot Oct 15, 2024
c80694f
Merge pull request #26 from RyanBirtch-aot/my-location-button
abhilash-aot Oct 16, 2024
5391c7d
fixes for marker appearing at geocoder search, replaced with popup
RyanBirtch-aot Oct 16, 2024
d7605f3
Update MapService.ts
abhilash-aot Oct 16, 2024
e11aed0
Merge pull request #27 from RyanBirtch-aot/my-location-button
abhilash-aot Oct 16, 2024
9286ac3
Added fix for popup bug
RyanBirtch-aot Oct 22, 2024
abf0026
Removed console
RyanBirtch-aot Oct 22, 2024
a2176e6
Merge pull request #28 from RyanBirtch-aot/bug-max-markers
abhilash-aot Oct 23, 2024
b04274e
Changes to map settings form to enable line input
RyanBirtch-aot Oct 24, 2024
c34ba12
Merge pull request #29 from RyanBirtch-aot/add-line-marker
abhilash-aot Oct 24, 2024
124cd6f
merge in main
RyanBirtch-aot Oct 25, 2024
4076e73
Merge pull request #30 from RyanBirtch-aot/main
abhilash-aot Oct 29, 2024
bebd667
Update constants.js for Map component include
abhilash-aot Oct 30, 2024
2110031
Changed settings form to formio defaults
RyanBirtch-aot Nov 8, 2024
523af05
Tried turning on validation settings page, looking into more in-depth…
RyanBirtch-aot Nov 8, 2024
afb3639
Merge pull request #32 from RyanBirtch-aot/main
abhilash-aot Nov 21, 2024
6ae027c
Fixes for PR comments, added constant for map component height
RyanBirtch-aot Nov 21, 2024
908e357
Merge branch 'main' into feat-map
RyanBirtch-aot Nov 21, 2024
9abd9b6
Merge branch 'main' into feat-map
abhilash-aot Nov 22, 2024
52eaeb2
Added required field and overrode isEmpty from formio base component,…
RyanBirtch-aot Dec 13, 2024
23a3c62
cleanup
RyanBirtch-aot Dec 13, 2024
4e53361
Linting fixes
RyanBirtch-aot Dec 16, 2024
42cac57
Merge branch 'feat-map' of https://github.com/RyanBirtch-aot/common-h…
RyanBirtch-aot Dec 16, 2024
a5f10a6
Merge branch 'bcgov:main' into feat-map
RyanBirtch-aot Dec 16, 2024
438a3ca
Merge pull request #33 from RyanBirtch-aot/map-required-bug
RyanBirtch-aot Dec 17, 2024
0863b90
Merge branch 'bcgov:main' into feat-map
RyanBirtch-aot Dec 17, 2024
8c25eb2
Merge branch 'main' into feat-map
RyanBirtch-aot Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/src/components/Map/Component.form.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import baseEditForm from 'formiojs/components/_classes/component/Component.form';
import EditData from './editForm/Component.edit.data';
import EditDisplay from './editForm/Component.edit.display';
import EditValidation from './editForm/Component.edit.validation';
import AdvancedEditLogic from '../Common/Advanced.edit.logic';
export default function (...extend) {
return baseEditForm(
[
EditDisplay,
EditData,
EditValidation,
{
key: 'display',
ignore: true,
Expand Down
8 changes: 8 additions & 0 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class Component extends (FieldComponent as any) {
myLocation,
bcGeocoder,
} = this.component;
const { required } = this.component.validate;

const { readOnly: viewMode } = this.options;

Expand Down Expand Up @@ -179,4 +180,11 @@ export default class Component extends (FieldComponent as any) {
getValue() {
return this.dataValue;
}

isEmpty(value) {
return (
value?.features.length === 0 ||
value?.features.length === this.defaultValue?.features.length
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import common from '../../Common/Simple.edit.validation';
export default [
...common,
];
export default {
key: 'customValidation',
label: 'Validation',
weight: 10,
components: common,
};
4 changes: 2 additions & 2 deletions components/src/components/Map/services/BCGeocoderProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export class BCGeocoderProvider extends OpenStreetMapProvider {
};
parse = ({ data }) => {
return data.features
.filter(function (feature) {
.filter((feature) => {
if (!feature.geometry.coordinates) return false;
if (feature.properties.fullAddress === 'BC') return false;
return true;
})
.map(function (feature) {
.map((feature) => {
return {
x: feature.geometry.coordinates[0],
y: feature.geometry.coordinates[1],
Expand Down
88 changes: 86 additions & 2 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ interface MapServiceOptions {
viewMode?: boolean;
myLocation?: boolean;
bcGeocoder: boolean;
required: boolean;
defaultValue?: any;
}

class MapService {
Expand All @@ -46,7 +48,6 @@ class MapService {

// this.map = map;
this.drawnItems = drawnItems;

map.invalidateSize();
// Triggering a resize event after map initialization
setTimeout(() => window.dispatchEvent(new Event('resize')), 0);
Expand All @@ -67,9 +68,22 @@ class MapService {
this.bindPopupToLayer(layer);
options.onDrawnItemsChange(drawnItems.getLayers());
});
map.on(L.Draw.Event.DELETED, (e) => {

map.on(L.Draw.Event.DELETED, (e: any) => {
e.layers.eachLayer((layer) => {
const match = this.isDefaultFeature(layer as L.Layer);
if (match) {
// re-add the feature/layer to the map
drawnItems.addLayer(layer);
L.popup()
.setLatLng(map.getCenter())
.setContent('<p>Please do not delete pre-existing features</p>')
.addTo(map);
}
});
options.onDrawnItemsChange(drawnItems.getLayers());
});

map.on(L.Draw.Event.EDITSTOP, (e) => {
options.onDrawnItemsChange(drawnItems.getLayers());
});
Expand Down Expand Up @@ -270,5 +284,75 @@ class MapService {
}
return false;
}
isDefaultFeature(feature): boolean {
const defaults = this.options.defaultValue.features;
if (defaults.length === 0) {
return false;
}
const featureType = this.getFeatureType(feature);
const sameTypes = defaults.filter((d) => {
return d.type === featureType;
}); // filter out the types that don't match the marker to be deleted
if (sameTypes.length === 0) {
return false;
}
return sameTypes.some((f) => {
// returns true if one of the filtered defaults
switch (featureType) {
case 'marker':
return this.coordinatesEqual(f.coordinates, feature.getLatLng());
case 'rectangle':
return f.bounds === feature.getBounds();
case 'circle':
const radCheck = f.radius === feature.getRadius();
const pointCheck = this.coordinatesEqual(
f.coordinates,
feature.getLatLng()
);
return radCheck && pointCheck;
case 'polygon':
return this.polyEqual(f.coordinates, feature.getLatLngs());
case 'polyline':
return this.polyEqual(f.coordinates, feature.getLatLngs());
default:
return false;
}
});
}
getFeatureType(feature) {
if (feature instanceof L.Marker) {
return 'marker';
} else if (feature instanceof L.Rectangle) {
return 'rectangle';
} else if (feature instanceof L.Circle) {
return 'circle';
} else if (feature instanceof L.Polygon) {
return 'polygon';
} else if (feature instanceof L.Polyline) {
return 'polyline';
}
}
coordinatesEqual(c1, c2) {
return c1.lat === c2.lat && c1.lng === c2.lng;
}
polyEqual(c1, c2) {
if (c1[0] instanceof Array) {
c1 = c1[0];
}
if (c2[0] instanceof Array) {
c2 = c2[0];
}
if (c1.length !== c2.length) {
// different number of vertices, no match
return false;
} else {
for (let i = 0; i < c1.length; i++) {
if (!this.coordinatesEqual(c1[i], c2[i])) {
return false; // if there's no match in one of the points, it's a new feature
}
}
return true;
}
}
}
export default MapService;
Loading