Skip to content
Snippets Groups Projects
Unverified Commit 8ceb29f1 authored by Sebastian Castro's avatar Sebastian Castro
Browse files

import: fix saving sourceType

parent 289acd1c
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -28,6 +28,7 @@ document.addEventListener('DOMContentLoaded', function() {
mounted() { mounted() {
for(let key in importObject) this[key] = importObject[key] for(let key in importObject) this[key] = importObject[key]
this.osmQueriesJson = JSON.parse(this.osmQueriesJson) this.osmQueriesJson = JSON.parse(this.osmQueriesJson)
this.sourceType = sourceType;
this.formName = formName this.formName = formName
$(`#sonata-ba-field-container-${formName}_file`).appendTo('.file-container') $(`#sonata-ba-field-container-${formName}_file`).appendTo('.file-container')
} }
......
...@@ -120,7 +120,7 @@ class ImportAdminController extends Controller ...@@ -120,7 +120,7 @@ class ImportAdminController extends Controller
if ($isFormValid) { if ($isFormValid) {
try { try {
$dm = $this->container->get('doctrine_mongodb')->getManager(); $dm = $this->container->get('doctrine_mongodb')->getManager();
$object->setSourceType($request->get('sourceType'));
$ontology = $request->get('ontology'); $ontology = $request->get('ontology');
// Fix ontology mapping for elements fields with reverse value // Fix ontology mapping for elements fields with reverse value
......
...@@ -209,7 +209,7 @@ class Import extends AbstractFile ...@@ -209,7 +209,7 @@ class Import extends AbstractFile
} }
public function getSourceType() public function getSourceType()
{ {
if ($this->sourceType) return $this->sourceType; if (isset($this->sourceType)) return $this->sourceType;
if (isset($this->osmQueriesJson)) return 'openstreetmap'; if (isset($this->osmQueriesJson)) return 'openstreetmap';
if ($this->url) return 'json'; if ($this->url) return 'json';
if ($this->file) return 'csv'; if ($this->file) return 'csv';
......
{% set formName = form.vars.full_name|split('[')|first %} {% set formName = form.vars.full_name|split('[')|first %}
<div id="element-import"> <div id="element-import">
<select class="source-type form-control" data-sonata-select2="false" v-model="sourceType" :name="`${formName}[sourceType]`"> <select class="source-type form-control" data-sonata-select2="false" v-model="sourceType" name="sourceType">
<option></option> <option></option>
<option value="csv">Fichier CSV</option> <option value="csv">Fichier CSV</option>
<option value="json">API Json</option> <option value="json">API Json</option>
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<script> <script>
var importObject = {{ form.vars.sonata_admin.admin.subject|json_encode|raw }} var importObject = {{ form.vars.sonata_admin.admin.subject|json_encode|raw }}
var sourceType = "{{ form.vars.sonata_admin.admin.subject.getSourceType() }}"
var formName = {{ form.vars.full_name|split('[')|first|json_encode|raw }} var formName = {{ form.vars.full_name|split('[')|first|json_encode|raw }}
// See element-import.js Vue Component // See element-import.js Vue Component
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment