Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Feature/fix admin field order #1011

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 33 additions & 3 deletions geocity/apps/core/static/css/admin/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,37 @@
overflow-x: auto;
}

/*Reduce select2 field width so that CRUD button remain visible*/
tr .select2 {
width: 70% !important;
/* tweak admin-sortable2 for jazzmin compatibility with tabular inlines */
/* Used in "1.4 Formulaires", tab "Champs" */

fieldset.module.sortable tbody tr.form-row {
padding: 20px 0px 10px 0px; /* top right bottom left*/
border-bottom: 1px dashed #c7c7c7;
}

fieldset.module.sortable tbody .original {
width: 50px;
text-align: center;
}

fieldset.module.sortable td.original p {
width: 45px !important;
}

fieldset.module.sortable tbody .field-field {
width: 650px;
}

fieldset.module.sortable tbody .delete {
width: 50px; /* width of div. (thead .original - tbody.original - tbody .field-field)*/
position: relative; /* used to move 50 px left */
left: 75px;
}

fieldset.module.sortable thead .original {
width: 750px;
}

fieldset.module.sortable thead .column-field {
display: none;
}
7 changes: 3 additions & 4 deletions geocity/apps/forms/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string

import django.db.models
from adminsortable2.admin import SortableAdminMixin, SortableInlineAdminMixin
from adminsortable2.admin import SortableAdminMixin, SortableTabularInline
from constance import config
from django import forms
from django.contrib import admin
Expand Down Expand Up @@ -178,8 +178,7 @@ def save(self, *args, **kwargs):
return super().save(*args, **kwargs)


# TODO: enable drag and drop for inline reorder
class FormFieldInline(admin.TabularInline, SortableInlineAdminMixin):
class FormFieldInline(SortableTabularInline):
model = models.FormField
extra = 2
verbose_name = _("Champ")
Expand All @@ -198,7 +197,7 @@ class Media:
css = {"all": ("css/admin/admin.css",)}


class FormPricesInline(admin.TabularInline, SortableInlineAdminMixin):
class FormPricesInline(admin.TabularInline):
model = models.Form.prices.through
extra = 1
verbose_name = _("Tarif")
Expand Down
3 changes: 3 additions & 0 deletions geocity/apps/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ class Meta:
verbose_name_plural = _("Champs du formulaire")
ordering = ("order",)

def __str__(self):
return str(self.order)


# Input types
INPUT_TYPE_ADDRESS = "address"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ django-formtools==2.5.1
# via django-two-factor-auth
django-ipware==6.0.5
# via django-axes
django-jazzmin==2.6.1
django-jazzmin==3.0.0
# via -r requirements.in
django-jsoneditor==0.2.4
# via -r requirements.in
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ django-ipware==6.0.5
# via
# -r requirements.txt
# django-axes
django-jazzmin==2.6.1
django-jazzmin==3.0.0
# via -r requirements.txt
django-jsoneditor==0.2.4
# via -r requirements.txt
Expand Down
Loading