B: Fix substitution UI error
Some checks failed
Backend CI / build (3.12) (push) Has been cancelled
Frontend CI / build (22.x) (push) Has been cancelled

This commit is contained in:
Ivan 2024-12-20 15:01:23 +03:00
parent 8bad0890cd
commit f919bfe4cf
5 changed files with 10 additions and 6 deletions

View File

@ -95,7 +95,7 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
}, [schemasIDs, needPreload, cache]); }, [schemasIDs, needPreload, cache]);
useEffect(() => { useEffect(() => {
if (cache.loading || schemas.length !== schemasIDs.length) { if (cache.loading || schemas.length !== schemasIDs.length || schemas.length === 0) {
return; return;
} }
setSubstitutions(prev => setSubstitutions(prev =>
@ -114,7 +114,7 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
}, [schemasIDs, schemas, cache.loading, getSchemaByCst]); }, [schemasIDs, schemas, cache.loading, getSchemaByCst]);
useEffect(() => { useEffect(() => {
if (cache.loading || schemas.length !== schemasIDs.length) { if (cache.loading || schemas.length !== schemasIDs.length || schemas.length === 0) {
return; return;
} }
const validator = new SubstitutionValidator(schemas, substitutions); const validator = new SubstitutionValidator(schemas, substitutions);

View File

@ -44,7 +44,7 @@ function TabSynthesis({
disabled disabled
value={validationText} value={validationText}
rows={4} rows={4}
style={{ borderColor: isCorrect ? undefined : APP_COLORS.fgRed }} style={{ borderColor: isCorrect ? undefined : APP_COLORS.fgRed, borderWidth: isCorrect ? undefined : '2px' }}
/> />
</div> </div>
</DataLoader> </DataLoader>

View File

@ -75,6 +75,7 @@ export class RSFormLoader {
const order = this.graph.topologicalOrder(); const order = this.graph.topologicalOrder();
order.forEach(cstID => { order.forEach(cstID => {
const cst = this.cstByID.get(cstID)!; const cst = this.cstByID.get(cstID)!;
cst.schema = this.schema.id;
cst.status = inferStatus(cst.parse.status, cst.parse.valueClass); cst.status = inferStatus(cst.parse.status, cst.parse.valueClass);
cst.is_template = inferTemplate(cst.definition_formal); cst.is_template = inferTemplate(cst.definition_formal);
cst.cst_class = inferClass(cst.cst_type, cst.is_template); cst.cst_class = inferClass(cst.cst_type, cst.is_template);

View File

@ -70,9 +70,10 @@ export class SubstitutionValidator {
constructor(schemas: IRSForm[], substitutions: ICstSubstitute[]) { constructor(schemas: IRSForm[], substitutions: ICstSubstitute[]) {
this.schemas = schemas; this.schemas = schemas;
this.substitutions = substitutions; this.substitutions = substitutions;
if (this.substitutions.length === 0) { if (schemas.length === 0 || substitutions.length === 0) {
return; return;
} }
schemas.forEach(schema => { schemas.forEach(schema => {
this.schemaByID.set(schema.id, schema); this.schemaByID.set(schema.id, schema);
this.mapping.set(schema.id, {}); this.mapping.set(schema.id, {});

View File

@ -65,7 +65,6 @@ export interface TermForm {
*/ */
export interface IConstituentaMeta { export interface IConstituentaMeta {
id: ConstituentaID; id: ConstituentaID;
schema: LibraryItemID;
alias: string; alias: string;
convention: string; convention: string;
cst_type: CstType; cst_type: CstType;
@ -101,6 +100,9 @@ export interface IConstituentaData extends IConstituentaMeta {
* Represents Constituenta. * Represents Constituenta.
*/ */
export interface IConstituenta extends IConstituentaData { export interface IConstituenta extends IConstituentaData {
/** {@link LibraryItemID} of this {@link IConstituenta}. */
schema: LibraryItemID;
/** {@link CstClass} of this {@link IConstituenta}. */ /** {@link CstClass} of this {@link IConstituenta}. */
cst_class: CstClass; cst_class: CstClass;
/** {@link ExpressionStatus} of this {@link IConstituenta}. */ /** {@link ExpressionStatus} of this {@link IConstituenta}. */
@ -135,7 +137,7 @@ export interface IConstituenta extends IConstituentaData {
/** /**
* Represents {@link IConstituenta} reference. * Represents {@link IConstituenta} reference.
*/ */
export interface IConstituentaReference extends Pick<IConstituentaMeta, 'id' | 'schema'> {} export interface IConstituentaReference extends Pick<IConstituenta, 'id' | 'schema'> {}
/** /**
* Represents Constituenta list. * Represents Constituenta list.