From 4b56db3b9e35bd58c38a67294bd9ee8b19d17c19 Mon Sep 17 00:00:00 2001
From: Sebastian Castro <sebastian.castro@protonmail.com>
Date: Wed, 20 Jan 2021 11:40:17 +0100
Subject: [PATCH] map edit: provide liste of readonly sources

---
 src/Services/GoGoCartoJsService.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/Services/GoGoCartoJsService.php b/src/Services/GoGoCartoJsService.php
index f1363b915..97668dd44 100644
--- a/src/Services/GoGoCartoJsService.php
+++ b/src/Services/GoGoCartoJsService.php
@@ -45,6 +45,15 @@ class GoGoCartoJsService
             }
         }
 
+        $readonlySources = $this->dm->query('ImportDynamic')
+                                    ->field('isSynchronized')->notEqual(true)
+                                    ->select('sourceName')->getArray();
+        $editFeatureConf = [
+            'options' => ['readonlySources' => array_values($readonlySources)]
+        ];
+        if (!$config->getEditFeature()->isOnlyAllowedForAdmin()) {
+            $editFeatureConf['roles'] = ['anonymous', 'user', 'admin'];
+        }
         $result = [
             'security' => [
                 'userRoles' => $userGogocartoRole,
@@ -153,7 +162,7 @@ class GoGoCartoJsService
                 'edit' => $this->getConfigFrom(
                                 $config->getEditFeature(),
                                 'gogo_element_edit',
-                                $config->getEditFeature()->isOnlyAllowedForAdmin() ? [] : ['roles' => ['anonymous', 'user', 'admin']]
+                                $editFeatureConf
                             ),
                 'delete' => $this->getConfigFrom($config->getDeleteFeature(), 'gogo_delete_element'),
                 'sendMail' => [ 'url' => $this->getAbsolutePath('gogo_element_send_mail') ],
-- 
GitLab