mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-05 17:19:33 +08:00
check modules when validating expression
This commit is contained in:
parent
cc21a427e0
commit
b874ca203d
@ -6,6 +6,7 @@ import {
|
||||
ComponentType,
|
||||
IAppModel,
|
||||
IComponentModel,
|
||||
ModuleId,
|
||||
SlotName,
|
||||
} from './IAppModel';
|
||||
import { genComponent } from './utils';
|
||||
@ -36,6 +37,10 @@ export class AppModel implements IAppModel {
|
||||
return Object.values(this.componentMap);
|
||||
}
|
||||
|
||||
get moduleIds(): ModuleId[] {
|
||||
return this.allComponents.filter(c => c.type === 'core/v1/moduleContainer').map(c => c.properties.rawValue.id);
|
||||
}
|
||||
|
||||
toSchema(): ComponentSchema[] {
|
||||
this.schema = this.allComponents.map(c => {
|
||||
return c.toSchema();
|
||||
|
@ -39,6 +39,7 @@ export type EventName = string & {
|
||||
export interface IAppModel {
|
||||
topComponents: IComponentModel[];
|
||||
// modules: IModuleModel[];
|
||||
moduleIds: ModuleId[];
|
||||
// generated by traverse the tree. Component will be overwritten if its id is duplicated.
|
||||
allComponents: IComponentModel[];
|
||||
// all components, including orphan component
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { get, has } from 'lodash-es';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import { ComponentId, ModuleId } from '../../AppModel/IAppModel';
|
||||
import {
|
||||
PropertiesValidatorRule,
|
||||
PropertiesValidateContext,
|
||||
@ -97,8 +97,11 @@ class ExpressionValidatorRule implements PropertiesValidatorRule {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (appModel.moduleIds.includes(id as ModuleId)) {
|
||||
// case 3: id is a module
|
||||
// TODO: check module stateMap
|
||||
} else {
|
||||
// case 3: id doesn't exist
|
||||
// case 4: id doesn't exist
|
||||
results.push({
|
||||
message: `Cannot find '${id}' in store or window.`,
|
||||
componentId: component.id,
|
||||
|
Loading…
Reference in New Issue
Block a user