web fixes
This commit is contained in:
@@ -61,6 +61,8 @@ pub(crate) struct BuilderForm {
|
||||
#[serde(default)]
|
||||
pub column_quantity_ledger_input: String,
|
||||
#[serde(default)]
|
||||
pub column_required_input: String,
|
||||
#[serde(default)]
|
||||
pub column_rounding_input: String,
|
||||
#[serde(default)]
|
||||
pub column_currency_input: String,
|
||||
@@ -75,6 +77,8 @@ pub(crate) struct BuilderForm {
|
||||
#[serde(default)]
|
||||
pub column_quantity_ledger: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub column_required: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub column_rounding: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub column_currencies: Vec<String>,
|
||||
@@ -113,6 +117,7 @@ impl BuilderForm {
|
||||
decimal_scale_input: self.decimal_scale_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(),
|
||||
rounding_input: self.column_rounding_input.clone(),
|
||||
currency_input: self.column_currency_input.clone(),
|
||||
added: columns_from_rows(
|
||||
@@ -120,6 +125,7 @@ impl BuilderForm {
|
||||
&self.column_types,
|
||||
&self.column_indexed,
|
||||
&self.column_quantity_ledger,
|
||||
&self.column_required,
|
||||
&self.column_rounding,
|
||||
&self.column_currencies,
|
||||
),
|
||||
@@ -129,6 +135,12 @@ impl BuilderForm {
|
||||
// The table is being created here, so the creation-only types are
|
||||
// on the table.
|
||||
creating_table: true,
|
||||
// What the table will be, so the panel can hold a column to the
|
||||
// rules of the table it is being described for: a shared table
|
||||
// takes no column that posts to one profile's books, and no link
|
||||
// may point at the table being created.
|
||||
global: self.global,
|
||||
table_name: self.table_name.trim().to_ascii_lowercase(),
|
||||
};
|
||||
|
||||
// Drop display columns whose column is gone, so a stale post cannot
|
||||
@@ -206,12 +218,17 @@ impl AddTablePageState {
|
||||
let mut rows = Vec::new();
|
||||
|
||||
for (index, column) in columns.added.iter().enumerate() {
|
||||
// Whether it is indexed has a column of its own, so it is not
|
||||
// repeated here.
|
||||
let mut tags = Vec::new();
|
||||
if column.required {
|
||||
tags.push("required".to_string());
|
||||
}
|
||||
if column.quantity_ledger {
|
||||
tags.push("quantity ledger".to_string());
|
||||
}
|
||||
if !column.option_label().is_empty() {
|
||||
tags.push(column.option_label());
|
||||
if !column.currency.is_empty() {
|
||||
tags.push(format!("{}, {}", column.currency, column.money_mode.label()));
|
||||
}
|
||||
rows.push(ColumnRow {
|
||||
index: Some(index),
|
||||
@@ -220,7 +237,9 @@ impl AddTablePageState {
|
||||
name: column.name.clone(),
|
||||
data_type: column.data_type.clone(),
|
||||
indexable: columns.is_indexable(index),
|
||||
indexed: column.indexed,
|
||||
// A link is indexed whether or not anyone asked: the server
|
||||
// builds an index for every foreign key.
|
||||
indexed: column.is_indexed(),
|
||||
tags,
|
||||
alias_source: None,
|
||||
alias: String::new(),
|
||||
@@ -313,8 +332,17 @@ impl AddTablePageState {
|
||||
rows
|
||||
}
|
||||
|
||||
/// Row-display candidates: `id` first, then every column, matching the
|
||||
/// client's candidate list.
|
||||
/// Row-display candidates: `id` first, then every column the table will
|
||||
/// really hold.
|
||||
///
|
||||
/// That includes the columns a definition row generates — they are columns
|
||||
/// like any other once the table exists, and the server accepts them here.
|
||||
/// The definition row itself is not among them: it leaves no column of its
|
||||
/// own name behind for a row to be shown by.
|
||||
///
|
||||
/// The index is the candidate's place in this list, so the button that
|
||||
/// toggles one names the same column the label does however the list is
|
||||
/// filtered.
|
||||
pub(crate) fn row_display_candidates(&self) -> Vec<RowDisplayCandidate> {
|
||||
let mut candidates = vec![RowDisplayCandidate {
|
||||
index: 0,
|
||||
@@ -325,21 +353,13 @@ impl AddTablePageState {
|
||||
None
|
||||
},
|
||||
}];
|
||||
candidates.extend(
|
||||
self.draft
|
||||
.columns
|
||||
.added
|
||||
.iter()
|
||||
.enumerate()
|
||||
// A compound column expands into schema-managed companions, so
|
||||
// there is no column of that name for a row to be shown by.
|
||||
.filter(|(index, _)| self.draft.columns.is_indexable(*index))
|
||||
.map(|(index, column)| RowDisplayCandidate {
|
||||
index: index + 1,
|
||||
name: column.name.clone(),
|
||||
position: self.draft.row_display_position(&column.name),
|
||||
}),
|
||||
);
|
||||
for name in self.draft.row_display_column_names() {
|
||||
candidates.push(RowDisplayCandidate {
|
||||
index: candidates.len(),
|
||||
position: self.draft.row_display_position(&name),
|
||||
name,
|
||||
});
|
||||
}
|
||||
candidates
|
||||
}
|
||||
}
|
||||
@@ -409,6 +429,7 @@ mod tests {
|
||||
column_types: vec!["text".into(), "money".into()],
|
||||
column_indexed: vec!["yes".into(), "no".into()],
|
||||
column_quantity_ledger: vec!["no".into(), "no".into()],
|
||||
column_required: vec!["yes".into(), "no".into()],
|
||||
column_rounding: vec!["exact".into(), "half-up".into()],
|
||||
column_currencies: vec![String::new(), "EUR".into()],
|
||||
relation_tables: vec!["customer".into(), "project".into()],
|
||||
@@ -480,6 +501,7 @@ mod tests {
|
||||
data_type: "accounting".to_string(),
|
||||
indexed: false,
|
||||
quantity_ledger: false,
|
||||
required: false,
|
||||
money_mode: MoneyMode::Exact,
|
||||
currency: "EUR".to_string(),
|
||||
});
|
||||
@@ -523,6 +545,7 @@ mod tests {
|
||||
form.column_types.push("accounting".into());
|
||||
form.column_indexed.push("no".into());
|
||||
form.column_quantity_ledger.push("no".into());
|
||||
form.column_required.push("no".into());
|
||||
form.column_rounding.push("exact".into());
|
||||
form.column_currencies.push("EUR".into());
|
||||
form.generated_alias_sources = vec!["debit".into(), "account".into()];
|
||||
|
||||
Reference in New Issue
Block a user