Skip to content

Commit

Permalink
Merge pull request #3251 from digitalfabrik/feature/add-cancel-button…
Browse files Browse the repository at this point in the history
…-to-creation-form

Add cancel button to creation and edit forms
  • Loading branch information
lunars97 authored Jan 8, 2025
2 parents 7d703ab + 739a2cf commit a51f84f
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 30 deletions.
7 changes: 7 additions & 0 deletions integreat_cms/cms/templates/contacts/contact_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ <h1 class="heading">
{% endif %}
</h1>
<div class="flex flex-wrap justify-between gap-4">
{% if contact_form.instance.archived %}
<a href="{% url 'archived_contacts' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% else %}
<a href="{% url 'contacts' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% endif %}
{% if perms.cms.change_contact and not contact_form.instance.archived %}
<div class="flex flex-wrap gap-4">
<button class="btn">
Expand Down
15 changes: 11 additions & 4 deletions integreat_cms/cms/templates/events/event_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ <h1 class="heading overflow-hidden text-ellipsis">
{% translate "Create new event" %}
{% endif %}
</h1>
{% if not disabled %}
<div class="flex flex-wrap gap-4 ml-auto mr-0 items-center">
<div class="flex flex-wrap gap-4 ml-auto mr-0 items-center">
{% if event_form.instance.archived %}
<a href="{% url 'events_archived' region_slug=request.region.slug language_slug=language.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% else %}
<a href="{% url 'events' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% endif %}
{% if not disabled %}
{% include "generic_auto_save_note.html" with form_instance=event_form.instance %}
{% if perms.cms.publish_event %}
<button name="status"
Expand All @@ -61,8 +68,8 @@ <h1 class="heading overflow-hidden text-ellipsis">
{% translate "Submit for approval" %}
</button>
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
</div>
<div class="3xl:grid grid-cols-2 3xl:grid-cols-[minmax(0px,_1fr)_400px] 4xl:grid-cols-[minmax(0px,_1fr)_816px] gap-4">
<div class="col-span-2 3xl:col-span-1 flex flex-wrap flex-col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ <h1 class="heading">
</div>
<div class="flex justify-end w-2/5">
<div class="flex flex-wrap justify-between gap-4">
<a href="{% url 'external_calendar_list' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% if external_calendar_form.instance.id and perms.cms.delete_externalcalendar %}
<div class="flex flex-wrap gap-4">
<button type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ <h1 class="heading overflow-hidden text-ellipsis">
{% endif %}
</h1>
{% if perms.cms.change_languagetreenode %}
{% if form.instance.id %}
<button class="btn ml-auto mr-0">
{% translate "Update" %}
</button>
{% else %}
<div class="flex flex-wrap gap-2">
<div class="flex flex-wrap gap-2">
<a href="{% url 'languagetreenodes' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% if form.instance.id %}
<button class="btn ml-auto mr-0">
{% translate "Update" %}
</button>
{% else %}
<button class="btn ml-auto mr-0">
{% translate "Create" %}
</button>
<button name="submit_add_new" class="btn ml-auto mr-0">
{% translate "Create and add more" %}
</button>
</div>
{% endif %}
{% endif %}
</div>
{% endif %}
</div>
<div class="mb-4 rounded border border-blue-500 shadow-2xl bg-white">
Expand Down
15 changes: 11 additions & 4 deletions integreat_cms/cms/templates/organizations/organization_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ <h1 class="heading">
{% endif %}
</h1>
<div class="flex flex-wrap justify-between gap-4">
{% if form.instance.archived %}
<a href="{% url 'archived_organizations' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% else %}
<a href="{% url 'organizations' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% endif %}
{% if form.instance.id and perms.cms.delete_organization %}
<div class="flex flex-wrap gap-4">
{% if form.instance.is_used %}
Expand All @@ -40,8 +47,8 @@ <h1 class="heading">
{% endif %}
</div>
{% endif %}
{% if perms.cms.change_organization %}
<div class="flex flex-wrap gap-4">
<div class="flex flex-wrap gap-4">
{% if perms.cms.change_organization %}
{% if form.instance.id %}
<button class="btn">
{% translate "Update" %}
Expand All @@ -51,8 +58,8 @@ <h1 class="heading">
{% translate "Create" %}
</button>
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
<div class="grid xl:grid-cols-2 gap-4">
Expand Down
15 changes: 11 additions & 4 deletions integreat_cms/cms/templates/pages/page_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ <h1 class="heading">
{% translate "Create new page" %}
{% endif %}
</h1>
{% if not page_form.instance.id or not page_form.instance.archived %}
<div class="flex flex-wrap grow justify-end gap-2 items-center">
<div class="flex flex-wrap grow justify-end gap-2 items-center">
{% if page_form.instance.id and page_form.instance.archived %}
<a href="{% url 'archived_pages' region_slug=request.region.slug language_slug=language.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% else %}
<a href="{% url 'pages' region_slug=request.region.slug language_slug=language.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% endif %}
{% if not page_form.instance.id or not page_form.instance.archived %}
{% include "generic_auto_save_note.html" with form_instance=page_translation_form.instance %}
<button name="preview_page" type="button" data-preview-page data-edit-page-mode data-right-to-left={{ right_to_left }} class="btn btn-ghost">
{% translate "Preview" %}
Expand Down Expand Up @@ -73,8 +80,8 @@ <h1 class="heading">
{% translate "Submit for approval" %}
</button>
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
</div>
<div class="3xl:grid grid-cols-2 3xl:grid-cols-[minmax(0px,_1fr)_400px] {% if page %}4xl:grid-cols-[minmax(0px,_1fr)_816px]{% endif %} gap-4">
<div class="col-span-2 3xl:col-span-1 flex flex-wrap flex-col flex-auto">
Expand Down
15 changes: 11 additions & 4 deletions integreat_cms/cms/templates/pois/poi_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ <h1 class="overflow-hidden heading text-ellipsis">
{% translate "Create new location" %}
{% endif %}
</h1>
{% if not poi_form.instance.archived and perms.cms.change_poi %}
<div class="flex flex-wrap items-center gap-4 ml-auto mr-0">
<div class="flex flex-wrap items-center gap-4 ml-auto mr-0">
{% if poi_form.instance.archived %}
<a href="{% url 'archived_pois' region_slug=request.region.slug language_slug=language.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% else %}
<a href="{% url 'pois' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% endif %}
{% if not poi_form.instance.archived and perms.cms.change_poi %}
{% include "generic_auto_save_note.html" with form_instance=poi_translation_form.instance %}
<button name="status"
value="{{ DRAFT }}"
Expand All @@ -50,8 +57,8 @@ <h1 class="overflow-hidden heading text-ellipsis">
{% translate "Publish" %}
{% endif %}
</button>
</div>
{% endif %}
{% endif %}
</div>
</div>
<div class="pt-4 lg:pt-0 3xl:grid grid-cols-2 3xl:grid-cols-[minmax(0px,_1fr)_400px] 4xl:grid-cols-[minmax(0px,_1fr)_816px] gap-4">
<div class="flex flex-col flex-wrap col-span-2 3xl:col-span-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ <h1 class="heading overflow-hidden text-ellipsis">
{% if perms.cms.change_pushnotification and not not_accessible_regions_warning %}
{% if push_notification_form.is_template.value %}
{# BUTTONS FOR NEWS TEMPLATES #}
<a href="{% url 'push_notifications_templates' region_slug=request.region.slug language_slug=language.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
<button name="submit_draft" class="btn btn-outline">
{% if push_notification_form.instance.id %}
{% translate "Update template" %}
Expand All @@ -42,6 +44,8 @@ <h1 class="heading overflow-hidden text-ellipsis">
</button>
{% else %}
{# BUTTONS FOR NEWS #}
<a href="{% url 'push_notifications' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
<button name="submit_draft" class="btn btn-outline">
{% translate "Save as draft" %}
</button>
Expand Down
14 changes: 9 additions & 5 deletions integreat_cms/cms/templates/users/region_user_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ <h1 class="heading">
{% translate "Create new account" %}
{% endif %}
</h1>
{% if perms.cms.change_user %}
<button class="btn">
{% translate "Save" %}
</button>
{% endif %}
<div class="flex flex-wrap grow justify-end gap-2 items-center">
<a href="{% url 'region_users' region_slug=request.region.slug %}"
class="btn btn-ghost">{% translate "Cancel" %}</a>
{% if perms.cms.change_user %}
<button class="btn">
{% translate "Save" %}
</button>
{% endif %}
</div>
</div>
<div class="grid xl:grid-cols-2 2xl:grid-cols-3 gap-4">
<div class="mb-4 rounded border border-blue-500 shadow-2xl bg-white">
Expand Down
9 changes: 8 additions & 1 deletion integreat_cms/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4736,10 +4736,17 @@ msgid "Show more"
msgstr "Mehr anzeigen"

#: cms/templates/_machine_translation_overlay.html
#: cms/templates/_tinymce_config.html
#: cms/templates/_tinymce_config.html cms/templates/contacts/contact_form.html
#: cms/templates/events/event_form.html
#: cms/templates/events/external_calendar_form.html
#: cms/templates/generic_confirmation_dialog.html
#: cms/templates/languagetreenodes/languagetreenode_form.html
#: cms/templates/linkcheck/link_list_row.html
#: cms/templates/organizations/organization_form.html
#: cms/templates/pages/page_form.html cms/templates/pois/poi_form.html
#: cms/templates/pois/poi_form_sidebar/position_box.html
#: cms/templates/push_notifications/push_notification_form.html
#: cms/templates/users/region_user_form.html
#: cms/views/pois/poi_context_mixin.py
msgid "Cancel"
msgstr "Abbrechen"
Expand Down
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/2930.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: Add cancel button to creation and edit forms
de: Füge einen Abbrechen-Button zu den Erstellungs- und Bearbeitungsformularen hinzu

0 comments on commit a51f84f

Please sign in to comment.