diff --git a/src/Biopen/GeoDirectoryBundle/Admin/ImportAdmin.php b/src/Biopen/GeoDirectoryBundle/Admin/ImportAdmin.php index fa766bef170ba0436c74e4caac4a0fd3960c7848..268abfb248a1cc351bab4e2e2ee6e81c06eaa807 100755 --- a/src/Biopen/GeoDirectoryBundle/Admin/ImportAdmin.php +++ b/src/Biopen/GeoDirectoryBundle/Admin/ImportAdmin.php @@ -90,15 +90,19 @@ class ImportAdmin extends AbstractAdmin if ($this->getSubject()->getId()) { + $title = 'Table de correspondance des champs'; + if ($this->getSubject()->getNewOntologyToMap()) $title .= ' <label class="label label-info">Nouveaux champs</label>'; $formMapper - ->tab('Table de correspondance des champs') + ->tab($title) ->with('Transformer les données à importer') ->add('ontologyMapping', 'hidden', array('attr' => ['class' => 'gogo-mapping-ontology', 'data-form-props' => $formProperties, 'data-props' => $elementProperties])) ->end() ->end(); if (count($this->getSubject()->getOntologyMapping()) > 0) { - $formMapper->tab('Table de correspondance des catégories') + $title = 'Table de correspondance des catégories'; + if ($this->getSubject()->getNewTaxonomyToMap()) $title .= ' <label class="label label-info">Nouvelles catégories</label>'; + $formMapper->tab($title) ->with('Faites correspondre les catégories') ->add('taxonomyMapping', 'hidden', array('attr' => ['class' => 'gogo-mapping-taxonomy', 'data-options' => $optionsList])) ->end() diff --git a/src/Biopen/GeoDirectoryBundle/Controller/Admin/ImportAdminController.php b/src/Biopen/GeoDirectoryBundle/Controller/Admin/ImportAdminController.php index d8896a7887bbd7ba815fb0bc3e7d07f66692b771..8c2a1d4c9b136deeba8b98bc1c9385af510d7d15 100755 --- a/src/Biopen/GeoDirectoryBundle/Controller/Admin/ImportAdminController.php +++ b/src/Biopen/GeoDirectoryBundle/Controller/Admin/ImportAdminController.php @@ -94,6 +94,8 @@ class ImportAdminController extends Controller // ----- CUSTOM ------- $object->setOntologyMapping($request->get('ontology')); $object->setTaxonomyMapping($request->get('taxonomy')); + $object->setNewOntologyToMap(false); + $object->setNewTaxonomyToMap(false); // ---- END CUSTOM ------ diff --git a/src/Biopen/GeoDirectoryBundle/Document/Import.php b/src/Biopen/GeoDirectoryBundle/Document/Import.php index f8532e1e263aeaec7b972fe66f444e5bb88756d8..12dc5bd6f98621825208f551708756866ce974ac 100644 --- a/src/Biopen/GeoDirectoryBundle/Document/Import.php +++ b/src/Biopen/GeoDirectoryBundle/Document/Import.php @@ -119,11 +119,21 @@ class Import extends AbstractFile */ private $ontologyMapping = []; + /** + * @MongoDB\Field(type="bool") + */ + private $newOntologyToMap = false; + /** * @MongoDB\Field(type="hash") */ private $taxonomyMapping = []; + /** + * @MongoDB\Field(type="bool") + */ + private $newTaxonomyToMap = false; + /** * Custom code made by the user to be run on the $data object when importing * @MongoDB\Field(type="string") @@ -581,4 +591,48 @@ class Import extends AbstractFile { return $this->createdAt; } + + /** + * Set newOntologyToMap + * + * @param bool $newOntologyToMap + * @return $this + */ + public function setNewOntologyToMap($newOntologyToMap) + { + $this->newOntologyToMap = $newOntologyToMap; + return $this; + } + + /** + * Get newOntologyToMap + * + * @return bool $newOntologyToMap + */ + public function getNewOntologyToMap() + { + return $this->newOntologyToMap; + } + + /** + * Set newTaxonomyToMap + * + * @param bool $newTaxonomyToMap + * @return $this + */ + public function setNewTaxonomyToMap($newTaxonomyToMap) + { + $this->newTaxonomyToMap = $newTaxonomyToMap; + return $this; + } + + /** + * Get newTaxonomyToMap + * + * @return bool $newTaxonomyToMap + */ + public function getNewTaxonomyToMap() + { + return $this->newTaxonomyToMap; + } } diff --git a/src/Biopen/GeoDirectoryBundle/Resources/views/admin/core_custom/base_edit.html.twig b/src/Biopen/GeoDirectoryBundle/Resources/views/admin/core_custom/base_edit.html.twig index 247cbf3103410af7eacf2ba62e8be621f45560cf..b4ffcc7d93b1e09dfe4e4060f9e9b72e3ede5b86 100644 --- a/src/Biopen/GeoDirectoryBundle/Resources/views/admin/core_custom/base_edit.html.twig +++ b/src/Biopen/GeoDirectoryBundle/Resources/views/admin/core_custom/base_edit.html.twig @@ -8,7 +8,7 @@ <div class="nav-tabs-custom"> <ul class="nav nav-tabs" role="tablist"> {% for name, form_tab in admin.formtabs %} - <li{% if loop.index == 1 %} class="tab-first"{% endif %}><a href="#tab_{{ loop.index }}" data-toggle="tab"><i class="fa fa-exclamation-circle has-errors hide" aria-hidden="true"></i> {{ name|trans({}, form_tab.translation_domain ?: admin.translationDomain) }}</a></li> + <li{% if loop.index == 1 %} class="tab-first"{% endif %}><a href="#tab_{{ loop.index }}" data-toggle="tab"><i class="fa fa-exclamation-circle has-errors hide" aria-hidden="true"></i> {{ name|trans({}, form_tab.translation_domain ?: admin.translationDomain)|raw }}</a></li> {% endfor %} </ul> <div class="tab-content"> @@ -35,9 +35,9 @@ <script> $(document).ready(function() { - $('.nav-tabs li a').click(function() { + $('.nav-tabs li a').click(function() { var newHash = $(this).attr('href'); - window.location.hash = newHash; + window.location.hash = newHash; var url = $('form').attr('action'); $('form').attr('action', url.split('#')[0] + newHash); }); @@ -48,7 +48,7 @@ } else { $('li.tab-first').addClass('active'); } - + }); </script> {% endblock %} \ No newline at end of file diff --git a/src/Biopen/GeoDirectoryBundle/Resources/views/admin/partials/import/list_non_visibles_count.html.twig b/src/Biopen/GeoDirectoryBundle/Resources/views/admin/partials/import/list_non_visibles_count.html.twig index 437c50e6ab77485b4f663882ec050ef61680c579..4825ff82c80fc5caaee4bd38e74728adbdcb4c25 100644 --- a/src/Biopen/GeoDirectoryBundle/Resources/views/admin/partials/import/list_non_visibles_count.html.twig +++ b/src/Biopen/GeoDirectoryBundle/Resources/views/admin/partials/import/list_non_visibles_count.html.twig @@ -2,15 +2,23 @@ {% block field %} {% spaceless %} + {% if object.newOntologyToMap %} + <span class="label label-info log-label">Nouveaux champs à mapper</span> + {% endif %} + + {% if object.newTaxonomyToMap %} + <span class="label label-info log-label">Nouvelles caatégories à mapper</span> + {% endif %} + {% set deletedCount = field_description.options.choices[object.id] is defined ? field_description.options.choices[object.id] : 0 %} {% if deletedCount > 0 %} <span class="label label-danger log-label">{{ deletedCount }} localement supprimés</span> - {% endif %} + {% endif %} {% if object.logs|length > 0 %} {% set log = object.logs[0] %} {% if log.getDataProp('elementsMissingGeoCount') > 0 %} <span class="label label-warning log-label">{{ log.getDataProp('elementsMissingGeoCount') }} sans geoloc</span> - {% endif %} + {% endif %} {% if log.getDataProp('elementsMissingTaxoCount') > 0 %} <span class="label label-warning log-label">{{ log.getDataProp('elementsMissingTaxoCount') }} sans categories</span> {% endif %} diff --git a/src/Biopen/GeoDirectoryBundle/Services/ElementImportMappingService.php b/src/Biopen/GeoDirectoryBundle/Services/ElementImportMappingService.php index 2ced411069df16f24f0669738bee32dde9212447..42499334dc1a82371908e7955560c39a0acfd1bc 100644 --- a/src/Biopen/GeoDirectoryBundle/Services/ElementImportMappingService.php +++ b/src/Biopen/GeoDirectoryBundle/Services/ElementImportMappingService.php @@ -115,9 +115,9 @@ class ElementImportMappingService foreach($data as $row) { foreach ($row as $key => $value) { - $this->collectKey($key); + $this->collectKey($key, null, $import); if ($this->isAssociativeArray($value) && !in_array($key, ['openHours', 'modifiedElement'])) { - foreach ($value as $subkey => $subvalue) { $this->collectKey($subkey, $key); } + foreach ($value as $subkey => $subvalue) { $this->collectKey($subkey, $key, $import); } } } } @@ -129,7 +129,7 @@ class ElementImportMappingService $import->setOntologyMapping($this->ontologyMapping); } - private function collectKey($key, $parentKey = null) { + private function collectKey($key, $parentKey = null, $import) { if (in_array($key, ['__initializer__', '__cloner__', '__isInitialized__'])) return; $keyName = $parentKey ? $parentKey . '/' . $key : $key; if (!$keyName || strlen($keyName) == 0) return; @@ -142,7 +142,10 @@ class ElementImportMappingService $value = $this->mappedCoreFields[$keyLower]; // Asign mapping if (!$value || !in_array($value, array_values($this->ontologyMapping))) + { $this->ontologyMapping[$keyName] = $value; + $import->setNewOntologyToMap(true); + } } } @@ -176,6 +179,7 @@ class ElementImportMappingService if ($value == '' && $this->createMissingOptions) $value = $this->createOption($category); $taxonomyMapping[$category] = $value; + $import->setNewTaxonomyToMap(true); } // create options for previously imported non mapped options if (array_key_exists($category, $taxonomyMapping) diff --git a/src/Biopen/GeoDirectoryBundle/Services/ElementImportOneService.php b/src/Biopen/GeoDirectoryBundle/Services/ElementImportOneService.php index f3c62cf4b0940c4bb7cdd11f5f02050ed6986997..8e83f00fa2fc6bff7579f6e2cd156fdd26b457d5 100755 --- a/src/Biopen/GeoDirectoryBundle/Services/ElementImportOneService.php +++ b/src/Biopen/GeoDirectoryBundle/Services/ElementImportOneService.php @@ -197,7 +197,7 @@ class ElementImportOneService private function createOpenHours($element, $row) { if (!isset($row['openhours']) || !$this->isAssociativeArray($row['openhours'])) return; - $element->setOpenHours(new OpenHours($row['openHours'])); + $element->setOpenHours(new OpenHours($row['openhours'])); } private function isAssociativeArray($a) {