talbe definition web
This commit is contained in:
@@ -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::AddTablePageState;
|
||||
struct AddTablePage<'a> {
|
||||
nav: Nav,
|
||||
page: &'a AddTablePageState,
|
||||
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],
|
||||
}
|
||||
|
||||
@@ -25,18 +25,20 @@ struct AddTablePage<'a> {
|
||||
#[template(path = "pages/add_table/builder.html")]
|
||||
struct BuilderFragment<'a> {
|
||||
page: &'a AddTablePageState,
|
||||
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>,
|
||||
}
|
||||
|
||||
pub(crate) fn render_page(page: &AddTablePageState) -> String {
|
||||
render(&AddTablePage {
|
||||
nav: page.nav.clone(),
|
||||
page,
|
||||
// Every picker is the backend's own vocabulary, asked through the
|
||||
// draft so it can only offer what the draft would accept.
|
||||
column_types: page.draft.columns.offered_types(),
|
||||
temporal_types: TEMPORAL_TYPES,
|
||||
gtin_types: GTIN_TYPES,
|
||||
temporal_types: page.draft.columns.temporal_types(),
|
||||
gtin_types: page.draft.columns.gtin_types(),
|
||||
currency_codes: CURRENCY_CODES,
|
||||
})
|
||||
}
|
||||
@@ -45,8 +47,8 @@ pub(crate) fn render_builder(page: &AddTablePageState) -> String {
|
||||
render(&BuilderFragment {
|
||||
page,
|
||||
column_types: page.draft.columns.offered_types(),
|
||||
temporal_types: TEMPORAL_TYPES,
|
||||
gtin_types: GTIN_TYPES,
|
||||
temporal_types: page.draft.columns.temporal_types(),
|
||||
gtin_types: page.draft.columns.gtin_types(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,6 +69,7 @@ mod tests {
|
||||
|
||||
fn page() -> AddTablePageState {
|
||||
let mut draft = TableDraft::new();
|
||||
draft.columns.catalog = crate::schema::tests::catalog();
|
||||
draft.profile_name = "billing".to_string();
|
||||
draft.table_name = "invoice".to_string();
|
||||
draft.columns.added.push(ColumnDefinition {
|
||||
|
||||
Reference in New Issue
Block a user