-
Notifications
You must be signed in to change notification settings - Fork 19
feat(#560): edit coordinates for a vertex or feature #606
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
bae07a6
Advanced panel component
latin-panda 74f9517
file parsing to coords array
latin-panda db94e62
updates event name
latin-panda 6df2619
save new value and validations
latin-panda e24b60b
Adds support for editing point feature
latin-panda b52e8ae
Adds changeset
latin-panda 4d61399
Test coverage and cleaning
latin-panda cbac4ab
restructure geojson parsers and keep bundle slim
latin-panda c18a3dd
test coverage for geojson parsers
latin-panda 47c9fdd
e2e tests
latin-panda b910e8b
lint
latin-panda 2dc797a
cleans code
latin-panda 67d4a7e
refactored draw feature type to single feature type to count for poin…
latin-panda 46a1290
Improves status message
latin-panda acf5117
fixes lint
latin-panda 08cef2c
Merge branch 'main' of https://github.com/getodk/web-forms into edit-…
latin-panda bfaf87b
merge test
latin-panda f865aa5
Merge branch 'main' of https://github.com/getodk/web-forms into edit-…
latin-panda 71e1a39
feedback
latin-panda 50c180b
revert changes for placement map in e2e tests
latin-panda cf69983
Resolves new design feedback
latin-panda 3478e9e
new feature on paste or upload
latin-panda 4c07e9c
Code clean up
latin-panda 7e73647
Fixes feedback
latin-panda 3fbf50a
Fixes feedback
latin-panda dc2a6cc
Fixes designer feedback
latin-panda 2bd6a29
Fixes designer feedback
latin-panda 1287a7a
Feedback
latin-panda 6962be5
Feedback file name
latin-panda fba07a1
Merge branch 'main' of https://github.com/getodk/web-forms into edit-…
latin-panda be5ea61
Feedback and fixes merge conflict
latin-panda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@getodk/web-forms': minor | ||
| --- | ||
|
|
||
| Adds support for editing the coordinates in geoshape and geotrace question types. |
Binary file modified
BIN
+4.57 KB
(100%)
...al/all-question-types.test.ts-snapshots/geoshape-autoclose-polygon-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.85 KB
(100%)
...ual/all-question-types.test.ts-snapshots/geoshape-autoclose-polygon-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.92 KB
(100%)
...sual/all-question-types.test.ts-snapshots/geoshape-autoclose-polygon-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.54 KB
(100%)
.../visual/all-question-types.test.ts-snapshots/geoshape-three-points-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.3 KB
(110%)
...s/visual/all-question-types.test.ts-snapshots/geoshape-three-points-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.58 KB
(100%)
...es/visual/all-question-types.test.ts-snapshots/geoshape-three-points-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.38 KB
(110%)
...es/visual/all-question-types.test.ts-snapshots/geotrace-two-points-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.82 KB
(110%)
...ses/visual/all-question-types.test.ts-snapshots/geotrace-two-points-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.59 KB
(100%)
...ases/visual/all-question-types.test.ts-snapshots/geotrace-two-points-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
269 changes: 269 additions & 0 deletions
269
packages/web-forms/src/components/common/map/MapAdvancedPanel.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,269 @@ | ||
| <script setup lang="ts"> | ||
| import IconSVG from '@/components/common/IconSVG.vue'; | ||
| import { | ||
| isNullLocation, | ||
| isValidLatitude, | ||
| isValidLongitude, | ||
| toGeoJsonCoordinateArray, | ||
| } from '@/components/common/map/geojson-parsers.ts'; | ||
| import { fromLonLat } from 'ol/proj'; | ||
| import { computed, ref, watch } from 'vue'; | ||
| import type { Coordinate } from 'ol/coordinate'; | ||
|
|
||
| const props = defineProps<{ | ||
| isOpen: boolean; | ||
| coordinates: Coordinate | null; | ||
| }>(); | ||
|
|
||
| const emit = defineEmits(['open-paste-dialog', 'save']); | ||
|
|
||
| const latitude = ref<number | undefined>(); | ||
| const longitude = ref<number | undefined>(); | ||
| const accuracy = ref<number | undefined>(); | ||
| const altitude = ref<number | undefined>(); | ||
| const disableInputs = computed(() => !props.coordinates?.length); | ||
| const validLatitude = computed(() => { | ||
| return isValidLatitude(latitude.value) && !isNullLocation(latitude.value, longitude.value); | ||
| }); | ||
| const validLongitude = computed(() => { | ||
| return isValidLongitude(longitude.value) && !isNullLocation(latitude.value, longitude.value); | ||
| }); | ||
|
|
||
| watch( | ||
| () => props.coordinates, | ||
| (newVal) => { | ||
| if (newVal) { | ||
| [longitude.value, latitude.value, altitude.value, accuracy.value] = newVal; | ||
| return; | ||
| } | ||
| accuracy.value = undefined; | ||
| latitude.value = undefined; | ||
| altitude.value = undefined; | ||
| longitude.value = undefined; | ||
| }, | ||
| { immediate: true } | ||
| ); | ||
|
|
||
| const updateVertex = () => { | ||
| if (!validLatitude.value || !validLongitude.value) { | ||
| return; | ||
| } | ||
|
|
||
| const newVertex = toGeoJsonCoordinateArray( | ||
| Number(longitude.value), | ||
| Number(latitude.value), | ||
| Number(altitude.value), | ||
| Number(accuracy.value) | ||
| ) as Coordinate; | ||
|
|
||
| if (newVertex.length) { | ||
| emit('save', fromLonLat(newVertex)); | ||
| } | ||
| }; | ||
| </script> | ||
|
|
||
| <template> | ||
| <transition name="panel"> | ||
| <div v-if="isOpen" class="advanced-panel"> | ||
| <div class="fields-container"> | ||
| <div :class="{ 'field-error': !disableInputs && !validLongitude }" class="field-set"> | ||
| <div class="input-wrap"> | ||
| <!-- TODO: translations --> | ||
| <label for="longitude">Longitude</label> | ||
| <input | ||
| id="longitude" | ||
| v-model="longitude" | ||
| type="number" | ||
| :disabled="disableInputs" | ||
| @change="updateVertex" | ||
| > | ||
| </div> | ||
| <!-- TODO: translations --> | ||
| <p class="field-error-message"> | ||
| Longitude is invalid | ||
| </p> | ||
| </div> | ||
| <div :class="{ 'field-error': !disableInputs && !validLatitude }" class="field-set"> | ||
| <div class="input-wrap"> | ||
| <!-- TODO: translations --> | ||
| <label for="latitude">Latitude</label> | ||
| <input | ||
| id="latitude" | ||
| v-model="latitude" | ||
| type="number" | ||
| :disabled="disableInputs" | ||
| @change="updateVertex" | ||
| > | ||
| </div> | ||
| <!-- TODO: translations --> | ||
| <p class="field-error-message"> | ||
| Latitude is invalid | ||
| </p> | ||
| </div> | ||
| <div class="field-set"> | ||
| <div class="input-wrap"> | ||
| <!-- TODO: translations --> | ||
| <label for="altitude">Altitude</label> | ||
| <input | ||
| id="altitude" | ||
| v-model="altitude" | ||
| type="number" | ||
| :disabled="disableInputs" | ||
| @change="updateVertex" | ||
| > | ||
| </div> | ||
| </div> | ||
| <div class="field-set"> | ||
| <div class="input-wrap"> | ||
| <!-- TODO: translations --> | ||
| <label for="accuracy">Accuracy</label> | ||
| <input | ||
| id="accuracy" | ||
| v-model="accuracy" | ||
| type="number" | ||
| :disabled="disableInputs" | ||
| @change="updateVertex" | ||
| > | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <a class="paste-location" @click="emit('open-paste-dialog')"> | ||
| <IconSVG name="mdiFileOutline" size="sm" /> | ||
| <!-- TODO: translations --> | ||
| <strong>Import data to replace location</strong> | ||
| </a> | ||
| </div> | ||
| </transition> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .advanced-panel { | ||
| --odk-double-map-spacing: calc(var(--odk-map-controls-spacing) * 2); | ||
| } | ||
|
|
||
| .advanced-panel { | ||
| background: var(--odk-base-background-color); | ||
| border-top: 1px solid var(--odk-border-color); | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: flex-start; | ||
| gap: 3px; | ||
| } | ||
|
|
||
| .fields-container { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: var(--odk-double-map-spacing); | ||
| padding: var(--odk-double-map-spacing) var(--odk-map-controls-spacing); | ||
|
|
||
| .field-set { | ||
| display: flex; | ||
| flex: 1 1 calc(50% - var(--odk-double-map-spacing)); | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .input-wrap { | ||
| display: flex; | ||
| flex-direction: row; | ||
| border-radius: var(--odk-radius); | ||
| overflow: hidden; | ||
| background-color: var(--odk-muted-background-color); | ||
| height: 38px; | ||
| min-width: 250px; | ||
| } | ||
|
|
||
| label { | ||
| padding: var(--odk-map-controls-spacing); | ||
| background-color: var(--odk-light-background-color); | ||
| color: var(--odk-text-color); | ||
| font-weight: normal; | ||
| font-size: var(--odk-base-font-size); | ||
| border-radius: var(--odk-radius) 0 0 var(--odk-radius); | ||
| border: 1px solid var(--odk-border-color); | ||
| border-right: none; | ||
| display: flex; | ||
| align-items: center; | ||
| white-space: nowrap; | ||
| flex-basis: 110px; | ||
| flex-shrink: 0; | ||
| max-width: 150px; | ||
| } | ||
|
|
||
| input { | ||
| padding: var(--odk-map-controls-spacing); | ||
| width: 100%; | ||
| background-color: var(--odk-base-background-color); | ||
| border-radius: 0 var(--odk-radius) var(--odk-radius) 0; | ||
| border: 1px solid var(--odk-border-color); | ||
| font-size: var(--odk-base-font-size); | ||
| color: var(--odk-text-color); | ||
| -moz-appearance: textfield; | ||
|
|
||
| &:focus-visible { | ||
| outline: none; | ||
| outline-offset: unset; | ||
| } | ||
|
|
||
| &::-webkit-outer-spin-button, | ||
| &::-webkit-inner-spin-button { | ||
| appearance: none; | ||
| -webkit-appearance: none; | ||
| margin: 0; | ||
| } | ||
|
|
||
| &:disabled { | ||
| background-color: var(--odk-muted-background-color); | ||
| cursor: not-allowed; | ||
| } | ||
| } | ||
|
|
||
| .field-error-message { | ||
| margin: 8px 0 0 0; | ||
| color: var(--odk-error-text-color); | ||
| display: none; | ||
| } | ||
|
|
||
| .field-error { | ||
| .field-error-message { | ||
| display: block; | ||
| } | ||
|
|
||
| .input-wrap input { | ||
| border: 1px solid var(--odk-error-text-color); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .paste-location { | ||
| display: flex; | ||
| flex-direction: row; | ||
| align-items: center; | ||
| gap: 8px; | ||
| padding: var(--odk-double-map-spacing); | ||
| text-decoration: none; | ||
| cursor: pointer; | ||
| font-size: var(--odk-base-font-size); | ||
| color: var(--odk-text-color); | ||
| } | ||
|
|
||
| .panel-enter-active, | ||
| .panel-leave-active { | ||
| transition: | ||
| max-height 0.6s ease-in-out, | ||
| opacity 0.6s ease-in-out; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .panel-enter-from, | ||
| .panel-leave-to { | ||
| max-height: 0; | ||
| opacity: 0; | ||
| } | ||
|
|
||
| .panel-enter-to, | ||
| .panel-leave-from { | ||
| max-height: 300px; | ||
| opacity: 1; | ||
| } | ||
| </style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meta-comment: maybe we should configure LFS for these images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion! I've created an issue and will bring it to the team