talbe definition web

This commit is contained in:
Priec
2026-08-06 17:47:53 +02:00
parent f13def52c1
commit 5f4b026624
14 changed files with 870 additions and 273 deletions

View File

@@ -1,7 +1,7 @@
use askama::Template;
use crate::{
schema::{CURRENCY_CODES, GTIN_TYPES, TEMPORAL_TYPES},
schema::CURRENCY_CODES,
ui::{Alert, Nav, render},
};
@@ -13,9 +13,9 @@ use super::state::TableDefinitionPageState;
struct TableDefinitionPage<'a> {
nav: Nav,
page: &'a TableDefinitionPageState,
column_types: &'static [&'static str],
temporal_types: &'static [&'static str],
gtin_types: &'static [&'static str],
column_types: Vec<String>,
temporal_types: Vec<String>,
gtin_types: Vec<String>,
currency_codes: &'static [&'static str],
/// False, as on the workspace fragment: the page embeds both, and the
/// outcome is reported once, at the top.
@@ -28,9 +28,9 @@ struct TableDefinitionPage<'a> {
#[template(path = "pages/admin/table_definition/workspace.html")]
struct WorkspaceFragment<'a> {
page: &'a TableDefinitionPageState,
column_types: &'static [&'static str],
temporal_types: &'static [&'static str],
gtin_types: &'static [&'static str],
column_types: Vec<String>,
temporal_types: Vec<String>,
gtin_types: Vec<String>,
/// False: the workspace shows the outcome of the last action itself, at
/// the top, so the panel it embeds must not repeat it.
standalone_column_panel: bool,
@@ -41,9 +41,9 @@ struct WorkspaceFragment<'a> {
#[template(path = "pages/admin/table_definition/column_panel.html")]
struct ColumnPanelFragment<'a> {
page: &'a TableDefinitionPageState,
column_types: &'static [&'static str],
temporal_types: &'static [&'static str],
gtin_types: &'static [&'static str],
column_types: Vec<String>,
temporal_types: Vec<String>,
gtin_types: Vec<String>,
/// True: this is the whole response, so a refused column has nowhere else
/// to be reported.
standalone_column_panel: bool,
@@ -56,8 +56,8 @@ pub(crate) fn render_page(page: &TableDefinitionPageState) -> String {
// Asking the draft, so the picker can only ever offer what the draft
// would accept — the accounting rule is stated once.
column_types: page.columns.offered_types(),
temporal_types: TEMPORAL_TYPES,
gtin_types: GTIN_TYPES,
temporal_types: page.columns.temporal_types(),
gtin_types: page.columns.gtin_types(),
currency_codes: CURRENCY_CODES,
standalone_column_panel: false,
})
@@ -69,8 +69,8 @@ pub(crate) fn render_workspace(page: &TableDefinitionPageState) -> String {
// Asking the draft, so the picker can only ever offer what the draft
// would accept — the accounting rule is stated once.
column_types: page.columns.offered_types(),
temporal_types: TEMPORAL_TYPES,
gtin_types: GTIN_TYPES,
temporal_types: page.columns.temporal_types(),
gtin_types: page.columns.gtin_types(),
standalone_column_panel: false,
})
}
@@ -81,8 +81,8 @@ pub(crate) fn render_column_panel(page: &TableDefinitionPageState) -> String {
// Asking the draft, so the picker can only ever offer what the draft
// would accept — the accounting rule is stated once.
column_types: page.columns.offered_types(),
temporal_types: TEMPORAL_TYPES,
gtin_types: GTIN_TYPES,
temporal_types: page.columns.temporal_types(),
gtin_types: page.columns.gtin_types(),
standalone_column_panel: true,
})
}
@@ -131,6 +131,7 @@ mod tests {
columns: vec![DetailColumn {
name: "number".to_string(),
field_type: "text".to_string(),
sql_type: "TEXT".to_string(),
currency: String::new(),
quantity_ledger: false,
rounded: false,
@@ -140,7 +141,7 @@ mod tests {
}],
}),
history: Vec::new(),
columns: ColumnDraft::for_append(),
columns: ColumnDraft::for_append(crate::schema::tests::catalog()),
rename: RenameForm::default(),
copy: CopyForm::default(),
invoice: InvoiceTemplateForm::default(),