From 159cda2118b95eba3dfa776d7a3bab4608655321 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Thu, 10 Dec 2020 11:41:51 +0100 Subject: [PATCH 01/30] Add prettierrc config file to avoid breaking source code --- .prettierrc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..896721e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "$schema": "http://json.schemastore.org/prettierrc", + "arrowParens": "avoid", + "semi": false, + "singleQuote": true, + "trailingComma": "none", + "useTabs": false +} \ No newline at end of file From 8d556987d18d87a6d46e8e60bc21c92b03b64278 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Thu, 10 Dec 2020 11:42:12 +0100 Subject: [PATCH 02/30] Add fixtures for geopoint field --- .env | 2 +- public/schema-geopoint-fixture.json | 14 ++++++++++++++ public/schemas-fixture.json | 11 +++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 public/schema-geopoint-fixture.json create mode 100644 public/schemas-fixture.json diff --git a/.env b/.env index 1e66aab..f4a19c5 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ VUE_APP_VALIDATA_API_URL=https://api.validata.etalab.studio -VUE_APP_SCHEMAS_CATALOG_URL=https://schema.data.gouv.fr/schemas/schemas.json +VUE_APP_SCHEMAS_CATALOG_URL=/schemas-fixture.json diff --git a/public/schema-geopoint-fixture.json b/public/schema-geopoint-fixture.json new file mode 100644 index 0000000..56c0743 --- /dev/null +++ b/public/schema-geopoint-fixture.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://frictionlessdata.io/schemas/table-schema.json", + "title": "Schema fixture with geopoint", + "fields": [ + { + "name": "id_lieu", + "type": "string" + }, + { + "name": "location", + "type": "geopoint" + } + ] +} \ No newline at end of file diff --git a/public/schemas-fixture.json b/public/schemas-fixture.json new file mode 100644 index 0000000..b4c8dd9 --- /dev/null +++ b/public/schemas-fixture.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://opendataschema.frama.io/catalog/schema-catalog.json", + "version": 1, + "schemas": [ + { + "name": "schema-geopoint-fixture", + "title": "Schema fixture with geopoint", + "schema_url": "http://csvgg.loca.lt/schema-geopoint-fixture.json" + } + ] +} \ No newline at end of file From 9b10f63f6915cdfb8607cd6650668634138ee66f Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Thu, 10 Dec 2020 11:42:45 +0100 Subject: [PATCH 03/30] Add GeoPointField stub --- src/components/GeoPointField.vue | 25 +++++++++++++++++++++++++ src/views/SchemaForm.vue | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 src/components/GeoPointField.vue diff --git a/src/components/GeoPointField.vue b/src/components/GeoPointField.vue new file mode 100644 index 0000000..b34b25b --- /dev/null +++ b/src/components/GeoPointField.vue @@ -0,0 +1,25 @@ + + diff --git a/src/views/SchemaForm.vue b/src/views/SchemaForm.vue index cce28ea..ba23c64 100644 --- a/src/views/SchemaForm.vue +++ b/src/views/SchemaForm.vue @@ -23,6 +23,7 @@ import Vue from 'vue' import StringField from '@/components/StringField.vue' import SelectField from '@/components/SelectField.vue' import RadioField from '@/components/RadioField.vue' +import GeoPointField from '@/components/GeoPointField.vue' import { EventBus } from '@/event-bus.js'; const VALIDATA_API_URL = process.env.VUE_APP_VALIDATA_API_URL @@ -164,6 +165,7 @@ export default { addField(field) { const hasEnum = field.constraints && field.constraints.enum const isBoolean = field.type === "boolean" + const isGeoPoint = field.type === "geopoint" const factory = (klass, field) => { const className = Vue.extend(klass) @@ -176,6 +178,8 @@ export default { return factory(SelectField, field) } else if (isBoolean) { return factory(RadioField, field) + } else if (isGeoPoint) { + return factory(GeoPointField, field) } return factory(StringField, field) }, From 9977a252d4c31eb95da0c4d31088a689558b5584 Mon Sep 17 00:00:00 2001 From: Pierre Dittgen Date: Thu, 10 Dec 2020 18:10:46 +0100 Subject: [PATCH 04/30] wip --- package.json | 4 ++- src/components/GeoPointField.vue | 56 ++++++++++++++++++++++++++++++-- src/main.js | 15 +++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1761249..b0e3440 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,12 @@ "dependencies": { "babel-runtime": "^6.26.0", "bootstrap-vue": "^2.0.0-rc.15", + "leaflet": "^1.7.1", "vue": "^2.6.6", "vue-loading-overlay": "^3.2.0", "vue-markdown": "^2.2.4", - "vue-router": "^3.0.1" + "vue-router": "^3.0.1", + "vue2-leaflet": "^2.6.0" }, "devDependencies": { "@vue/cli-plugin-babel": "^3.12.0", diff --git a/src/components/GeoPointField.vue b/src/components/GeoPointField.vue index b34b25b..cc4d309 100644 --- a/src/components/GeoPointField.vue +++ b/src/components/GeoPointField.vue @@ -1,6 +1,6 @@ + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 197ba18..2b8baab 100644 --- a/src/main.js +++ b/src/main.js @@ -3,15 +3,30 @@ import App from './App.vue' import router from './router' import BootstrapVue from 'bootstrap-vue' import Loading from 'vue-loading-overlay' +import { LMap, LTileLayer, LMarker } from 'vue2-leaflet'; +import { Icon } from 'leaflet'; import 'vue-loading-overlay/dist/vue-loading.css' import 'bootstrap/dist/css/bootstrap.css' import 'bootstrap-vue/dist/bootstrap-vue.css' +import 'leaflet/dist/leaflet.css'; + +// https://vue2-leaflet.netlify.app/quickstart/#marker-icons-are-missing +delete Icon.Default.prototype._getIconUrl; +Icon.Default.mergeOptions({ + iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'), + iconUrl: require('leaflet/dist/images/marker-icon.png'), + shadowUrl: require('leaflet/dist/images/marker-shadow.png'), +}); Vue.config.productionTip = false Vue.use(BootstrapVue) Vue.use(Loading) +Vue.component('l-map', LMap); +Vue.component('l-tile-layer', LTileLayer); +Vue.component('l-marker', LMarker); + new Vue({ router, render: h => h(App) From b4a4814bbc0a5caf431d865fc7b03f1447965a2d Mon Sep 17 00:00:00 2001 From: Pierre Dittgen Date: Mon, 14 Dec 2020 18:43:08 +0100 Subject: [PATCH 05/30] first geopoint widget --- src/components/GeoPointField.vue | 100 ++++++++++++++----------------- src/main.js | 3 +- 2 files changed, 48 insertions(+), 55 deletions(-) diff --git a/src/components/GeoPointField.vue b/src/components/GeoPointField.vue index cc4d309..d2d0cc0 100644 --- a/src/components/GeoPointField.vue +++ b/src/components/GeoPointField.vue @@ -1,16 +1,26 @@ @@ -18,58 +28,40 @@ - - \ No newline at end of file diff --git a/src/main.js b/src/main.js index 2b8baab..39af96c 100644 --- a/src/main.js +++ b/src/main.js @@ -3,7 +3,7 @@ import App from './App.vue' import router from './router' import BootstrapVue from 'bootstrap-vue' import Loading from 'vue-loading-overlay' -import { LMap, LTileLayer, LMarker } from 'vue2-leaflet'; +import { LMap, LTileLayer, LMarker, LTooltip } from 'vue2-leaflet'; import { Icon } from 'leaflet'; import 'vue-loading-overlay/dist/vue-loading.css' @@ -26,6 +26,7 @@ Vue.use(Loading) Vue.component('l-map', LMap); Vue.component('l-tile-layer', LTileLayer); Vue.component('l-marker', LMarker); +Vue.component('l-tooltip', LTooltip); new Vue({ router, From 218ac17dd2a5eb4578ec7d0d2bc814da678bec24 Mon Sep 17 00:00:00 2001 From: Pierre Dittgen Date: Fri, 18 Dec 2020 15:37:22 +0100 Subject: [PATCH 06/30] wip --- src/components/GeoPointField.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/GeoPointField.vue b/src/components/GeoPointField.vue index d2d0cc0..cf551c6 100644 --- a/src/components/GeoPointField.vue +++ b/src/components/GeoPointField.vue @@ -47,7 +47,9 @@ export default { // as an array //const value = [center.lng, center.lat] // as a string - const value = center.lng + ", " + center.lat + // const value = center.lng + ", " + center.lat + const fp = this.floatPrecision + const value = `${center.lng.toFixed(fp)}, ${center.lat.toFixed(fp)}` // as an object (doesn't work) //const value = { lon: center.lng, lat: center.lat } EventBus.$emit('field-value-changed', this.field.name, value) @@ -60,7 +62,8 @@ export default { url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', attribution: '© OpenStreetMap contributors', markerLocation: [46, 2], - values: [[46, 2]] + values: [[46, 2]], + floatPrecision: 3 } }, } From 5f915df94c52e1b9bdd9659616c19e3d050c9c5f Mon Sep 17 00:00:00 2001 From: Pierre Dittgen Date: Mon, 21 Dec 2020 09:52:28 +0100 Subject: [PATCH 07/30] wip use button to show map --- src/components/GeoPointField.vue | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/GeoPointField.vue b/src/components/GeoPointField.vue index cf551c6..1ecb909 100644 --- a/src/components/GeoPointField.vue +++ b/src/components/GeoPointField.vue @@ -1,7 +1,26 @@