Skip to content

Commit 9178803

Browse files
authored
sort alphabetically dropdown boxes (#582)
1 parent 8e81092 commit 9178803

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Changes
88

99
- pyproject.toml upgraded for poetry 2.0
10+
- in document details view, values of document type dropdown are sorted alphabetically and autocomplete
11+
- in "new document type" modal dialog, custom field dropdown is sorted alphabetically
1012

1113
### Adds
1214

papermerge/core/features/custom_fields/db/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def get_custom_fields(
7373
def get_custom_fields_without_pagination(
7474
db_session: Session, user_id: uuid.UUID
7575
) -> list[schema.CustomField]:
76-
stmt = select(orm.CustomField).where(orm.CustomField.user_id == user_id)
76+
stmt = (
77+
select(orm.CustomField)
78+
.order_by(orm.CustomField.name.asc())
79+
.where(orm.CustomField.user_id == user_id)
80+
)
7781

7882
db_cfs = db_session.scalars(stmt).all()
7983
items = [schema.CustomField.model_validate(db_cf) for db_cf in db_cfs]

papermerge/core/features/document_types/db/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
def get_document_types_without_pagination(
2020
db_session: Session, user_id: uuid.UUID
2121
) -> list[schema.DocumentType]:
22-
stmt = select(orm.DocumentType).where(orm.DocumentType.user_id == user_id)
22+
stmt = (
23+
select(orm.DocumentType)
24+
.order_by(orm.DocumentType.name.asc())
25+
.where(orm.DocumentType.user_id == user_id)
26+
)
2327

2428
db_document_types = db_session.scalars(stmt).all()
2529
items = [

ui2/src/cconstants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ export const ONE_DAY_IN_SECONDS = 86400
5353
export const DRAGGED = "dragged"
5454

5555
export const CUSTOM_FIELD_DATA_TYPES: Array<CustomFieldDataType> = [
56-
"text",
57-
"date",
5856
"boolean",
59-
"int",
57+
"date",
6058
"float",
59+
"int",
6160
"monetary",
61+
"text",
6262
"yearmonth"
6363
]
6464

ui2/src/features/document/components/DocumentDetails/CustomFields.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export default function CustomFields() {
185185
onChange={onDocumentTypeChange}
186186
onClear={onClearDocumentType}
187187
clearable
188+
searchable
188189
/>
189190
<Stack>{genericCustomFieldsComponents}</Stack>
190191
{isErrorGetDocCF && (

0 commit comments

Comments
 (0)