diff --git a/assets/controllers/map_controller.js b/assets/controllers/map_controller.js index 8a94e12..e8df3c4 100644 --- a/assets/controllers/map_controller.js +++ b/assets/controllers/map_controller.js @@ -4,20 +4,43 @@ import 'leaflet'; export default class extends Controller { static values = { geojson: String, + icon: String, } connect() { + const simpleIcon = L.icon({ + iconUrl: this.iconValue, + iconSize: [16, 16], + iconAnchor: [8, 16], + popupAnchor: [0, 0], + }); + + const iconHtml = ` + + + + `; + const icons = { + 'danger': L.divIcon({ html: iconHtml, className: 'svg-icon text-danger', iconSize: [16, 16], iconAnchor: [8, 16], }), + 'warning': L.divIcon({ html: iconHtml, className: 'svg-icon text-warning', iconSize: [16, 16], iconAnchor: [8, 16], }), + 'success': L.divIcon({ html: iconHtml, className: 'svg-icon text-success', iconSize: [16, 16], iconAnchor: [8, 16], }), + }; + var map = L.map(this.element); L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map); + var layer = L.featureGroup(); + var geojsons = JSON.parse(this.geojsonValue); if (geojsons.length > 0) { geojsons.forEach(function (geojson) { + const feature0 = geojson.features[0].properties; - L.geoJSON(geojson, { + + const polygon = L.geoJSON(geojson, { style: function (feature) { var color = 'blue'; switch (feature.properties.color) { @@ -30,9 +53,18 @@ export default class extends Controller { }).bindTooltip(feature0.name).addTo(layer).on('click', function (event) { window.location.href = event.layer.feature.properties.url; }); + + L.marker(polygon.getBounds().getCenter(), { + icon: icons[feature0.color], + title: feature0.name, + clickUrl: feature0.url, + }).addTo(layer).on('click', function (event) { + window.location.href = event.target.options.clickUrl; + }); + }); layer.addTo(map); - console.log(layer.getBounds().toBBoxString()); + map.fitBounds(layer.getBounds()); } } diff --git a/assets/images/marker.svg b/assets/images/marker.svg new file mode 100644 index 0000000..bb2a150 --- /dev/null +++ b/assets/images/marker.svg @@ -0,0 +1,3 @@ + + + diff --git a/config/packages/workflow.yaml b/config/packages/workflow.yaml index 1407231..4bf092e 100644 --- a/config/packages/workflow.yaml +++ b/config/packages/workflow.yaml @@ -15,14 +15,17 @@ framework: metadata: title: 'À faire' color: danger + locking: false !php/const App\Entity\Task::STATUS_DOING: metadata: title: 'En cours' color: warning + locking: true !php/const App\Entity\Task::STATUS_DONE: metadata: title: 'Terminé' color: success + locking: false transitions: !php/const App\Entity\Task::TRANSITION_START: from: !php/const App\Entity\Task::STATUS_TODO @@ -30,21 +33,29 @@ framework: metadata: title: 'Commencer la tâche' route: 'app_task_start' + lock: true + unlock: false !php/const App\Entity\Task::TRANSITION_FINISH: from: !php/const App\Entity\Task::STATUS_DOING to: !php/const App\Entity\Task::STATUS_DONE metadata: title: 'Terminer la tâche' route: 'app_task_finish' + lock: false + unlock: true !php/const App\Entity\Task::TRANSITION_CANCEL: from: !php/const App\Entity\Task::STATUS_DOING to: !php/const App\Entity\Task::STATUS_TODO metadata: title: 'Abandonner la tâche' route: 'app_task_cancel' + lock: false + unlock: true !php/const App\Entity\Task::TRANSITION_RESET: from: !php/const App\Entity\Task::STATUS_DONE to: !php/const App\Entity\Task::STATUS_TODO metadata: title: 'Recommencer la tâche' route: 'app_task_reset' + lock: false + unlock: false diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php index d88fc03..1eb2545 100644 --- a/src/Controller/TaskController.php +++ b/src/Controller/TaskController.php @@ -179,7 +179,7 @@ class TaskController extends AbstractController 'Tâche modifiée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirectToRoute('app_task_show', ['projectSlug' => $projectSlug, 'taskSlug' => $taskSlug]); } catch (\Exception $exception) { $this->addFlash( 'danger', diff --git a/templates/macro.html.twig b/templates/macro.html.twig index d6a2b03..8614126 100644 --- a/templates/macro.html.twig +++ b/templates/macro.html.twig @@ -18,3 +18,7 @@ {% endif %} {% endmacro %} + +{% macro map(entity) %} +
+{% endmacro %} diff --git a/templates/project/show.html.twig b/templates/project/show.html.twig index fb60fc3..fb6c5e9 100644 --- a/templates/project/show.html.twig +++ b/templates/project/show.html.twig @@ -32,7 +32,7 @@

Carte

-
+ {{ macro.map(project) }}
diff --git a/templates/task/show.html.twig b/templates/task/show.html.twig index f0f28cc..3fc603b 100644 --- a/templates/task/show.html.twig +++ b/templates/task/show.html.twig @@ -1,4 +1,5 @@ {% extends 'base.html.twig' %} +{% import 'macro.html.twig' as macro %} {% block breadcrumb %} @@ -35,7 +36,7 @@

Carte

-
+ {{ macro.map(task) }}