Skip to content

Commit

Permalink
Merge pull request #1564 from UrbanOS-Public/982
Browse files Browse the repository at this point in the history
Andi Select Labels ADA
  • Loading branch information
c-m-duncan authored Jan 3, 2023
2 parents 0061895 + 7d5fff0 commit d813faa
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ defmodule AndiWeb.ExtractSteps.ExtractDateStepForm do
<div class="component-edit-section--<%= @visibility %>">
<div class="extract-date-step-form-edit-section form-grid">
<div class="extract-date-step-form__destination">
<%= label(f, :destination, DisplayNames.get(:destination), class: "label label--required") %>
<%= label(f, :destination, DisplayNames.get(:destination), class: "label label--required", for: "step-#{@id}__date-destination") %>
<%= text_input(f, :destination, [id: "step-#{@id}__date-destination", class: "extract-date-step-form__destination input", phx_focus: :get_example_output, phx_target: "#step-#{@id}", required: true]) %>
<%= ErrorHelpers.error_tag(f, :destination) %>
</div>
<div class="extract-date-step-form__deltaTimeUnit">
<%= label(f, :deltaTimeUnit, DisplayNames.get(:deltaTimeUnit), class: "label") %>
<%= label(f, :deltaTimeUnit, DisplayNames.get(:deltaTimeUnit), class: "label", for: "step_#{@id}__date_delta_time_unit") %>
<%= select(f, :deltaTimeUnit, get_time_units(), id: "step_#{@id}__date_delta_time_unit", class: "extract-date-step-form__delta_time_unit select", phx_focus: :get_example_output, phx_target: "#step-#{@id}") %>
<%= ErrorHelpers.error_tag(f, :deltaTimeUnit) %>
</div>
<div class="extract-date-step-form__deltaTimeValue">
<%= label(f, :deltaTimeValue, DisplayNames.get(:deltaTimeValue), class: "label") %>
<%= label(f, :deltaTimeValue, DisplayNames.get(:deltaTimeValue), class: "label", for: "step_#{@id}__date_delta_time_value") %>
<%= text_input(f, :deltaTimeValue, id: "step_#{@id}__date_delta_time_value", class: "extract-date-step-form__delta_time_value input", phx_focus: :get_example_output, phx_target: "#step-#{@id}") %>
<%= ErrorHelpers.error_tag(f, :deltaTimeValue) %>
</div>
<div class="extract-date-step-form__format">
<div class="help-text-label">
<%= label(f, :format, "Format", class: "label label--required") %>
<%= label(f, :format, "Format", class: "label label--required", for: "step_#{@id}__date_format") %>
<a href="https://hexdocs.pm/timex/Timex.Format.DateTime.Formatters.Default.html" target="_blank">Help</a>
</div>
<%= text_input(f, :format, [id: "step_#{@id}__date_format", class: "extract-date-step-form__format input", phx_focus: :get_example_output, phx_target: "#step-#{@id}", required: true]) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ defmodule AndiWeb.ExtractSteps.ExtractHttpStepForm do
<div class="extract-http-step-form-edit-section form-grid">
<div class="extract-http-step-form__method">
<%= label(f, :action, DisplayNames.get(:method), class: "label label--required") %>
<%= label(f, :action, DisplayNames.get(:method), class: "label label--required", for: "step_#{@id}__http_method") %>
<%= select(f, :action, get_http_methods(), [id: "step_#{@id}__http_method", class: "extract-http-step-form__method select", required: true]) %>
<%= ErrorHelpers.error_tag(f, :action) %>
</div>
<div class="extract-http-step-form__url">
<%= label(f, :url, DisplayNames.get(:url), class: "label label--required") %>
<%= label(f, :url, DisplayNames.get(:url), class: "label label--required", for: "step_#{@id}__url") %>
<%= url_input(f, :url, [id: "step_#{@id}__url", class: "input full-width", disabled: @testing, required: true]) %>
<%= ErrorHelpers.error_tag(f, :url, bind_to_input: false) %>
</div>
Expand All @@ -62,7 +62,7 @@ defmodule AndiWeb.ExtractSteps.ExtractHttpStepForm do
<%= if input_value(f, :action) == "POST" do %>
<div class="extract-http-step-form__body">
<%= label(f, :body, DisplayNames.get(:body), class: "label") %>
<%= label(f, :body, DisplayNames.get(:body), class: "label", for: "step_#{@id}__body") %>
<%= textarea(f, :body, id: "step_#{@id}__body", class: "input full-width", phx_hook: "prettify", disabled: @testing) %>
<%= ErrorHelpers.error_tag(f, :body, bind_to_input: false) %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule AndiWeb.IngestionLiveView.ExtractSteps.ExtractStepForm do
<div class="component-edit-section--<%= @visibility %>">
<div class="add-step">
<%= select(:form, :step_type, get_extract_step_types(), phx_blur: "update_new_step_type", selected: @new_step_type, id: "extract_step_type", class: "extract-step-form__step-type select") %>
<%= select(:form, :step_type, get_extract_step_types(), phx_blur: "update_new_step_type", selected: @new_step_type, id: "extract_step_type", class: "extract-step-form__step-type select", aria_label: "Select New Step Type") %>
<button class="btn btn--primary-outline" type="button" phx-click="add-extract-step">Add Step</button>
</div>
Expand Down Expand Up @@ -143,10 +143,17 @@ defmodule AndiWeb.IngestionLiveView.ExtractSteps.ExtractStepForm do
|> update_validation_status()}
end

