Alexander changes
This commit is contained in:
parent
d47d555061
commit
314e070bee
6 changed files with 74 additions and 34 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
import { Launch } from "../../../core/models/skill_model";
|
||||
|
||||
export interface ISkillsModel {}
|
||||
|
||||
|
@ -10,6 +9,9 @@ export const SkillsSchema = new Schema({
|
|||
Module: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
Settings:{
|
||||
type:Schema.Types.Mixed,
|
||||
},
|
||||
BTAction: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
|
|
|
@ -4,7 +4,8 @@ import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from
|
|||
import { DependencyViewModel } from "./skill_model";
|
||||
import { ValidationModel } from "./validation_model";
|
||||
import { FormType } from "./form";
|
||||
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
|
||||
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
|
@ -16,6 +17,7 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
|||
public output: any;
|
||||
constructor(context: string, result: string, form: string[], output: string) {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
this.context = context;
|
||||
this.result = result;
|
||||
this.form = form;
|
||||
|
@ -28,20 +30,14 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
|||
formBuilderValidationModel.result.isEmpty() &&
|
||||
formBuilderValidationModel.form.isEmpty();
|
||||
|
||||
static datasetEmpty() {
|
||||
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||
}
|
||||
static empty() {
|
||||
return new FormBuilderValidationModel("", "", [], "");
|
||||
}
|
||||
static emptyTest() {
|
||||
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
}
|
||||
static creteDataSetTest() {
|
||||
return new FormBuilderValidationModel(``, scene, [], "");
|
||||
}
|
||||
static vision(): FormBuilderValidationModel {
|
||||
return new FormBuilderValidationModel(
|
||||
static datasetEmpty = () =>
|
||||
new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||
static empty = () => new FormBuilderValidationModel("", "", [], "");
|
||||
static emptyTest = () => new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||
static creteDataSetTest = () => new FormBuilderValidationModel(``, scene, [], "");
|
||||
static emptySimple = () => new FormBuilderValidationModel("", simpleFormBuilder, [], "");
|
||||
static vision = () =>
|
||||
new FormBuilderValidationModel(
|
||||
`ENUM PRETRAIN = "true","false";`,
|
||||
`{
|
||||
"numberOfEpochs": \${numberOfEpochs:number:10},
|
||||
|
@ -51,9 +47,11 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
|||
[],
|
||||
""
|
||||
);
|
||||
}
|
||||
}
|
||||
export const scene = `{
|
||||
"center_shell": [\${CENTER_SHELL_1:number:0}, \${CENTER_SHELL_2:number:0}, \${CENTER_SHELL_3:number:0}],
|
||||
"scene":\${<SelectScene/>:OBJECT:{"details": []}
|
||||
}`;
|
||||
export const simpleFormBuilder = `{
|
||||
"center_shell": [\${CENTER_SHELL_1:number:0}, \${CENTER_SHELL_2:number:0}, \${CENTER_SHELL_3:number:0}]
|
||||
}`;
|
||||
|
|
|
@ -248,12 +248,15 @@ export class SkillModel extends ValidationModel implements ISkill {
|
|||
topicsOut: TopicViewModel[] = [];
|
||||
@Type(() => Launch)
|
||||
Launch: Launch;
|
||||
@Type(() => FormBuilderValidationModel)
|
||||
Settings: FormBuilderValidationModel;
|
||||
static empty() {
|
||||
const skillModel = new SkillModel();
|
||||
skillModel.BTAction = [];
|
||||
skillModel.SkillPackage = SkillPackage.empty();
|
||||
skillModel.Module = Module.empty();
|
||||
skillModel.Launch = Launch.empty();
|
||||
skillModel.Settings = FormBuilderValidationModel.empty();
|
||||
return skillModel;
|
||||
}
|
||||
public static isEmpty(skill: SkillModel): Result<void, SkillModel> {
|
||||
|
|
|
@ -15,6 +15,7 @@ interface IInputProps extends IStyle {
|
|||
error?: string;
|
||||
type?: CoreInputType;
|
||||
trim?: boolean;
|
||||
styleContentEditable?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export const CoreInput = (props: IInputProps) => {
|
||||
|
@ -50,19 +51,22 @@ export const CoreInput = (props: IInputProps) => {
|
|||
<div
|
||||
ref={ref}
|
||||
contentEditable={true}
|
||||
style={{
|
||||
backgroundColor: "#00008000",
|
||||
border: 1,
|
||||
fontSize: isSmall ? 12 : 16,
|
||||
fontFamily: "Roboto",
|
||||
color: "#1D1B20",
|
||||
height: 24,
|
||||
width: "100%",
|
||||
userSelect: "none",
|
||||
outline: "none",
|
||||
position: isSmall ? "relative" : undefined,
|
||||
top: isSmall ? -8 : undefined,
|
||||
}}
|
||||
style={Object.assign(
|
||||
{
|
||||
backgroundColor: "#00008000",
|
||||
border: 1,
|
||||
fontSize: isSmall ? 12 : 16,
|
||||
fontFamily: "Roboto",
|
||||
color: "#1D1B20",
|
||||
height: 24,
|
||||
width: "100%",
|
||||
userSelect: "none",
|
||||
outline: "none",
|
||||
position: isSmall ? "relative" : undefined,
|
||||
top: isSmall ? -8 : undefined,
|
||||
},
|
||||
props.styleContentEditable
|
||||
)}
|
||||
onInput={(e) => {
|
||||
let val = e.currentTarget.innerText;
|
||||
|
||||
|
|
|
@ -9,12 +9,13 @@ import { btDependencyFormBuilder } from "../behavior_tree_builder/presentation/u
|
|||
import { CoreButton } from "../../core/ui/button/button";
|
||||
import { CoreSelect } from "../../core/ui/select/select";
|
||||
import { useStore } from "../../core/helper/use_store";
|
||||
import { FormBuilder } from "../../core/ui/form_builder/form_builder";
|
||||
import { ButtonV2 } from "../../core/ui/button/button_v2";
|
||||
|
||||
export const SkillsScreenPath = "/skills";
|
||||
|
||||
export const SkillsScreen = observer(() => {
|
||||
const store = useStore(SkillsStore);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
|
@ -125,6 +126,37 @@ export const SkillsScreen = observer(() => {
|
|||
store.updateForm({ Launch: Object.assign(store.viewModel.Launch, { executable: text }) })
|
||||
}
|
||||
/>
|
||||
<CoreInput
|
||||
label="Settings form builder result"
|
||||
style={{ height: "min-content" }}
|
||||
styleContentEditable={{ height: "min-content" }}
|
||||
onChange={(text) =>
|
||||
store.updateForm({ Settings: Object.assign(store.viewModel.Settings, { result: text }) })
|
||||
}
|
||||
/>
|
||||
<CoreInput
|
||||
label="Settings form builder context"
|
||||
style={{ height: "min-content" }}
|
||||
styleContentEditable={{ height: "min-content" }}
|
||||
onChange={(text) =>
|
||||
store.updateForm({ Settings: Object.assign(store.viewModel.Settings, { context: text }) })
|
||||
}
|
||||
/>
|
||||
<ButtonV2 text="form builder modal" onClick={() => (store.formBuilderModal = true)} />
|
||||
<Modal
|
||||
destroyOnClose={true}
|
||||
open={store.formBuilderModal}
|
||||
footer={null}
|
||||
closable={false}
|
||||
closeIcon={null}
|
||||
onCancel={store.handleFormBuilderModalCancel}
|
||||
>
|
||||
<FormBuilder
|
||||
formBuilder={store.viewModel.Settings}
|
||||
onChange={(form) => store.updateForm({ Settings: form })}
|
||||
/>
|
||||
<ButtonV2 text="save" onClick={() => store.handleFormBuilderModalCancel} />
|
||||
</Modal>
|
||||
|
||||
<CoreText
|
||||
text={`Topics ${store.viewModel.topicsOut.length}`}
|
||||
|
@ -176,7 +208,7 @@ export const SkillsScreen = observer(() => {
|
|||
store.updateForm({ BTAction: store.viewModel.BTAction.replacePropIndex({ type: text }, index) })
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
<CoreSelect
|
||||
items={Object.keys(BtAction)}
|
||||
value={el.typeAction}
|
||||
|
@ -205,6 +237,7 @@ export const SkillsScreen = observer(() => {
|
|||
<CoreButton text="Save" style={{ width: 100 }} onClick={() => store.saveNewSkill()} />
|
||||
</div>
|
||||
</Drawer>
|
||||
|
||||
<Modal
|
||||
destroyOnClose={true}
|
||||
afterClose={() => (store.selectParam = undefined)}
|
||||
|
@ -224,4 +257,3 @@ export const SkillsScreen = observer(() => {
|
|||
</>
|
||||
);
|
||||
});
|
||||
|
|
@ -20,11 +20,12 @@ export class SkillsStore extends UiDrawerFormState<SkillModel, HttpError> {
|
|||
};
|
||||
skills: SkillModel[];
|
||||
skillsHttpRepository: SkillsHttpRepository = new SkillsHttpRepository();
|
||||
|
||||
formBuilderModal: boolean = false;
|
||||
constructor() {
|
||||
super(DrawersSkills);
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
handleFormBuilderModalCancel = () => (this.formBuilderModal = false);
|
||||
init = async (navigate?: NavigateFunction | undefined) => {
|
||||
this.mapOk("skills", this.skillsHttpRepository.getAllSkills());
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue