versioning of FK for archiving
This commit is contained in:
@@ -35,6 +35,7 @@ pub(crate) struct TableDraft {
|
||||
/// Profile name typed in when creating a new profile.
|
||||
pub profile_name_input: String,
|
||||
pub creating_new_profile: bool,
|
||||
pub global: bool,
|
||||
pub accounting_currency: String,
|
||||
|
||||
pub table_name: String,
|
||||
@@ -69,11 +70,11 @@ impl TableDraft {
|
||||
// ---- field visibility (the same rules the TUI canvas applies) --------
|
||||
|
||||
pub(crate) fn show_profile_name_input(&self) -> bool {
|
||||
self.creating_new_profile
|
||||
self.creating_new_profile && !self.global
|
||||
}
|
||||
|
||||
pub(crate) fn show_accounting_currency(&self) -> bool {
|
||||
self.creating_new_profile
|
||||
self.creating_new_profile && !self.global
|
||||
}
|
||||
|
||||
// ---- mutations -------------------------------------------------------
|
||||
@@ -211,10 +212,10 @@ impl TableDraft {
|
||||
/// Every check the client runs before it will save.
|
||||
pub(crate) fn validate(&self) -> Result<(), String> {
|
||||
let profile_name = self.effective_profile_name();
|
||||
if self.creating_new_profile && profile_name.is_empty() {
|
||||
if !self.global && self.creating_new_profile && profile_name.is_empty() {
|
||||
return Err("Enter a name for the new profile.".to_string());
|
||||
}
|
||||
if let Some(error) = validate_identifier(&profile_name, "Profile name", false) {
|
||||
if !self.global && let Some(error) = validate_identifier(&profile_name, "Profile name", false) {
|
||||
return Err(error);
|
||||
}
|
||||
if let Some(error) = validate_accounting_currency(self) {
|
||||
@@ -244,18 +245,19 @@ impl TableDraft {
|
||||
profile_name: self.effective_profile_name(),
|
||||
columns: proto_columns(&self.columns.added),
|
||||
indexes: self.columns.selected_index_names(),
|
||||
accounting_currency: if self.creating_new_profile {
|
||||
accounting_currency: if self.creating_new_profile && !self.global {
|
||||
self.accounting_currency.trim().to_ascii_uppercase()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
row_display_columns: self.row_display_columns.clone(),
|
||||
global: self.global,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn validate_accounting_currency(draft: &TableDraft) -> Option<String> {
|
||||
if !draft.creating_new_profile {
|
||||
if !draft.creating_new_profile || draft.global {
|
||||
return None;
|
||||
}
|
||||
let currency = draft.accounting_currency.to_ascii_uppercase();
|
||||
|
||||
Reference in New Issue
Block a user