Skip to content

Commit

Permalink
✨ [#988] IMPROVE the forms.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefrado committed Dec 10, 2024
1 parent 36fc809 commit 5c09224
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/sdg/js/components/formset/add_formset_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DynamicTitle } from "../dynamic_title";
import { DynamicCheckbox } from "./dynamic_checkbox";

/** @type {HTMLDivElement} */
const ADD_FORM_ELEMENT = document.querySelector(".formset__add");
const ADD_FORM_ELEMENT = document.querySelector(".formset__button--add");
const PREFIX_PLACEHOLDER = "__prefix__";

class AddFormsetForm extends FormsetFormComponent {
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/js/components/formset/remove_formset_form.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormsetFormComponent } from "./abstract/formset_form_component";

const REMOVE_ELEMENTS = document.querySelectorAll(".formset__remove");
const REMOVE_ELEMENTS = document.querySelectorAll(".formset__button--remove");

export class RemoveFormsetForm extends FormsetFormComponent {
/**
Expand Down
16 changes: 10 additions & 6 deletions src/sdg/organisaties/migrations/0033_auto_20241022_1421.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
class Migration(migrations.Migration):

dependencies = [
('organisaties', '0032_alter_links'),
("organisaties", "0032_alter_links"),
]

operations = [
migrations.AlterModelOptions(
name='lokatie',
options={'ordering': ('order', 'naam'), 'verbose_name': 'locatie', 'verbose_name_plural': 'locaties'},
name="lokatie",
options={
"ordering": ("order", "naam"),
"verbose_name": "locatie",
"verbose_name_plural": "locaties",
},
),
migrations.AddField(
model_name='lokatie',
name='order',
field=models.PositiveIntegerField(default=0, verbose_name='order'),
model_name="lokatie",
name="order",
field=models.PositiveIntegerField(default=0, verbose_name="order"),
),
]
27 changes: 7 additions & 20 deletions src/sdg/scss/components/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
padding: .75rem;
vertical-align: top;
width: 100%;
padding: 12px;

// Input states
&[disabled],
Expand All @@ -80,6 +81,12 @@
color: transparent;
}

&:focus-visible {
// Use CK-editor focus state as default focus state.
box-shadow: var(--ck-inner-shadow), 0 0;
--field-border-color: var(--ck-color-focus-border);
}

// Modifiers
&--preview {
--field-border-color: #{$color_grey_light};
Expand Down Expand Up @@ -244,26 +251,6 @@
}
}

&__input {
border: 1px solid #dfdfdf;
padding: 12px;
outline: none;
font-size: 16px;
width: 100%;
min-height: 57px;

&[disabled],
&[readonly]:not(.flatpickr-input),
&--disabled {
background-color: $color_grey_lightest;
}

&[disabled]::placeholder,
&[readonly]::placeholder {
color: transparent;
}
}

&__block {
width: 425px;

Expand Down
47 changes: 18 additions & 29 deletions src/sdg/scss/components/_formset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
--margin-bottom: 32px;
--text-gap: .75rem;
--font-size: 1rem;
--button-size: ;

margin-bottom: var(--margin-bottom);
color: var(--text-color);
Expand All @@ -17,7 +16,6 @@
font-size: 13.3333px;
}


&__form{
margin-bottom: var(--margin-bottom);
border: 1px solid var(--border-color);
Expand Down Expand Up @@ -84,7 +82,6 @@
}
}


&__header {
display: flex;
gap: var(--x-spacing);
Expand All @@ -106,24 +103,6 @@
&__label {
font-size: 16px;
}



.button {
margin: 0;
}

button:not(.button) {
appearance: none;
color: #0b71a1;
border: none;
padding: 0;
font-size: 1rem;
cursor: pointer;
background-color: transparent;

}


&__footer{
padding: 24px;
Expand All @@ -148,20 +127,30 @@
&__form:not(&__form--hidden) &__toggle-indication {
transform: rotate(180deg);
}

// TODO: Change this element to a button and disable the native styling.
&__add {
color: #0b71a1;

&__button {
cursor: pointer;
margin-bottom: 42px;
margin-left: 16px;
border: none;
font-size: 1rem;
margin-bottom: 10px;
padding: 0;
background-color: transparent;
}
appearance: none;

&--add {
color: #0b71a1;
margin-bottom: 42px;
margin-left: 16px;
margin-bottom: 10px;
}

&--remove {
color: $color_red;
}

&:hover {
text-decoration: underline;
}
}

// Remove the dynamic title '(' & ')' if there is no dyanmic title target availible
&__form-name:has([class*="dynamic_title_target"]:empty){
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/forms/location_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h3 class="formset__form-title">
</div>
</div>
<footer class="formset__ftr formset__footer">
<button class="formset__remove red" type="button">
<button class="formset__button formset__button--remove" type="button">
<i class="far fa-trash-alt"></i>
{% trans "Locatie verwijderen" %}
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/forms/organization_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h3 class="formset__form-title">
</div>

<footer class="formset__footer">
<button class="formset__remove red" type="button">
<button class="formset__button formset__button--remove" type="button">
<i class="far fa-trash-alt"></i>
{% trans "Organisatie verwijderen" %}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3 class="formset__form-title">
</div>
</div>
<footer class="formset__footer">
<button class="formset__remove red" type="button">
<button class="formset__button formset__button--remove" type="button">
<i class="far fa-trash-alt"></i>
{% trans "Locatie verwijderen" %}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3 class="formset__form-title">
</div>
</div>
<footer class="formset__footer">
<button class="formset__remove red" type="button">
<button class="formset__button formset__button--remove" type="button">
<i class="far fa-trash-alt"></i>
{% trans "Organisatie verwijderen" %}
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/organisaties/bevoegde_organisaties.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3 class="formset__form-title">
{% endfor %}
</div>
</div>
<button class="formset__add" data-formset-prefix="{{ locatie_formset.prefix }}" type="button">
<button class="formset__button formset__button--add" data-formset-prefix="{{ locatie_formset.prefix }}" type="button">
<i class="fas fa-plus"></i>
{% trans "Nog een organisatie toevoegen" %}
</button>
Expand Down
7 changes: 6 additions & 1 deletion src/sdg/templates/organisaties/locaties.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{% load static i18n utils %}

{% block page_title %}{% trans "Locaties" %}{% endblock %}
{% block page_intro %}
<p class="subheading">
{% trans "Je kant hier alle locaties opgeven waar producten worden aangeboden. Bij elk product kan je vervolgens een of meer locaties selecteren uit deze lijst." %}
</p>
{% endblock %}

{% block inner_content %}
<form action="{% url "organisaties:locaties" pk=lokaleoverheid.pk %}" method="post" class="form">
Expand All @@ -16,7 +21,7 @@
{% endfor %}
</div>
</div>
<button class="formset__add" data-formset-prefix="{{ locatie_formset.prefix }}" type="button">
<button class="formset__button formset__button--add" data-formset-prefix="{{ locatie_formset.prefix }}" type="button">
<i class="fas fa-plus"></i>
{% trans "Nog een locatie toevoegen" %}
</button>
Expand Down
18 changes: 14 additions & 4 deletions src/sdg/utils/templatetags/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,24 @@ def order_field(context, field=None, **kwargs):


@register.inclusion_tag("forms/location_form.html", takes_context=True)
def location_form(context,subform, initialOrder, **kwargs):
def location_form(context, subform, initialOrder, **kwargs):
print(subform)
return {"context":context, "subform": subform, "initialOrder": initialOrder, **kwargs}
return {
"context": context,
"subform": subform,
"initialOrder": initialOrder,
**kwargs,
}


@register.inclusion_tag("forms/organization_form.html", takes_context=True)
def organization_form(context,subform, initialOrder, **kwargs):
return {"context":context, "subform": subform, "initialOrder": initialOrder, **kwargs}
def organization_form(context, subform, initialOrder, **kwargs):
return {
"context": context,
"subform": subform,
"initialOrder": initialOrder,
**kwargs,
}


@register.inclusion_tag("forms/table_grid_field.html")
Expand Down

0 comments on commit 5c09224

Please sign in to comment.