Skip to content

Commit 80336dd

Browse files
committed
chore: bump version 0.38.1 → 0.38.2
1 parent a6cf02c commit 80336dd

3 files changed

Lines changed: 75 additions & 5 deletions

File tree

django_forms_workflows/forms.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,17 +687,35 @@ def get_initial_value(self, field_def, initial_data):
687687
"""
688688

689689
# Check if we have saved data
690-
if initial_data and field_def.field_name in initial_data:
691-
return initial_data[field_def.field_name]
690+
saved_value = None
691+
has_saved = bool(initial_data and field_def.field_name in initial_data)
692+
if has_saved:
693+
saved_value = initial_data[field_def.field_name]
694+
# Non-empty saved value always wins — it represents explicit user input
695+
if saved_value:
696+
return saved_value
697+
# Empty saved value: only skip prefill when the field has no prefill
698+
# source configured. If a prefill source IS configured we fall through
699+
# so that a draft that was auto-saved before the prefill ran (or while
700+
# the user's email was temporarily unset) doesn't permanently suppress
701+
# the prefill value.
702+
if not field_def.prefill_source_config_id:
703+
return saved_value # "" — no prefill available
692704

693705
# Handle prefill sources using data source abstraction
694706
# Use the new get_prefill_source_key method which handles both
695707
# the new prefill_source_config and legacy prefill_source
696708
prefill_key = field_def.get_prefill_source_key()
697709
if prefill_key and self.user:
698-
return self._get_prefill_value(prefill_key, field_def.prefill_source_config)
710+
prefill_value = self._get_prefill_value(
711+
prefill_key, field_def.prefill_source_config
712+
)
713+
if prefill_value:
714+
return prefill_value
699715

700-
# Default value
716+
# Fall back to empty saved value, default value, or ""
717+
if has_saved:
718+
return saved_value # already confirmed empty above
701719
return field_def.default_value or ""
702720

703721
def _get_prefill_value(self, prefill_source, prefill_config=None):

django_forms_workflows/static/django_forms_workflows/js/form-enhancements.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,58 @@ if (typeof module !== 'undefined' && module.exports) {
11711171
}
11721172
}());
11731173

1174+
/**
1175+
* Shared-row label height equaliser.
1176+
*
1177+
* When two (or more) fields share a Bootstrap row (half-width or
1178+
* third/fourth-width layout), a label that wraps onto a second line makes
1179+
* the inputs in that row appear misaligned. This IIFE walks every `.row`
1180+
* that contains multiple `.field-wrapper` columns and sets `min-height` on
1181+
* each label to match the tallest one in the row, so all inputs start at
1182+
* the same vertical position.
1183+
*
1184+
* It runs once after DOMContentLoaded and again on window resize
1185+
* (debounced) so the result stays correct across viewport sizes.
1186+
*/
1187+
(function () {
1188+
function equalizeRowLabelHeights() {
1189+
document.querySelectorAll('.row').forEach(function (row) {
1190+
// Collect the first <label> from each direct field-wrapper column.
1191+
var labels = [];
1192+
row.querySelectorAll(':scope > [class*="col-"] > .field-wrapper label').forEach(function (lbl) {
1193+
// Only take the first label per wrapper (ignore nested radio/checkbox labels).
1194+
var wrapper = lbl.closest('.field-wrapper');
1195+
if (wrapper && wrapper.parentElement.parentElement === row) {
1196+
if (!labels.find(function (l) { return l.closest('.field-wrapper') === wrapper; })) {
1197+
labels.push(lbl);
1198+
}
1199+
}
1200+
});
1201+
1202+
// Reset before measuring so a shrink is reflected correctly.
1203+
labels.forEach(function (lbl) { lbl.style.minHeight = ''; });
1204+
1205+
if (labels.length < 2) return;
1206+
1207+
var maxH = 0;
1208+
labels.forEach(function (lbl) { maxH = Math.max(maxH, lbl.offsetHeight); });
1209+
1210+
if (maxH > 0) {
1211+
labels.forEach(function (lbl) { lbl.style.minHeight = maxH + 'px'; });
1212+
}
1213+
});
1214+
}
1215+
1216+
document.addEventListener('DOMContentLoaded', function () {
1217+
equalizeRowLabelHeights();
1218+
var _resizeTimer;
1219+
window.addEventListener('resize', function () {
1220+
clearTimeout(_resizeTimer);
1221+
_resizeTimer = setTimeout(equalizeRowLabelHeights, 120);
1222+
});
1223+
});
1224+
}());
1225+
11741226
/**
11751227
* Currency field enhancement.
11761228
*

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-forms-workflows"
3-
version = "0.38.1"
3+
version = "0.38.2"
44
description = "Enterprise-grade, database-driven form builder with approval workflows and external data integration"
55
license = "LGPL-3.0-only"
66
readme = "README.md"

0 commit comments

Comments
 (0)