On utilise un textarea pour les adresses, et on modifie le formulaire

This commit is contained in:
Tom Hubrecht 2021-01-28 10:41:27 +01:00
parent 89e5260027
commit 2009316ff0
5 changed files with 56 additions and 20 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.2.17 on 2021-01-28 00:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('fiches', '0008_auto_20201113_1038'),
]
operations = [
migrations.AlterField(
model_name='address',
name='content',
field=models.TextField(verbose_name='adresse'),
),
]

View file

@ -89,7 +89,7 @@ class Address(models.Model):
Profile, on_delete=models.CASCADE, verbose_name=_("profil") Profile, on_delete=models.CASCADE, verbose_name=_("profil")
) )
name = models.CharField(max_length=255, verbose_name=_("type")) name = models.CharField(max_length=255, verbose_name=_("type"))
content = models.CharField(max_length=1023, verbose_name=_("adresse")) content = models.TextField(verbose_name=_("adresse"))
def __str__(self): def __str__(self):
return "{} : {}".format(self.name, self.content) return "{} : {}".format(self.name, self.content)

View file

@ -426,19 +426,27 @@ body {
grid-template-areas: "errors errors errors" "type-input value-input remove-button"; grid-template-areas: "errors errors errors" "type-input value-input remove-button";
column-gap: 10px; column-gap: 10px;
margin: 0 0 10px 0; margin: 0 0 10px 0;
align-items: center;
} }
#content-edit-profile form .form-sub-entry.hidden { #content-edit-profile form .form-sub-entry.hidden {
display: none; display: none;
} }
#content-edit-profile form .form-sub-entry input:nth-child(1) { #content-edit-profile form .form-sub-entry input:nth-child(1) {
grid-area: type-input; grid-area: type-input;
max-height: 30px;
} }
#content-edit-profile form .form-sub-entry input:nth-child(2) { #content-edit-profile form .form-sub-entry input:nth-child(2) {
grid-area: value-input; grid-area: value-input;
} }
#content-edit-profile form .form-sub-entry textarea:nth-child(2) {
grid-area: value-input;
max-height: 35px;
resize: none;
}
#content-edit-profile form .form-sub-entry .remove-button { #content-edit-profile form .form-sub-entry .remove-button {
grid-area: remove-button; grid-area: remove-button;
min-height: 30px; min-height: 30px;
max-height: 30px;
min-width: 30px; min-width: 30px;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>'); background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
background-size: 80%; background-size: 80%;

View file

