Skip to content

Commit 60a1762

Browse files
authored
Merge pull request #15 from jowilf/bug_fix
Fix SearchBuilder not working with dates (SQLAlchemy)
2 parents f7f59f1 + 67799ab commit 60a1762

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

starlette_admin/statics/js/list.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,17 @@ $(function () {
105105
});
106106
} else {
107107
if (c.type.startsWith("moment-")) {
108-
search_format = columns[c.origData].search_format;
109-
if (!search_format) search_format = moment.defaultFormat;
108+
searchFormat = model.fields.find(
109+
(f) => f.name == c.origData
110+
)?.search_format;
111+
if (!searchFormat) searchFormat = moment.defaultFormat;
110112
c.value = [];
111113
if (c.value1) {
112-
c.value1 = moment(c.value1).format(search_format);
114+
c.value1 = moment(c.value1).format(searchFormat);
113115
c.value.push(c.value1);
114116
}
115117
if (c.value2) {
116-
c.value2 = moment(c.value2).format(search_format);
118+
c.value2 = moment(c.value2).format(searchFormat);
117119
c.value.push(c.value2);
118120
}
119121
} else if (c.type == "num") {

0 commit comments

Comments
 (0)