web fixes
This commit is contained in:
@@ -261,7 +261,13 @@ impl PageInputs {
|
||||
pub(crate) struct TableDefinitionPageState {
|
||||
pub nav: crate::ui::Nav,
|
||||
pub selection: Selection,
|
||||
/// The tables of the selected scope — what the workspace browses and acts
|
||||
/// on.
|
||||
pub tables: Vec<TableSummary>,
|
||||
/// What a new link may point at, which is not the same list: a profile's
|
||||
/// table may link to a shared one, and a shared table is not one of the
|
||||
/// profile's own. See `crate::pages::table_scope`.
|
||||
pub link_targets: Vec<TableSummary>,
|
||||
pub detail: Option<TableDetailView>,
|
||||
pub history: Vec<RenameEntry>,
|
||||
pub columns: ColumnDraft,
|
||||
@@ -283,12 +289,14 @@ impl TableDefinitionPageState {
|
||||
self.active == name
|
||||
}
|
||||
|
||||
/// A table cannot link to itself, and the chart of accounts is reached
|
||||
/// through an ACCOUNTING row rather than through a link of one's own.
|
||||
fn eligible_link_target(&self, table: &TableSummary) -> bool {
|
||||
table.name != self.selection.table && table.name != "accounts"
|
||||
table.name != self.selection.table && table.name != crate::schema::ACCOUNTS_TABLE
|
||||
}
|
||||
|
||||
pub(crate) fn global_link_target_tables(&self) -> Vec<&str> {
|
||||
self.tables
|
||||
self.link_targets
|
||||
.iter()
|
||||
.filter(|table| self.eligible_link_target(table) && table.global)
|
||||
.map(|table| table.name.as_str())
|
||||
@@ -296,7 +304,7 @@ impl TableDefinitionPageState {
|
||||
}
|
||||
|
||||
pub(crate) fn user_link_target_tables(&self) -> Vec<&str> {
|
||||
self.tables
|
||||
self.link_targets
|
||||
.iter()
|
||||
.filter(|table| {
|
||||
self.eligible_link_target(table) && !table.global && !table.is_system()
|
||||
@@ -306,7 +314,7 @@ impl TableDefinitionPageState {
|
||||
}
|
||||
|
||||
pub(crate) fn system_link_target_tables(&self) -> Vec<&str> {
|
||||
self.tables
|
||||
self.link_targets
|
||||
.iter()
|
||||
.filter(|table| {
|
||||
self.eligible_link_target(table) && !table.global && table.is_system()
|
||||
|
||||
Reference in New Issue
Block a user