diff --git a/apps/andi/assets/css/ingestions.scss b/apps/andi/assets/css/ingestions.scss index 93343fee3..50d06e890 100644 --- a/apps/andi/assets/css/ingestions.scss +++ b/apps/andi/assets/css/ingestions.scss @@ -4,6 +4,7 @@ .ingestion-metadata-form { margin-bottom: 1rem; + margin-top: 1rem; } .selected-results-from-search.selected-dataset { diff --git a/apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex b/apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex index ff858899a..bfb92429f 100644 --- a/apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex +++ b/apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex @@ -28,6 +28,7 @@ defmodule AndiWeb.Helpers.MetadataFormHelpers do end def get_source_format_options(_), do: Options.source_format() + def get_source_format_options(), do: Options.source_format() def get_language(nil), do: "english" def get_language(lang), do: lang diff --git a/apps/andi/lib/andi_web/live/ingestion_live_view/data_dictionary_form.ex b/apps/andi/lib/andi_web/live/ingestion_live_view/data_dictionary_form.ex index f16a76f5a..2b5f27289 100644 --- a/apps/andi/lib/andi_web/live/ingestion_live_view/data_dictionary_form.ex +++ b/apps/andi/lib/andi_web/live/ingestion_live_view/data_dictionary_form.ex @@ -51,6 +51,12 @@ defmodule AndiWeb.IngestionLiveView.DataDictionaryForm do "expanded" -> "MINIMIZE" end + loader_visibility = + case assigns.loading_schema do + true -> "loading" + false -> "hidden" + end + ~L"""
@@ -73,10 +79,27 @@ defmodule AndiWeb.IngestionLiveView.DataDictionaryForm do
- <%= ErrorHelpers.error_tag(f, :schema, bind_to_input: false, class: "full-width") %> -
+
+ <%= if @sourceFormat in ["text/csv", "application/json"] and @is_curator do %> +
+
+
+ <%= label(f, :schema_sample, "Upload data sample", class: "label") %> + <%= file_input(f, :schema_sample, phx_hook: "readFile", accept: "text/csv, application/json") %> + <%= ErrorHelpers.error_tag(f, :schema_sample, bind_to_input: false) %> +
+
+ + +
+
+ <% end %> + + <%= ErrorHelpers.error_tag(f, :schema, bind_to_input: false, class: "full-width") %> +
+
Enter/Edit Fields
@@ -105,6 +128,7 @@ defmodule AndiWeb.IngestionLiveView.DataDictionaryForm do <%= live_component(@socket, AndiWeb.DataDictionary.RemoveFieldEditor, id: :data_dictionary_remove_field_editor, selected_field: @current_data_dictionary_item, visible: @remove_data_dictionary_field_visible) %> + <%= live_component(@socket, AndiWeb.DataDictionary.OverwriteSchemaModal, id: :overwrite_schema_modal, visibility: @overwrite_schema_visibility) %>
""" end @@ -496,9 +520,4 @@ defmodule AndiWeb.IngestionLiveView.DataDictionaryForm do _ -> {:noreply, assign(socket, changeset: new_changeset, loading_schema: false)} end end - - defp send_data_dictionary_status(changeset, socket) do - send(socket.parent_pid, {:update_data_dictionary_status, changeset.valid?}) - changeset - end end diff --git a/apps/andi/lib/andi_web/live/ingestion_live_view/edit_ingestion_live_view.ex b/apps/andi/lib/andi_web/live/ingestion_live_view/edit_ingestion_live_view.ex index 8eaa396fb..1865da8dc 100644 --- a/apps/andi/lib/andi_web/live/ingestion_live_view/edit_ingestion_live_view.ex +++ b/apps/andi/lib/andi_web/live/ingestion_live_view/edit_ingestion_live_view.ex @@ -14,27 +14,30 @@ defmodule AndiWeb.IngestionLiveView.EditIngestionLiveView do ~L""" <%= header_render(@socket, @is_curator) %>
-
-

Define Data Ingestion

-
- -
- <%= live_render(@socket, AndiWeb.IngestionLiveView.MetadataForm, id: :ingestion_metadata_form_editor, session: %{"ingestion" => @ingestion}) %> -
- -
-
- <%= live_render(@socket, AndiWeb.IngestionLiveView.ExtractSteps.ExtractStepForm, id: :extract_step_form_editor, session: %{"ingestion" => @ingestion, "order" => "1"}) %> + <%= f = form_for @changeset, "" %> + <%= hidden_input(f, :sourceFormat) %> +
+

Define Data Ingestion

-
- <%= live_render(@socket, AndiWeb.IngestionLiveView.DataDictionaryForm, id: :data_dictionary_form_editor, session: %{"ingestion" => @ingestion, "is_curator" => @is_curator, "order" => "2"}) %> +
+ <%= live_render(@socket, AndiWeb.IngestionLiveView.MetadataForm, id: :ingestion_metadata_form_editor, session: %{"ingestion" => @ingestion}) %>
-
- <%= live_render(@socket, AndiWeb.IngestionLiveView.FinalizeForm, id: :finalize_form_editor, session: %{"ingestion" => @ingestion, "order" => "4"}) %> +
+
+ <%= live_render(@socket, AndiWeb.IngestionLiveView.ExtractSteps.ExtractStepForm, id: :extract_step_form_editor, session: %{"ingestion" => @ingestion, "order" => "1"}) %> +
+ +
+ <%= live_render(@socket, AndiWeb.IngestionLiveView.DataDictionaryForm, id: :data_dictionary_form_editor, session: %{"ingestion" => @ingestion, "is_curator" => @is_curator, "order" => "2"}) %> +
+ +
+ <%= live_render(@socket, AndiWeb.IngestionLiveView.FinalizeForm, id: :finalize_form_editor, session: %{"ingestion" => @ingestion, "order" => "4"}) %> +
-
+
diff --git a/apps/andi/lib/andi_web/live/ingestion_live_view/metadata_form.ex b/apps/andi/lib/andi_web/live/ingestion_live_view/metadata_form.ex index 404ec9fa6..b63607c7a 100644 --- a/apps/andi/lib/andi_web/live/ingestion_live_view/metadata_form.ex +++ b/apps/andi/lib/andi_web/live/ingestion_live_view/metadata_form.ex @@ -13,6 +13,7 @@ defmodule AndiWeb.IngestionLiveView.MetadataForm do def mount(_, %{"ingestion" => ingestion}, socket) do changeset = IngestionMetadataFormSchema.changeset_from_andi_ingestion(ingestion) AndiWeb.Endpoint.subscribe("form-save") + AndiWeb.Endpoint.subscribe("source-format") {:ok, assign(socket, @@ -20,7 +21,8 @@ defmodule AndiWeb.IngestionLiveView.MetadataForm do select_dataset_modal_visibility: "hidden", search_results: [], search_text: "", - selected_dataset: ingestion.targetDataset + selected_dataset: ingestion.targetDataset, + ingestion_id: ingestion.id )} end @@ -34,7 +36,7 @@ defmodule AndiWeb.IngestionLiveView.MetadataForm do