fixing errors2

This commit is contained in:
Priec
2026-08-15 15:32:11 +02:00
parent fa9ee23538
commit 52b0dbd744
6 changed files with 104 additions and 28 deletions

View File

@@ -545,6 +545,11 @@ impl TableDraft {
)
});
}
// A ragged post can leave no columns at all, and "add at least one
// column" would then be answering a question nobody asked.
if let Some(ragged) = self.columns.ragged {
return Err(ragged.message(locale));
}
if self.columns.is_empty() {
return Err(tr!(locale, "draft-err-no-columns"));
}

View File

@@ -107,6 +107,15 @@ impl BuilderForm {
pub(crate) fn to_draft(&self) -> TableDraft {
let creating_new_profile = self.creating_new_profile();
let (added, ragged) = columns_from_rows(
&self.column_names,
&self.column_types,
&self.column_indexed,
&self.column_quantity_ledger,
&self.column_required,
&self.column_rounding,
&self.column_currencies,
);
let columns = ColumnDraft {
name_input: self.column_name_input.clone(),
type_input: self.column_type_input.clone(),
@@ -120,15 +129,8 @@ impl BuilderForm {
required_input: self.column_required_input.clone(),
rounding_input: self.column_rounding_input.clone(),
currency_input: self.column_currency_input.clone(),
added: columns_from_rows(
&self.column_names,
&self.column_types,
&self.column_indexed,
&self.column_quantity_ledger,
&self.column_required,
&self.column_rounding,
&self.column_currencies,
),
added,
ragged,
// Filled in by the loader from `ListColumnTypes`, never by the
// form: it is the vocabulary the draft is validated against.
catalog: ColumnCatalog::default(),