fixed errors
This commit is contained in:
parent
fb4fa52c14
commit
ba5394107a
14 changed files with 131 additions and 104 deletions
8
ui/src/core/model/form.ts
Normal file
8
ui/src/core/model/form.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
export enum FormType {
|
||||||
|
weights = "weights",
|
||||||
|
robotName = "robot_name",
|
||||||
|
cameraDeviceForm = "camera",
|
||||||
|
topic = "topic",
|
||||||
|
formBuilder = "formBuilder",
|
||||||
|
moveToPose = "move_to_pose",
|
||||||
|
}
|
|
@ -3,56 +3,57 @@ import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/p
|
||||||
import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from "../../features/dataset/dataset_model";
|
import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from "../../features/dataset/dataset_model";
|
||||||
import { DependencyViewModel } from "./skill_model";
|
import { DependencyViewModel } from "./skill_model";
|
||||||
import { ValidationModel } from "./validation_model";
|
import { ValidationModel } from "./validation_model";
|
||||||
|
import { FormType } from "./form";
|
||||||
|
|
||||||
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
public result: string;
|
public result: string;
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
public context: string;
|
public context: string;
|
||||||
public form: string[];
|
public form: string[];
|
||||||
public output: any;
|
public output: any;
|
||||||
constructor(context: string, result: string, form: string[], output: string) {
|
constructor(context: string, result: string, form: string[], output: string) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.form = form;
|
this.form = form;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
toView = (store: BehaviorTreeBuilderStore | undefined) => <>IsFilled</>;
|
type: FormType = FormType.formBuilder;
|
||||||
static isEmpty = (formBuilderValidationModel: FormBuilderValidationModel) =>
|
toView = (store: BehaviorTreeBuilderStore | undefined) => <>IsFilled</>;
|
||||||
formBuilderValidationModel.context.isEmpty() &&
|
static isEmpty = (formBuilderValidationModel: FormBuilderValidationModel) =>
|
||||||
formBuilderValidationModel.result.isEmpty() &&
|
formBuilderValidationModel.context.isEmpty() &&
|
||||||
formBuilderValidationModel.form.isEmpty();
|
formBuilderValidationModel.result.isEmpty() &&
|
||||||
|
formBuilderValidationModel.form.isEmpty();
|
||||||
static datasetEmpty() {
|
|
||||||
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
static datasetEmpty() {
|
||||||
}
|
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||||
static empty() {
|
}
|
||||||
return new FormBuilderValidationModel("", "", [], "");
|
static empty() {
|
||||||
}
|
return new FormBuilderValidationModel("", "", [], "");
|
||||||
static emptyTest() {
|
}
|
||||||
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
static emptyTest() {
|
||||||
}
|
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||||
static creteDataSetTest() {
|
}
|
||||||
return new FormBuilderValidationModel(``, scene, [], "");
|
static creteDataSetTest() {
|
||||||
}
|
return new FormBuilderValidationModel(``, scene, [], "");
|
||||||
static vision(): FormBuilderValidationModel {
|
}
|
||||||
return new FormBuilderValidationModel(
|
static vision(): FormBuilderValidationModel {
|
||||||
`ENUM PRETRAIN = "true","false";`,
|
return new FormBuilderValidationModel(
|
||||||
`{
|
`ENUM PRETRAIN = "true","false";`,
|
||||||
|
`{
|
||||||
"numberOfEpochs": \${numberOfEpochs:number:10},
|
"numberOfEpochs": \${numberOfEpochs:number:10},
|
||||||
"selectDataset": \${<SelectDataset/>:OBJECT:{"dataset": {}},
|
"selectDataset": \${<SelectDataset/>:OBJECT:{"dataset": {}},
|
||||||
"pretrain": \${pretrain:Enum<PRETRAIN>:true}
|
"pretrain": \${pretrain:Enum<PRETRAIN>:true}
|
||||||
}`,
|
}`,
|
||||||
[],
|
[],
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
export const scene = `{
|
}
|
||||||
|
export const scene = `{
|
||||||
"center_shell": [\${CENTER_SHELL_1:number:0}, \${CENTER_SHELL_2:number:0}, \${CENTER_SHELL_3:number:0}],
|
"center_shell": [\${CENTER_SHELL_1:number:0}, \${CENTER_SHELL_2:number:0}, \${CENTER_SHELL_3:number:0}],
|
||||||
"scene":\${<SelectScene/>:OBJECT:{"details": []}
|
"scene":\${<SelectScene/>:OBJECT:{"details": []}
|
||||||
}`;
|
}`;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import makeAutoObservable from "mobx-store-inheritance";
|
||||||
|
import clone from "just-clone";
|
||||||
import { IsArray, IsEnum, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator";
|
import { IsArray, IsEnum, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||||
import { Type } from "class-transformer";
|
import { Type } from "class-transformer";
|
||||||
import { ISkillView } from "../../features/behavior_tree_builder/presentation/ui/skill_tree/skill_tree";
|
import { ISkillView } from "../../features/behavior_tree_builder/presentation/ui/skill_tree/skill_tree";
|
||||||
|
@ -6,8 +8,10 @@ import { Result } from "../helper/result";
|
||||||
import { ValidationModel } from "./validation_model";
|
import { ValidationModel } from "./validation_model";
|
||||||
import { ITopicModel, TopicViewModel } from "../../features/topics/topic_view_model";
|
import { ITopicModel, TopicViewModel } from "../../features/topics/topic_view_model";
|
||||||
import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/presentation/behavior_tree_builder_store";
|
import { BehaviorTreeBuilderStore } from "../../features/behavior_tree_builder/presentation/behavior_tree_builder_store";
|
||||||
import makeAutoObservable from "mobx-store-inheritance";
|
import { TopicDependencyViewModel } from "../../features/behavior_tree_builder/presentation/ui/forms/topics_form/topic_dependency_view_model";
|
||||||
import clone from "just-clone";
|
import { FormBuilderValidationModel } from "./form_builder_validation_model";
|
||||||
|
import { FormType } from "./form";
|
||||||
|
|
||||||
export interface IDependency {
|
export interface IDependency {
|
||||||
skills: ISkillDependency[];
|
skills: ISkillDependency[];
|
||||||
}
|
}
|
||||||
|
@ -22,8 +26,6 @@ export interface ISkill {
|
||||||
SkillPackage: ISkillPackage;
|
SkillPackage: ISkillPackage;
|
||||||
Module: IModule;
|
Module: IModule;
|
||||||
BTAction: IBTAction[];
|
BTAction: IBTAction[];
|
||||||
// Interface: IInterface;
|
|
||||||
// Settings: ISetting[];
|
|
||||||
}
|
}
|
||||||
export interface IWeightsDependency {
|
export interface IWeightsDependency {
|
||||||
weights_name: string;
|
weights_name: string;
|
||||||
|
@ -40,14 +42,28 @@ export interface IParam {
|
||||||
type: string;
|
type: string;
|
||||||
dependency?: DependencyViewModel;
|
dependency?: DependencyViewModel;
|
||||||
}
|
}
|
||||||
export class DependencyViewModel {
|
|
||||||
|
abstract class IDependencyViewModel {
|
||||||
|
abstract type: FormType;
|
||||||
|
}
|
||||||
|
export class DependencyViewModel implements IDependencyViewModel {
|
||||||
|
type: FormType;
|
||||||
static empty = () => new DependencyViewModel();
|
static empty = () => new DependencyViewModel();
|
||||||
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => "string";
|
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => "Dependency view model error";
|
||||||
}
|
}
|
||||||
export class ParamViewModel implements IParam {
|
export class ParamViewModel implements IParam {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
@Type(() => DependencyViewModel)
|
@Type(() => DependencyViewModel, {
|
||||||
|
discriminator: {
|
||||||
|
property: "type",
|
||||||
|
subTypes: [
|
||||||
|
{ value: TopicDependencyViewModel, name: FormType.topic },
|
||||||
|
{ value: FormBuilderValidationModel, name: FormType.formBuilder },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
keepDiscriminatorProperty: true,
|
||||||
|
})
|
||||||
dependency: DependencyViewModel;
|
dependency: DependencyViewModel;
|
||||||
isFilled: boolean = false;
|
isFilled: boolean = false;
|
||||||
constructor(type: string, dependency: DependencyViewModel) {
|
constructor(type: string, dependency: DependencyViewModel) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { SceneManagerPath } from "../../../features/scene_manager/presentation/s
|
||||||
import { AssemblesScreenPath } from "../../../features/assembles/assembles_screen";
|
import { AssemblesScreenPath } from "../../../features/assembles/assembles_screen";
|
||||||
import { SimulationScreenPath } from "../../../features/simulations/simulations_screen";
|
import { SimulationScreenPath } from "../../../features/simulations/simulations_screen";
|
||||||
import { EstimateScreenPath } from "../../../features/estimate/estimate_screen";
|
import { EstimateScreenPath } from "../../../features/estimate/estimate_screen";
|
||||||
import { BehaviorTreeBuilderPath } from "../../../features/behavior_tree_builder/presentation/behavior_tree_builder_screen";
|
|
||||||
import { CalculationInstanceScreenPath as SkillScreenPath } from "../../../features/calculation_instance/presentation/calculation_instance_screen";
|
import { CalculationInstanceScreenPath as SkillScreenPath } from "../../../features/calculation_instance/presentation/calculation_instance_screen";
|
||||||
import { UiBaseError } from "../../model/ui_base_error";
|
import { UiBaseError } from "../../model/ui_base_error";
|
||||||
import { DetailsScreenPath } from "../../../features/details/details_screen";
|
import { DetailsScreenPath } from "../../../features/details/details_screen";
|
||||||
|
@ -54,7 +53,6 @@ export interface IMainPageProps {
|
||||||
bodyChildren?: JSX.Element;
|
bodyChildren?: JSX.Element;
|
||||||
panelChildren?: JSX.Element;
|
panelChildren?: JSX.Element;
|
||||||
panelStyle?: React.CSSProperties;
|
panelStyle?: React.CSSProperties;
|
||||||
|
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
maskLoader?: boolean;
|
maskLoader?: boolean;
|
||||||
error?: UiBaseError[];
|
error?: UiBaseError[];
|
||||||
|
|
|
@ -52,16 +52,22 @@ export class BehaviorTreeBuilderModel {
|
||||||
}
|
}
|
||||||
public static xmlFormat = (result: string, btRootTag: string): Result<string, string> => {
|
public static xmlFormat = (result: string, btRootTag: string): Result<string, string> => {
|
||||||
try {
|
try {
|
||||||
return Result.ok(xmlFormat(btRootTag.replace("${bt}", result)));
|
return Result.ok(
|
||||||
|
xmlFormat(
|
||||||
|
'<root BTCPP_format="4"><BehaviorTree ID="Main">${bt}</BehaviorTree></root>'.replace(
|
||||||
|
"${bt}",
|
||||||
|
btRootTag.replace("${bt}", result)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
console.log(btRootTag);
|
console.log(btRootTag);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
console.log(btRootTag.replace("${bt}", result))
|
|
||||||
return Result.error(error as string);
|
return Result.error(error as string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills,) {
|
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills) {
|
||||||
try {
|
try {
|
||||||
if (skills?.getSkillsNames().find((el) => el.name.isEqual(editor.getNode(id)!.label))) {
|
if (skills?.getSkillsNames().find((el) => el.name.isEqual(editor.getNode(id)!.label))) {
|
||||||
return `Action ID="RbsAction" do="${skills.getSkillDo(editor.getNode(id)!.label)}" command="${
|
return `Action ID="RbsAction" do="${skills.getSkillDo(editor.getNode(id)!.label)}" command="${
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import makeAutoObservable from "mobx-store-inheritance";
|
||||||
|
import clone from "just-clone";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { NavigateFunction } from "react-router-dom";
|
import { NavigateFunction } from "react-router-dom";
|
||||||
import makeAutoObservable from "mobx-store-inheritance";
|
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import clone from "just-clone";
|
|
||||||
import { CoreError, UiDrawerFormState } from "../../../core/store/base_store";
|
import { CoreError, UiDrawerFormState } from "../../../core/store/base_store";
|
||||||
import {
|
import {
|
||||||
BehaviorTreeBuilderModel,
|
BehaviorTreeBuilderModel,
|
||||||
|
@ -21,7 +21,7 @@ import { DependencyViewModel, IParam, Skills } from "../../../core/model/skill_m
|
||||||
import { ISkillView } from "./ui/skill_tree/skill_tree";
|
import { ISkillView } from "./ui/skill_tree/skill_tree";
|
||||||
import { BehaviorTreeViewModel } from "../model/behavior_tree_view_model";
|
import { BehaviorTreeViewModel } from "../model/behavior_tree_view_model";
|
||||||
import { UiBaseError } from "../../../core/model/ui_base_error";
|
import { UiBaseError } from "../../../core/model/ui_base_error";
|
||||||
import { BehaviorTreeBuilderPath, behaviorTreeBuilderStore } from "./behavior_tree_builder_screen";
|
import { behaviorTreeBuilderStore } from "./behavior_tree_builder_screen";
|
||||||
import { BehaviorTreeModel } from "../model/behavior_tree_model";
|
import { BehaviorTreeModel } from "../model/behavior_tree_model";
|
||||||
import { PrimitiveViewModel, SystemPrimitive } from "../model/primitive_view_model";
|
import { PrimitiveViewModel, SystemPrimitive } from "../model/primitive_view_model";
|
||||||
import { SceneAsset } from "../../../core/model/scene_asset";
|
import { SceneAsset } from "../../../core/model/scene_asset";
|
||||||
|
@ -149,12 +149,10 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
||||||
this.nodeUpdateObserver = undefined;
|
this.nodeUpdateObserver = undefined;
|
||||||
}
|
}
|
||||||
async init(navigate: NavigateFunction): Promise<void> {
|
async init(navigate: NavigateFunction): Promise<void> {
|
||||||
(await this.behaviorTreeBuilderHttpRepository.getActiveProjectId())
|
(await this.behaviorTreeBuilderHttpRepository.getActiveProjectId()).map((el) => {
|
||||||
// eslint-disable-next-line array-callback-return
|
this.activeProject = el.id;
|
||||||
.map((el) => {
|
this.viewModel.project = this.activeProject;
|
||||||
this.activeProject = el.id;
|
});
|
||||||
this.viewModel.project = this.activeProject;
|
|
||||||
});
|
|
||||||
(await this.behaviorTreeBuilderHttpRepository.getBtSkills()).fold(
|
(await this.behaviorTreeBuilderHttpRepository.getBtSkills()).fold(
|
||||||
(model) => {
|
(model) => {
|
||||||
this.skillTemplates = Skills.fromSkills(model);
|
this.skillTemplates = Skills.fromSkills(model);
|
||||||
|
@ -164,7 +162,6 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
||||||
}
|
}
|
||||||
return el;
|
return el;
|
||||||
});
|
});
|
||||||
// this.sceneAsset = this.behaviorTreeBuilderHttpRepository.getScene()
|
|
||||||
},
|
},
|
||||||
(e) => console.log(e)
|
(e) => console.log(e)
|
||||||
);
|
);
|
||||||
|
|
|
@ -137,7 +137,11 @@ export async function createEditor(container: HTMLElement) {
|
||||||
el.source.isEqual(event.id) || el.target.isEqual(event.id) ? editor.removeConnection(el.id) : null
|
el.source.isEqual(event.id) || el.target.isEqual(event.id) ? editor.removeConnection(el.id) : null
|
||||||
);
|
);
|
||||||
areaContainer.removeNodeView(event.id);
|
areaContainer.removeNodeView(event.id);
|
||||||
|
|
||||||
|
editor.removeNode(event.id)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AreaExtensions.selectableNodes(areaContainer, AreaExtensions.selector(), {
|
AreaExtensions.selectableNodes(areaContainer, AreaExtensions.selector(), {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import React, { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { FormBuilderStore } from "./form_builder_store";
|
import { Modal, message } from "antd";
|
||||||
|
import { FormsFormBuilderStore } from "./form_builder_store";
|
||||||
import { IPropsForm } from "../forms";
|
import { IPropsForm } from "../forms";
|
||||||
import { useStore } from "../../../../../../core/helper/use_store";
|
import { useStore } from "../../../../../../core/helper/use_store";
|
||||||
import { isBtScreen } from "../../../behavior_tree_builder_screen";
|
import { isBtScreen } from "../../../behavior_tree_builder_screen";
|
||||||
import { CoreInput } from "../../../../../../core/ui/input/input";
|
import { CoreInput } from "../../../../../../core/ui/input/input";
|
||||||
import { CoreButton } from "../../../../../../core/ui/button/button";
|
import { CoreButton } from "../../../../../../core/ui/button/button";
|
||||||
import { Modal, message } from "antd";
|
|
||||||
import { FormBuilder } from "../../../../../../core/ui/form_builder/form_builder";
|
import { FormBuilder } from "../../../../../../core/ui/form_builder/form_builder";
|
||||||
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
||||||
|
|
||||||
export const FormBuilderForm = observer((props: IPropsForm<Partial<FormBuilderValidationModel>>) => {
|
export const FormBuilderForm = observer((props: IPropsForm<Partial<FormBuilderValidationModel>>) => {
|
||||||
const store = useStore(FormBuilderStore);
|
const store = useStore(FormsFormBuilderStore);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
store.initParam(isBtScreen(), props.store);
|
store.initParam(isBtScreen(), props.store);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -3,11 +3,8 @@ import { NavigateFunction } from "react-router-dom";
|
||||||
import { FormState, CoreError } from "../../../../../../core/store/base_store";
|
import { FormState, CoreError } from "../../../../../../core/store/base_store";
|
||||||
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
||||||
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
import { FormBuilderValidationModel } from "../../../../../../core/model/form_builder_validation_model";
|
||||||
|
|
||||||
export class FormBuilderStore extends FormState<FormBuilderValidationModel, CoreError> {
|
export class FormsFormBuilderStore extends FormState<FormBuilderValidationModel, CoreError> {
|
||||||
openModal() {
|
|
||||||
this.isModalOpen = true;
|
|
||||||
}
|
|
||||||
isBtScreen = false;
|
isBtScreen = false;
|
||||||
isModalOpen = false;
|
isModalOpen = false;
|
||||||
viewModel: FormBuilderValidationModel = FormBuilderValidationModel.empty();
|
viewModel: FormBuilderValidationModel = FormBuilderValidationModel.empty();
|
||||||
|
@ -18,6 +15,9 @@ export class FormBuilderStore extends FormState<FormBuilderValidationModel, Core
|
||||||
errorHandingStrategy = (error: CoreError) => {};
|
errorHandingStrategy = (error: CoreError) => {};
|
||||||
init = async (navigate?: NavigateFunction | undefined) => {};
|
init = async (navigate?: NavigateFunction | undefined) => {};
|
||||||
initParam = (isSkillScreen: boolean, store: BehaviorTreeBuilderStore | undefined) => {
|
initParam = (isSkillScreen: boolean, store: BehaviorTreeBuilderStore | undefined) => {
|
||||||
this.isBtScreen = true;
|
this.isBtScreen = isSkillScreen;
|
||||||
};
|
};
|
||||||
|
openModal() {
|
||||||
|
this.isModalOpen = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { FormType } from "../../../../../core/model/form";
|
||||||
import { FormBuilderValidationModel } from "../../../../../core/model/form_builder_validation_model";
|
import { FormBuilderValidationModel } from "../../../../../core/model/form_builder_validation_model";
|
||||||
import { DependencyViewModel } from "../../../../../core/model/skill_model";
|
import { DependencyViewModel } from "../../../../../core/model/skill_model";
|
||||||
import { BehaviorTreeBuilderStore } from "../../behavior_tree_builder_store";
|
import { BehaviorTreeBuilderStore } from "../../behavior_tree_builder_store";
|
||||||
|
@ -15,27 +16,20 @@ export interface IForms {
|
||||||
name: string;
|
name: string;
|
||||||
component: JSX.Element;
|
component: JSX.Element;
|
||||||
}
|
}
|
||||||
export enum Form {
|
|
||||||
weights = "weights",
|
|
||||||
robotName = "robot_name",
|
|
||||||
cameraDeviceForm = "camera",
|
|
||||||
topic = "topic",
|
|
||||||
formBuilder = "formBuilder",
|
|
||||||
moveToPose = "move_to_pose",
|
|
||||||
}
|
|
||||||
export interface BtDependencyFormBuilder {
|
export interface BtDependencyFormBuilder {
|
||||||
form: Form;
|
form: FormType;
|
||||||
component?: React.ReactNode;
|
component?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const btDependencyFormBuilder = (onChange: (dependency: DependencyViewModel) => void) => [
|
export const btDependencyFormBuilder = (onChange: (dependency: DependencyViewModel) => void) => [
|
||||||
{ form: Form.weights, component: null },
|
{ form: FormType.weights, component: null },
|
||||||
{
|
{
|
||||||
form: Form.topic,
|
form: FormType.topic,
|
||||||
component: <TopicsForm store={undefined} dependency={TopicDependencyViewModel.empty()} onChange={onChange} />,
|
component: <TopicsForm store={undefined} dependency={TopicDependencyViewModel.empty()} onChange={onChange} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
form: Form.formBuilder,
|
form: FormType.formBuilder,
|
||||||
component: (
|
component: (
|
||||||
<FormBuilderForm store={undefined} dependency={FormBuilderValidationModel.empty()} onChange={onChange} />
|
<FormBuilderForm store={undefined} dependency={FormBuilderValidationModel.empty()} onChange={onChange} />
|
||||||
),
|
),
|
||||||
|
@ -46,6 +40,6 @@ export const forms = (
|
||||||
onChange: (dependency: DependencyViewModel) => void,
|
onChange: (dependency: DependencyViewModel) => void,
|
||||||
store: BehaviorTreeBuilderStore
|
store: BehaviorTreeBuilderStore
|
||||||
): IForms[] => [
|
): IForms[] => [
|
||||||
{ name: Form.topic, component: <TopicsForm store={store} dependency={props} onChange={onChange} /> },
|
{ name: FormType.topic, component: <TopicsForm store={store} dependency={props} onChange={onChange} /> },
|
||||||
{ name: Form.formBuilder, component: <FormBuilderForm store={store} dependency={props} onChange={onChange} /> },
|
{ name: FormType.formBuilder, component: <FormBuilderForm store={store} dependency={props} onChange={onChange} /> },
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,19 +5,20 @@ import { StoreTopicType } from "./topics_form_store";
|
||||||
import { DependencyViewModel } from "../../../../../../core/model/skill_model";
|
import { DependencyViewModel } from "../../../../../../core/model/skill_model";
|
||||||
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
import { BehaviorTreeBuilderStore } from "../../../behavior_tree_builder_store";
|
||||||
import { CoreText, CoreTextType } from "../../../../../../core/ui/text/text";
|
import { CoreText, CoreTextType } from "../../../../../../core/ui/text/text";
|
||||||
|
import { FormType } from "../../../../../../core/model/form";
|
||||||
|
|
||||||
export class TopicDependencyViewModel extends ValidationModel implements DependencyViewModel {
|
export class TopicDependencyViewModel extends ValidationModel implements DependencyViewModel {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
type: string;
|
type = FormType.topic;
|
||||||
|
topicType?: string;
|
||||||
|
|
||||||
mode?: StoreTopicType;
|
mode?: StoreTopicType;
|
||||||
sid?: string;
|
sid?: string;
|
||||||
topicOut?: string;
|
topicOut?: string;
|
||||||
constructor(type: string, mode: StoreTopicType) {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
this.type = type;
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
}
|
||||||
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => {
|
toView = (store: BehaviorTreeBuilderStore | undefined): React.ReactNode => {
|
||||||
if (store && this.sid) {
|
if (store && this.sid) {
|
||||||
|
@ -31,6 +32,6 @@ export class TopicDependencyViewModel extends ValidationModel implements Depende
|
||||||
};
|
};
|
||||||
|
|
||||||
static empty() {
|
static empty() {
|
||||||
return new TopicDependencyViewModel("", StoreTopicType.specifiesDependencies);
|
return new TopicDependencyViewModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ export const TopicsForm = observer((props: IPropsForm<Partial<TopicDependencyVie
|
||||||
style={{ padding: 10 }}
|
style={{ padding: 10 }}
|
||||||
color={themeStore.theme.darkOnSurfaceVariant}
|
color={themeStore.theme.darkOnSurfaceVariant}
|
||||||
/>
|
/>
|
||||||
{match(store.type)
|
{match(isBtScreen())
|
||||||
.with(StoreTopicType.btExecute, () => (
|
.with(true, () => (
|
||||||
<>
|
<>
|
||||||
<CoreText
|
<CoreText
|
||||||
text={"Выберите топик"}
|
text={"Выберите топик"}
|
||||||
|
@ -75,9 +75,9 @@ export const TopicsForm = observer((props: IPropsForm<Partial<TopicDependencyVie
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
))
|
))
|
||||||
.with(StoreTopicType.specifiesDependencies, () => (
|
.with(false, () => (
|
||||||
<>
|
<>
|
||||||
<CoreInput label={"Тип топика"} onChange={(text) => store.updateForm({ type: text })} />
|
<CoreInput label={"Тип топика"} onChange={(text) => store.updateForm({ topicType: text })} />
|
||||||
<div style={{ height: 10 }} />
|
<div style={{ height: 10 }} />
|
||||||
<CoreButton
|
<CoreButton
|
||||||
text="OK"
|
text="OK"
|
||||||
|
|
|
@ -24,7 +24,8 @@ export class TopicsFormStore extends FormState<TopicDependencyViewModel, CoreErr
|
||||||
init = async (navigate?: NavigateFunction | undefined) => {
|
init = async (navigate?: NavigateFunction | undefined) => {
|
||||||
// await this.mapOk('topics', this.cameraDeviceHttpRepository.getAllTopics())
|
// await this.mapOk('topics', this.cameraDeviceHttpRepository.getAllTopics())
|
||||||
};
|
};
|
||||||
getAllTopicsMatched = () => this.topics?.filter((el) => el.type.isEqual(this.viewModel.type));
|
getAllTopicsMatched = () => this.topics?.filter((el) => el.type.isEqual(this.viewModel.topicType ?? ""));
|
||||||
|
|
||||||
initParam = (isBtScreen: boolean, behaviorTreeBuilderStore: BehaviorTreeBuilderStore | undefined) => {
|
initParam = (isBtScreen: boolean, behaviorTreeBuilderStore: BehaviorTreeBuilderStore | undefined) => {
|
||||||
isBtScreen ? (this.type = StoreTopicType.btExecute) : (this.type = StoreTopicType.specifiesDependencies);
|
isBtScreen ? (this.type = StoreTopicType.btExecute) : (this.type = StoreTopicType.specifiesDependencies);
|
||||||
this.behaviorTreeBuilderStore = behaviorTreeBuilderStore;
|
this.behaviorTreeBuilderStore = behaviorTreeBuilderStore;
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { UiDrawerFormState } from "../../core/store/base_store";
|
||||||
import { NavigateFunction } from "react-router-dom";
|
import { NavigateFunction } from "react-router-dom";
|
||||||
import { HttpError } from "../../core/repository/core_http_repository";
|
import { HttpError } from "../../core/repository/core_http_repository";
|
||||||
import { DependencyViewModel, ParamViewModel, SkillModel } from "../../core/model/skill_model";
|
import { DependencyViewModel, ParamViewModel, SkillModel } from "../../core/model/skill_model";
|
||||||
import { Form } from "../behavior_tree_builder/presentation/ui/forms/forms";
|
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { SkillsHttpRepository } from "./skills_http_repository";
|
import { SkillsHttpRepository } from "./skills_http_repository";
|
||||||
|
import { FormType } from "../../core/model/form";
|
||||||
|
|
||||||
export enum DrawersSkills {
|
export enum DrawersSkills {
|
||||||
newSkill = "Новый навык",
|
newSkill = "Новый навык",
|
||||||
}
|
}
|
||||||
|
@ -14,7 +15,7 @@ export class SkillsStore extends UiDrawerFormState<SkillModel, HttpError> {
|
||||||
activeIndex?: number;
|
activeIndex?: number;
|
||||||
viewModel: SkillModel = SkillModel.empty();
|
viewModel: SkillModel = SkillModel.empty();
|
||||||
selectParam?: {
|
selectParam?: {
|
||||||
form: Form;
|
form: FormType;
|
||||||
component?: React.ReactNode;
|
component?: React.ReactNode;
|
||||||
};
|
};
|
||||||
skills: SkillModel[];
|
skills: SkillModel[];
|
||||||
|
@ -66,7 +67,7 @@ export class SkillsStore extends UiDrawerFormState<SkillModel, HttpError> {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
clickParam(el: { form: Form; component: null } | { form: Form; component: React.JSX.Element }): void {
|
clickParam(el: { form: FormType; component: null } | { form: FormType; component: React.JSX.Element }): void {
|
||||||
this.selectParam = el;
|
this.selectParam = el;
|
||||||
if (el.component === null) this.onChangeBtDependency(DependencyViewModel.empty());
|
if (el.component === null) this.onChangeBtDependency(DependencyViewModel.empty());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue