Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI improvements #34

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo

## [Unreleased]

- [PR-34](https://github.com/itk-dev/aapodwalk_api/pull/34)
UI improvements
- [PR-33](https://github.com/itk-dev/aapodwalk_api/pull/33)
Security update
- [PR-32](https://github.com/itk-dev/aapodwalk_api/pull/32)
Expand Down
16 changes: 16 additions & 0 deletions assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,20 @@ window.addEventListener("load", () => {
}
}
});

// Open accordions with errors on submit.
document.addEventListener("ea.form.error", (event) => {
const { page, form } = event.detail;
// alert(`The ${page} form contains errors. Please resolve these before submitting again.`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saved for later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a leftover from testing example code in EasyCorp/EasyAdminBundle#6650. I've removed the line.

const elements = form.querySelectorAll(".accordion-item .has-error");
for (const el of elements) {
const item = el.closest(".accordion-item");
const button = item?.querySelector(".accordion-header button");
const contents = item?.querySelector(".accordion-collapse");
if (button && contents) {
button.classList.remove("collapsed");
contents.classList.add("show");
}
}
});
});
3 changes: 2 additions & 1 deletion src/Form/LocationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

public function implodeCoordinates(?array $coordinates): string
{
return implode(', ', $coordinates ?? []);
// Separate non-empty values with comma.
return implode(', ', array_filter($coordinates ?? []));
}

public function explodeCoordinates(string $coordinates): array
Expand Down
6 changes: 3 additions & 3 deletions translations/admin+intl-icu.da.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
</trans-unit>
<trans-unit id="Q4p_Gmi" resname="API documentation">
<source>API documentation</source>
<target state="translated">API-documentation</target>
<target state="translated">API-dokumentation</target>
</trans-unit>
<trans-unit id="mpHDX6N" resname="Administration">
<source>Administration</source>
Expand Down Expand Up @@ -211,7 +211,7 @@
</trans-unit>
<trans-unit id="XkthfIE" resname="Enter a location on the form &lt;code&gt;lat, lng&lt;/code&gt;, e.g. &lt;code&gt;56.153244272970866, 10.213798100000005&lt;/code&gt;. &lt;strong&gt;Notice&lt;/strong&gt;: the two numbers must always be separated by a comma and use dot as decimal separator.&lt;br&gt;Hint: Open &lt;a href=&quot;https://www.google.com/maps&quot; target=&quot;_blank&quot;&gt;Google Maps&lt;/a&gt; and “right” click on the map to get the coordinates.">
<source>Enter a location on the form &lt;code&gt;lat, lng&lt;/code&gt;, e.g. &lt;code&gt;56.153244272970866, 10.213798100000005&lt;/code&gt;. &lt;strong&gt;Notice&lt;/strong&gt;: the two numbers must always be separated by a comma and use dot as decimal separator.&lt;br&gt;Hint: Open &lt;a href="https://www.google.com/maps" target="_blank"&gt;Google Maps&lt;/a&gt; and “right” click on the map to get the coordinates.</source>
<target state="translated"><![CDATA[Indtast en lokation på formen <code>breddegrad, længdegrad</code>, fx. <code>56.153244272970866, 10.213798100000005</code>. <strong>Bemærk</strong>: de to tal skal altid adskilles af et komma og skal bruge punktum som decimalseparator.<br>Tip: Åbn <a href="https://www.google.com/maps" target="_blank">Google Maps</a> and højreklik på kortet for at få koordinaterne.]]></target>
<target state="translated"><![CDATA[Indtast en lokation på formen <code>breddegrad, længdegrad</code>, fx. <code>56.153244272970866, 10.213798100000005</code>. <strong>Bemærk</strong>: de to tal skal altid adskilles af et komma og skal bruge punktum som decimalseparator.<br>Tip: Åbn <a href="https://www.google.com/maps" target="_blank">Google Maps</a> og højreklik på kortet for at få koordinaterne.]]></target>
</trans-unit>
<trans-unit id="p.sAfxC" resname="The total duration of the route, i.e. the total duration of audio tracks in the route plus the time needed for moving along the route.">
<source>The total duration of the route, i.e. the total duration of audio tracks in the route plus the time needed for moving along the route.</source>
Expand Down Expand Up @@ -303,7 +303,7 @@
</trans-unit>
<trans-unit id="_z4el3Z" resname="The password fields must match.">
<source>The password fields must match.</source>
<target state="translated">Adgangskoderne er ikke ens</target>
<target state="translated">Adgangskoderne er ikke ens.</target>
</trans-unit>
<trans-unit id="Zm.jZiK" resname="New password">
<source>New password</source>
Expand Down
Loading