Skip to content

Commit

Permalink
Fix specs / Add map default location label
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed May 2, 2024
1 parent a9014cb commit b52366f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function createEditableForm() {
const addMatrixRowButtonSelector = ".add-matrix-row";
const maxChoicesWrapperSelector = ".questionnaire-question-max-choices";
const locationCountWrapperSelector = ".questionnaire-question-location-count";
const defaultMapPositionLabelWrapperSelector = ".questionnaire-question-default-map-position-label"
const defaultMapPositionWrapperSelector = ".questionnaire-question-default-map-position";
const locationOptionFieldSelector = ".questionnaire-question-location-option";
const locationOptionsWrapperSelector = ".questionnaire-question-location-options";
Expand Down Expand Up @@ -444,6 +445,16 @@ export default function createEditableForm() {
}
});

createFieldDependentInputs({
controllerField: $fieldQuestionTypeSelect,
wrapperSelector: fieldSelector,
dependentFieldsSelector: defaultMapPositionLabelWrapperSelector,
dependentInputSelector: "label",
enablingCondition: ($field) => {
return $field.val() === "map_locations";
}
});

createFieldDependentInputs({
controllerField: $fieldQuestionTypeSelect,
wrapperSelector: fieldSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
<p class="help-text-map"><%= t("decidim.forms.admin.questionnaires.question.map_config_help") %></p>
</div>

<div class="row column questionnaire-question-default-map-position-label">
<%= label(:default_map_position, :default_map_position)%>
</div>

<div class="row column questionnaire-question-default-map-position">
<div class="default-map-position-child default-position-latitude">
<%=
Expand Down Expand Up @@ -193,7 +197,7 @@
</div>

<div>
<%= form.button t(".select_from_map"), type: "button", class: "button small button--title default-position-button" %>
<%= form.button t(".select_from_map"), type: "button", class: "button small hollow button--title default-position-button" %>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions decidim-module-forms_locations/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ en:
multiple: Multiple
single: Single
select_from_map: Select from map
default_map_position: Default map position
location_option:
answer_option: Answer option
remove: Remove
Expand Down
1 change: 1 addition & 0 deletions decidim-module-forms_locations/config/locales/fi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fi:
multiple: Useita
single: Yksittäinen
select_from_map: Valitse kartalta
default_map_position: Kartan oletusasetukset
location_option:
answer_option: Vastausvaihtoehto
remove: Poista
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
check "Mandatory"
select("Map", from: "Type").select_option
expect(page).to have_field("Map config", with: "multiple")
fill_in "Default latitude", with: "11"
fill_in "Default longitude", with: "13"
fill_in "Latitude", with: "11"
fill_in "Longitude", with: "13"
click_button "Save"

expect(page).to have_content("Survey successfully saved.")
Expand All @@ -48,8 +48,8 @@
select("Map", from: "Type").select_option
select("Single", from: "Map config")
expect(page).to have_field("Map config", with: "single")
fill_in "Default latitude", with: "11"
fill_in "Default longitude", with: "13"
fill_in "Latitude", with: "11"
fill_in "Longitude", with: "13"
click_button "Save"

expect(page).to have_content("Survey successfully saved.")
Expand All @@ -71,6 +71,7 @@
within(option) do
fill_in find("input", match: :first)["name"], with: "Lauttasaari"
fill_in "Geojson", match: :first, with: '{"type":"Feature","geometry":{"type":"Point","coordinates":[12,5]}}'
select("Left", from: "Tooltip direction")
end
end

Expand Down

0 comments on commit b52366f

Please sign in to comment.