def handle_event("move-extract-step", %{"id" => extract_step_id, "move-index" => move_index_string}, socket) do
def handle_event(
"move-extract-step",
%{"id" => extract_step_id, "move-index" => move_index_string},
socket
) do
move_index = String.to_integer(move_index_string)

extract_step_index = Enum.find_index(socket.assigns.extract_steps, fn extract_step -> extract_step.id == extract_step_id end)
extract_step_index =
Enum.find_index(socket.assigns.extract_steps, fn extract_step ->
extract_step.id == extract_step_id
end)

target_index = extract_step_index + move_index

Expand All @@ -163,10 +170,14 @@ defmodule AndiWeb.IngestionLiveView.ExtractSteps.ExtractStepForm do
) do
ExtractSteps.delete(extract_step_id)
updated_changeset_map = Map.delete(socket.assigns.extract_step_changesets, extract_step_id)

all_steps_for_ingestion = ExtractSteps.all_for_ingestion(ingestion_id) |> StructTools.sort_if_sequenced()

{:noreply,
assign(socket, extract_steps: all_steps_for_ingestion, extract_step_changesets: updated_changeset_map)
assign(socket,
extract_steps: all_steps_for_ingestion,
extract_step_changesets: updated_changeset_map
)
|> update_validation_status()}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ defmodule AndiWeb.IngestionLiveView.FinalizeForm do
<div class="finalize-form__schedule-options">
<div class="finalize-form__schedule-option">
<%= label(f, :cadence, "Immediately", class: "finalize-form__schedule-option-label") %>
<%= label(f, :cadence, "Immediately", class: "finalize-form__schedule-option-label", for: "form_data_cadence_once") %>
<%= radio_button(f, :cadence, "once")%>
</div>
<div class="finalize-form__schedule-option">
<%= label(f, :cadence, "Repeat", class: "finalize-form__schedule-option-label") %>
<%= label(f, :cadence, "Repeat", class: "finalize-form__schedule-option-label", for: "form_data_cadence_0__________") %>
<%= radio_button(f, :cadence, @crontab) %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ defmodule AndiWeb.IngestionLiveView.MetadataForm do
</div>
<div class="metadata-form__top-level-selector">
<%= label(f, :topLevelSelector, DisplayNames.get(:topLevelSelector), class: MetadataFormHelpers.top_level_selector_label_class(input_value(f, :sourceFormat))) %>
<%= if input_value(f, :sourceFormat) not in ["xml", "json", "text/xml", "application/json"] do %>
<%= label(f, :emptyValue, DisplayNames.get(:topLevelSelector), class: MetadataFormHelpers.top_level_selector_label_class(input_value(f, :sourceFormat))) %>
<%= text_input(f, :emptyValue, [class: "input--text input disable-focus", readonly: true]) %>
<% else %>
<%= label(f, :topLevelSelector, DisplayNames.get(:topLevelSelector), class: MetadataFormHelpers.top_level_selector_label_class(input_value(f, :sourceFormat))) %>
<%= text_input(f, :topLevelSelector, [class: "input--text input"]) %>
<% end %>
<%= ErrorHelpers.error_tag(f, :topLevelSelector) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ defmodule AndiWeb.DataDictionary.AddFieldEditor do
<div class="form-input-container">
<div class="data-dictionary-add-field-editor__name form-block">
<div class="form-input">
<%= label(form, :name, "Name", class: "label label--required") %>
<%= label(form, :name, "Name", class: "label label--required", for: id <> "_name") %>
<%= text_input(form, :name, [id: id <> "_name", class: "input", required: true]) %>
</div>
<%= error_tag(form, :name) %>
</div>
<div class="data-dictionary-add-field-editor__type form-block">
<div class="form-input">
<%= label(form, :type, "Type", class: "label label--required") %>
<%= label(form, :type, "Type", class: "label label--required", for: id <> "_type") %>
<%= select(form, :type, get_item_types(), [id: id <> "_type", class: "select", required: true]) %>
</div>
<%= error_tag(form, :type) %>
</div>
<div class="data-dictionary-add-field-editor__parent-id form-block">
<div class="form-input">
<%= label(form, :parent_id, "Child Of", class: "label") %>
<%= label(form, :parent_id, "Child Of", class: "label", for: id <> "_child-of") %>
<%= select(form, :parent_id, @eligible_parents, selected: @selected_field_id, id: id <> "_child-of", class: "select") %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ defmodule AndiWeb.DataDictionary.FieldEditor do
<%= hidden_input(@form, :ingestion_id) %>
<div class="data-dictionary-field-editor__name">
<%= label(@form, :name, "Name", class: "label label--required") %>
<%= label(@form, :name, "Name", class: "label label--required", for: id <> "_name") %>
<%= text_input(@form, :name, [id: id <> "_name", class: "data-dictionary-field-editor__name input", "phx-debounce": "1000", required: true]) %>
<%= ErrorHelpers.error_tag(form_with_errors, :name) %>
</div>
<%= if editing_ingestion? do %>
<div class="data-dictionary-field-editor__selector">
<%= if DataDictionaryHelpers.is_source_format_xml(@source_format) do %>
<%= label(@form, :selector, "Selector", class: "label label--required") %>
<%= label(@form, :selector, "Selector", class: "label label--required", for: id <> "_name") %>
<% else %>
<%= label(@form, :selector, "Selector", class: "label") %>
<%= label(@form, :selector, "Selector", class: "label", for: id <> "_name") %>
<% end %>
<%= text_input(@form, :selector, [id: id <> "_name", class: "data-dictionary-field-editor__selector input", disabled: !DataDictionaryHelpers.is_source_format_xml(@source_format), required: true]) %>
<%= ErrorHelpers.error_tag(form_with_errors, :selector) %>
</div>
<% end %>
<div class="data-dictionary-field-editor__type">
<%= label(@form, :type, "Type", class: "label label--required") %>
<%= label(@form, :type, "Type", class: "label label--required", for: id <> "_type") %>
<%= select(@form, :type, DataDictionaryHelpers.get_item_types(), [id: id <> "_type", class: "data-dictionary-field-editor__type select", required: true]) %>
<%= ErrorHelpers.error_tag(form_with_errors, :type) %>
</div>
<div class="data-dictionary-field-editor__type-info">
<%= if field_type == "list" do %>
<%= label(@form, :itemType, "Item Type", class: "label label--required") %>
<%= label(@form, :itemType, "Item Type", class: "label label--required", for: id <> "_item_type") %>
<%= select(@form, :itemType, DataDictionaryHelpers.get_item_types(@form), [id: id <> "_item_type", class: "data-dictionary-field-editor__item-type select", required: true]) %>
<%= ErrorHelpers.error_tag(form_with_errors, :itemType) %>
<% end %>
<%= if field_type in ["date", "timestamp"] do %>
<div class="format-label">
<%= label(@form, :format, "Format", class: "label label--required") %>
<%= label(@form, :format, "Format", class: "label label--required", for: id <> "_format") %>
<a href="https://hexdocs.pm/timex/Timex.Format.DateTime.Formatters.Default.html" target="_blank">Help</a>
</div>
<%= text_input(@form, :format, [id: id <> "_format", class: "data-dictionary-field-editor__format input", required: true]) %>
Expand All @@ -74,39 +74,39 @@ defmodule AndiWeb.DataDictionary.FieldEditor do
<div class="inline" style="align-items: baseline;">
<%= checkbox(@form, :use_default, id: id <> "__use-default", value: using_default) %>
<%= label(@form, :use_default, "Set the Default #{String.capitalize(field_type)}", class: "label") %>
<%= label(@form, :use_default, "Set the Default #{String.capitalize(field_type)}", class: "label", for: id <> "__use-default") %>
<div class="test-status__tooltip-wrapper"><p phx-hook="addTooltip" data-tooltip-content="If the data ingested does not have a <%= field_type %> value, the system can add this value during ingestion by taking the current <%= field_type %> offset by the value entered below" class="add-default-tooltip">Help</p></div>
</div>
<div class="inline" width="400px">
<%= number_input(@form, :default_offset, class: "input", id: id <> "__offset_input", value: offset, disabled: !using_default) %>
<%= label(@form, :default_offset, "Offset in #{time_unit_from_field_type(field_type)}", class: "label") %>
<%= label(@form, :default_offset, "Offset in #{time_unit_from_field_type(field_type)}", class: "label", for: id <> "__offset_input") %>
</div>
<% end %>
</div>
<div class="data-dictionary-field-editor__description">
<%= label(@form, :description, "Description", class: "label") %>
<%= label(@form, :description, "Description", class: "label", for: id <> "_description") %>
<%= textarea(@form, :description, id: id <> "_description", class: "data-dictionary-field-editor__description input textarea", "phx-debounce": "blur") %>
</div>
<div class="data-dictionary-field-editor__pii">
<%= label(@form, :pii, "P.I.I.", class: "label") %>
<%= label(@form, :pii, "P.I.I.", class: "label", for: id <> "_pii") %>
<%= select(@form, :pii, DataDictionaryHelpers.get_pii_types(), id: id <> "_pii", class: "data-dictionary-field-editor__pii select") %>
</div>
<div class="data-dictionary-field-editor__masked">
<%= label(@form, :masked, "De-Identified", class: "label") %>
<%= label(@form, :masked, "De-Identified", class: "label", for: id <> "_masked") %>
<%= select(@form, :masked, DataDictionaryHelpers.get_masked_types(), id: id <> "_masked", class: "data-dictionary-field-editor__masked select") %>
</div>
<div class="data-dictionary-field-editor__demographic">
<%= label(@form, :demographic, "Demographic Traits", class: "label") %>
<%= label(@form, :demographic, "Demographic Traits", class: "label", for: id <> "_demographic") %>
<%= select(@form, :demographic, DataDictionaryHelpers.get_demographic_traits(), id: id <> "_demographic", class: "data-dictionary-field-editor__demographic select") %>
</div>
<div class="data-dictionary-field-editor__biased">
<%= label(@form, :biased, "Potentially Biased", class: "label") %>
<%= label(@form, :biased, "Potentially Biased", class: "label", for: id <> "_biased") %>
<%= select(@form, :biased, DataDictionaryHelpers.get_biased_types(), id: id <> "_biased", class: "data-dictionary-field-editor__biased select") %>
</div>
<div class="data-dictionary-field-editor__rationale">
<%= label(@form, :rationale, "Rationale", class: "label") %>
<%= label(@form, :rationale, "Rationale", class: "label", for: id <> "_rationale") %>
<%= text_input(@form, :rationale, id: id <> "_rationale", class: "data-dictionary-field-editor__rationale input", "phx-debounce": "1000") %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ defmodule AndiWeb.UserLiveView.EditUserLiveView do
</div>
<div class="user-form__organizations">
<%= label(:organization, :org_id, class: "label") %>
<%= select(:organiation, :org_id, MetadataFormHelpers.get_org_options(), [class: "select", readonly: true]) %>
<%= label(:organization, :org_id, "Organization", class: "label") %>
<%= select(:organization, :org_id, MetadataFormHelpers.get_org_options(), [class: "select", readonly: true]) %>
<button type="submit" class="btn btn--add-organization btn--primary-outline">Add Organization</button>
</div>
</form>
Expand Down Expand Up @@ -134,11 +134,11 @@ defmodule AndiWeb.UserLiveView.EditUserLiveView do
end
end

