Fix: do not allow base and constant sets to have children

This commit is contained in:
IRBorisov 2024-04-26 09:56:56 +03:00
parent 6cd52c5c24
commit 128bdf5ec4
3 changed files with 18 additions and 2 deletions

View File

@ -506,7 +506,12 @@ class SemanticInfo:
sources = self._extract_sources(target)
if len(sources) != 1:
return target.id
return next(iter(sources))
parent_id = next(iter(sources))
parent = self._cst_by_ID[parent_id]
if is_base_set(parent.cst_type):
return target.id
return parent_id
def _extract_sources(self, target: Constituenta) -> set[int]:
sources: set[int] = set()

View File

@ -259,6 +259,10 @@ class TestRSForm(TestCase):
alias='D4',
definition_formal=r'Pr2(D3)',
)
f2 = self.schema.insert_new(
alias='F2',
definition_formal=r'[α∈ℬ(X1)] X1\α',
)
self.schema.restore_order()
x1.refresh_from_db()
@ -271,6 +275,7 @@ class TestRSForm(TestCase):
d3.refresh_from_db()
d4.refresh_from_db()
f1.refresh_from_db()
f2.refresh_from_db()
a1.refresh_from_db()
self.assertEqual(x1.order, 1)
@ -284,6 +289,7 @@ class TestRSForm(TestCase):
self.assertEqual(d4.order, 9)
self.assertEqual(d2.order, 10)
self.assertEqual(f1.order, 11)
self.assertEqual(f2.order, 12)
def test_reset_aliases(self):

View File

@ -103,7 +103,12 @@ export class RSFormLoader {
if (sources.size !== 1 || sources.has(target.id)) {
return undefined;
}
return sources.values().next().value as ConstituentaID;
const parent_id = sources.values().next().value as ConstituentaID;
const parent = this.cstByID.get(parent_id);
if (parent && isBaseSet(parent.cst_type)) {
return undefined;
}
return parent_id;
}
private extractSources(target: IConstituenta): Set<ConstituentaID> {