decimal precision constrained
This commit is contained in:
@@ -61,6 +61,8 @@ pub(crate) struct BuilderForm {
|
||||
#[serde(default)]
|
||||
pub decimal_scale_input: String,
|
||||
#[serde(default)]
|
||||
pub fixed_decimal_input: String,
|
||||
#[serde(default)]
|
||||
pub column_indexing_input: String,
|
||||
#[serde(default)]
|
||||
pub column_quantity_ledger_input: String,
|
||||
@@ -128,6 +130,7 @@ impl BuilderForm {
|
||||
link_table_input: self.link_table_input.clone(),
|
||||
decimal_precision_input: self.decimal_precision_input.clone(),
|
||||
decimal_scale_input: self.decimal_scale_input.clone(),
|
||||
fixed_decimal_input: self.fixed_decimal_input.clone(),
|
||||
indexing_input: self.column_indexing_input.clone(),
|
||||
quantity_ledger_input: self.column_quantity_ledger_input.clone(),
|
||||
required_input: self.column_required_input.clone(),
|
||||
|
||||
@@ -245,11 +245,18 @@ mod tests {
|
||||
assert!(html.contains("Every profile can use this shared table."));
|
||||
}
|
||||
|
||||
/// Every type the server accepts has to be reachable from the picker, or
|
||||
/// the web UI silently offers less than the backend does.
|
||||
/// Fixed-scale decimal is the one intentionally gated type; enabling the
|
||||
/// advanced control makes it reachable without removing server support.
|
||||
#[test]
|
||||
fn the_type_picker_offers_the_parameterised_and_interval_types() {
|
||||
let html = render_builder(&page());
|
||||
let mut state = page();
|
||||
let html = render_builder(&state);
|
||||
|
||||
assert!(!html.contains(r#"<option value="decimal""#));
|
||||
assert!(html.contains(r#"name="fixed_decimal_input""#));
|
||||
|
||||
state.draft.columns.fixed_decimal_input = "yes".to_string();
|
||||
let html = render_builder(&state);
|
||||
|
||||
for column_type in ["decimal", "duration", "period", "accounting"] {
|
||||
assert!(
|
||||
@@ -273,10 +280,12 @@ mod tests {
|
||||
assert!(render_builder(&state).contains(r#"name="gtin_type_input""#));
|
||||
|
||||
// Decimal reveals its precision and scale.
|
||||
state.draft.columns.fixed_decimal_input = "yes".to_string();
|
||||
state.draft.columns.type_input = "decimal".to_string();
|
||||
let html = render_builder(&state);
|
||||
assert!(html.contains(r#"name="decimal_precision_input""#));
|
||||
assert!(html.contains(r#"name="decimal_scale_input""#));
|
||||
assert!(html.contains("Advanced fixed-scale decimal"));
|
||||
|
||||
// Money reveals its currency and rounding inputs.
|
||||
state.draft.columns.type_input = "money".to_string();
|
||||
|
||||
Reference in New Issue
Block a user