def handle_event("associate", %{"organiation" => %{"org_id" => ""}}, socket) do
def handle_event("associate", %{"organization" => %{"org_id" => ""}}, socket) do
{:noreply, socket}
end

def handle_event("associate", %{"organiation" => %{"org_id" => org_id}}, socket) do
def handle_event("associate", %{"organization" => %{"org_id" => org_id}}, socket) do
user = socket.assigns.user
send_event(org_id, user, socket.assigns.signed_in_user_id)

Expand Down
2 changes: 1 addition & 1 deletion apps/andi/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Andi.MixProject do
def project do
[
app: :andi,
version: "2.4.28",
version: "2.4.29",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ defmodule AndiWeb.ExtractHttpStepFormTest do
http_step =
create_step("http", %{
action: "GET",
url: "{{secret}}.com/{{auth}}",
url: "http://{{secret}}.com/{{auth}}",
queryParams: %{"date" => "{{date}}"},
headers: %{"header" => "{{secret2}}"}
})
Expand Down Expand Up @@ -290,7 +290,7 @@ defmodule AndiWeb.ExtractHttpStepFormTest do
Process.sleep(3000)

assert_called(
UrlTest.test("secret.com/auth_token",
UrlTest.test("http://secret.com/auth_token",
query_params: [{"date", expected_date}],
headers: [{"header", "secret2"}]
)
Expand Down
Loading

0 comments on commit d813faa

Please sign in to comment.