@ -3,7 +3,7 @@
@use "errors"; @use "errors";
#content-area { #content-area {
color: colors.$content-text; color: colors.$content-text;
} }
.content { .content {
@ -21,7 +21,7 @@
input { input {
min-height: 30px; min-height: 30px;
padding: 5px; padding: 5px;
border: none; border: none;
border-radius: 0; border-radius: 0;
} }
@ -39,7 +39,7 @@
margin: 0 auto; margin: 0 auto;
grid-template-columns: 150px 250px; grid-template-columns: 150px 250px;
gap: 20px; gap: 20px;
label { label {
grid-column: 1; grid-column: 1;
margin: 5px 0 0 0; margin: 5px 0 0 0;
@ -74,7 +74,7 @@
// input[type="checkbox"] { // input[type="checkbox"] {
// display: inline; // display: inline;
// width: 1rem; // width: 1rem;
// float: right; // float: right;
// } // }
} }
} }
@ -111,7 +111,7 @@
text-align: center; text-align: center;
} }
} }
.photo { .photo {
height: 150px; height: 150px;
margin: 0 20px 0 0; margin: 0 20px 0 0;
@ -143,7 +143,7 @@
padding: 10px; padding: 10px;
background-color: colors.$content-frame-background; background-color: colors.$content-frame-background;
box-shadow: 2px 2px 0 colors.$shadow; box-shadow: 2px 2px 0 colors.$shadow;
&.multi-entry ul.value { &.multi-entry ul.value {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -195,11 +195,11 @@
padding: 10px; padding: 10px;
background-color: colors.$content-frame-background; background-color: colors.$content-frame-background;
box-shadow: 2px 2px 0 colors.$shadow; box-shadow: 2px 2px 0 colors.$shadow;
> * { > * {
display: block; display: block;
} }
label { label {
margin: 0 0 5px 0; margin: 0 0 5px 0;
color: colors.$page-text-emph; color: colors.$page-text-emph;
@ -207,7 +207,7 @@
font-style: italic; font-style: italic;
text-align: left; text-align: left;
} }
input, select { input, select {
width: 100%; width: 100%;
} }
@ -229,6 +229,7 @@
"type-input value-input remove-button"; "type-input value-input remove-button";
column-gap: 10px; column-gap: 10px;
margin: 0 0 10px 0; margin: 0 0 10px 0;
align-items: center;
&.hidden { &.hidden {
display: none; display: none;
@ -237,12 +238,21 @@
// Since the different labels and inputs are not obvious to identifiate using CSS selectors, // Since the different labels and inputs are not obvious to identifiate using CSS selectors,
// they are selected one after the other using their natural order in the DOM // they are selected one after the other using their natural order in the DOM
// TODO: make this more robust by giving proper class names to each sub-entry element // TODO: make this more robust by giving proper class names to each sub-entry element
input:nth-child(1) { grid-area: type-input; } input:nth-child(1) {
grid-area: type-input;
max-height: 30px;
}
input:nth-child(2) { grid-area: value-input; } input:nth-child(2) { grid-area: value-input; }
textarea:nth-child(2) {
grid-area: value-input;
max-height: 35px;
resize: none;
}
.remove-button { .remove-button {
grid-area: remove-button; grid-area: remove-button;
min-height: 30px; min-height: 30px;
max-height: 30px;
min-width: 30px; min-width: 30px;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>'); background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
background-size: 80%; background-size: 80%;
@ -261,14 +271,14 @@
&.erroneous { &.erroneous {
@extend %error-list-container; @extend %error-list-container;
// TODO: this is not robust and should be replaced by better selectors // TODO: this is not robust and should be replaced by better selectors
// In case of error, increment the child indices // In case of error, increment the child indices
// to take the additional list of errors (.errorlist) // to take the additional list of errors (.errorlist)
// prepended by Django to the sub-entry // prepended by Django to the sub-entry
input:nth-child(2) { grid-area: type-input; } input:nth-child(2) { grid-area: type-input; }
input:nth-child(3) { grid-area: value-input; } input:nth-child(3) { grid-area: value-input; }
// Use a darker red color when the sub-entry background is already red // Use a darker red color when the sub-entry background is already red
.remove-button:hover, .remove-button:hover,
.remove-button:active { .remove-button:active {
@ -281,7 +291,7 @@
grid-area: errors; grid-area: errors;
} }
} }
.form-sub-entry-template { .form-sub-entry-template {
display: none; display: none;
} }
@ -289,7 +299,7 @@
.add-sub-entry-button { .add-sub-entry-button {
margin: 0 auto 0 auto; margin: 0 auto 0 auto;
} }
.form-entry.checkbox { .form-entry.checkbox {
> * { > * {
display: inline; display: inline;
@ -310,7 +320,7 @@
input[type="checkbox"] { input[type="checkbox"] {
display: block; display: block;
width: auto; width: auto;
float: right; float: right;
} }
} }
} }
@ -355,7 +365,7 @@
// input[type="checkbox"] { // input[type="checkbox"] {
// display: inline-block; // display: inline-block;
// width: 1rem; // width: 1rem;
// float: right; // float: right;
// } // }
input[type="file"] { input[type="file"] {
@ -363,4 +373,4 @@
} }
} }
} }
} }

View file

@ -87,7 +87,7 @@
<span class="separator"></span> <span class="separator"></span>
<ul class="value"> <ul class="value">
{% for p in profile.address_set.all %} {% for p in profile.address_set.all %}
<li><span class="type">{{ p.name }}</span><span class="value">{{ p.content }}</span></li> <li><span class="type">{{ p.name }}</span><span class="value">{{ p.content|linebreaksbr }}</span></li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>