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 { Schema, model } from "mongoose";
|
||||||
import { Launch } from "../../../core/models/skill_model";
|
|
||||||
|
|
||||||
export interface ISkillsModel {}
|
export interface ISkillsModel {}
|
||||||
|
|
||||||
|
@ -10,6 +9,9 @@ export const SkillsSchema = new Schema({
|
||||||
Module: {
|
Module: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
},
|
},
|
||||||
|
Settings:{
|
||||||
|
type:Schema.Types.Mixed,
|
||||||
|
},
|
||||||
BTAction: {
|
BTAction: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { datasetFormMockContext, datasetFormMockResult, defaultFormValue } from
|
||||||
import { DependencyViewModel } from "./skill_model";
|
import { DependencyViewModel } from "./skill_model";
|
||||||
import { ValidationModel } from "./validation_model";
|
import { ValidationModel } from "./validation_model";
|
||||||
import { FormType } from "./form";
|
import { FormType } from "./form";
|
||||||
|
import makeAutoObservable from "mobx-store-inheritance";
|
||||||
|
|
||||||
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
export class FormBuilderValidationModel extends ValidationModel implements DependencyViewModel {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
@ -16,6 +17,7 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
||||||
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();
|
||||||
|
makeAutoObservable(this);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.form = form;
|
this.form = form;
|
||||||
|
@ -28,20 +30,14 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
||||||
formBuilderValidationModel.result.isEmpty() &&
|
formBuilderValidationModel.result.isEmpty() &&
|
||||||
formBuilderValidationModel.form.isEmpty();
|
formBuilderValidationModel.form.isEmpty();
|
||||||
|
|
||||||
static datasetEmpty() {
|
static datasetEmpty = () =>
|
||||||
return new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
new FormBuilderValidationModel(datasetFormMockContext, datasetFormMockResult, [], defaultFormValue);
|
||||||
}
|
static empty = () => new FormBuilderValidationModel("", "", [], "");
|
||||||
static empty() {
|
static emptyTest = () => new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
||||||
return new FormBuilderValidationModel("", "", [], "");
|
static creteDataSetTest = () => new FormBuilderValidationModel(``, scene, [], "");
|
||||||
}
|
static emptySimple = () => new FormBuilderValidationModel("", simpleFormBuilder, [], "");
|
||||||
static emptyTest() {
|
static vision = () =>
|
||||||
return new FormBuilderValidationModel(``, ``, [], defaultFormValue);
|
new FormBuilderValidationModel(
|
||||||
}
|
|
||||||
static creteDataSetTest() {
|
|
||||||
return new FormBuilderValidationModel(``, scene, [], "");
|
|
||||||
}
|
|
||||||
static vision(): FormBuilderValidationModel {
|
|
||||||
return new FormBuilderValidationModel(
|
|
||||||
`ENUM PRETRAIN = "true","false";`,
|
`ENUM PRETRAIN = "true","false";`,
|
||||||
`{
|
`{
|
||||||
"numberOfEpochs": \${numberOfEpochs:number:10},
|
"numberOfEpochs": \${numberOfEpochs:number:10},
|
||||||
|
@ -52,8 +48,10 @@ export class FormBuilderValidationModel extends ValidationModel implements Depen
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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": []}
|
||||||
}`;
|
}`;
|
||||||
|
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[] = [];
|
topicsOut: TopicViewModel[] = [];
|
||||||
@Type(() => Launch)
|
@Type(() => Launch)
|
||||||
Launch: Launch;
|
Launch: Launch;
|
||||||
|
@Type(() => FormBuilderValidationModel)
|
||||||
|
Settings: FormBuilderValidationModel;
|
||||||
static empty() {
|
static empty() {
|
||||||
const skillModel = new SkillModel();
|
const skillModel = new SkillModel();
|
||||||
skillModel.BTAction = [];
|
skillModel.BTAction = [];
|
||||||
skillModel.SkillPackage = SkillPackage.empty();
|
skillModel.SkillPackage = SkillPackage.empty();
|
||||||
skillModel.Module = Module.empty();
|
skillModel.Module = Module.empty();
|
||||||
skillModel.Launch = Launch.empty();
|
skillModel.Launch = Launch.empty();
|
||||||
|
skillModel.Settings = FormBuilderValidationModel.empty();
|
||||||
return skillModel;
|
return skillModel;
|
||||||
}
|
}
|
||||||
public static isEmpty(skill: SkillModel): Result<void, SkillModel> {
|
public static isEmpty(skill: SkillModel): Result<void, SkillModel> {
|
||||||
|
|
|
@ -15,6 +15,7 @@ interface IInputProps extends IStyle {
|
||||||
error?: string;
|
error?: string;
|
||||||
type?: CoreInputType;
|
type?: CoreInputType;
|
||||||
trim?: boolean;
|
trim?: boolean;
|
||||||
|
styleContentEditable?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CoreInput = (props: IInputProps) => {
|
export const CoreInput = (props: IInputProps) => {
|
||||||
|
@ -50,7 +51,8 @@ export const CoreInput = (props: IInputProps) => {
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
contentEditable={true}
|
contentEditable={true}
|
||||||
style={{
|
style={Object.assign(
|
||||||
|
{
|
||||||
backgroundColor: "#00008000",
|
backgroundColor: "#00008000",
|
||||||
border: 1,
|
border: 1,
|
||||||
fontSize: isSmall ? 12 : 16,
|
fontSize: isSmall ? 12 : 16,
|
||||||
|
@ -62,7 +64,9 @@ export const CoreInput = (props: IInputProps) => {
|
||||||
outline: "none",
|
outline: "none",
|
||||||
position: isSmall ? "relative" : undefined,
|
position: isSmall ? "relative" : undefined,
|
||||||
top: isSmall ? -8 : undefined,
|
top: isSmall ? -8 : undefined,
|
||||||
}}
|
},
|
||||||
|
props.styleContentEditable
|
||||||
|
)}
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
let val = e.currentTarget.innerText;
|
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 { CoreButton } from "../../core/ui/button/button";
|
||||||
import { CoreSelect } from "../../core/ui/select/select";
|
import { CoreSelect } from "../../core/ui/select/select";
|
||||||
import { useStore } from "../../core/helper/use_store";
|
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 SkillsScreenPath = "/skills";
|
||||||
|
|
||||||
export const SkillsScreen = observer(() => {
|
export const SkillsScreen = observer(() => {
|
||||||
const store = useStore(SkillsStore);
|
const store = useStore(SkillsStore);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
|
@ -125,6 +126,37 @@ export const SkillsScreen = observer(() => {
|
||||||
store.updateForm({ Launch: Object.assign(store.viewModel.Launch, { executable: text }) })
|
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
|
<CoreText
|
||||||
text={`Topics ${store.viewModel.topicsOut.length}`}
|
text={`Topics ${store.viewModel.topicsOut.length}`}
|
||||||
|
@ -205,6 +237,7 @@ export const SkillsScreen = observer(() => {
|
||||||
<CoreButton text="Save" style={{ width: 100 }} onClick={() => store.saveNewSkill()} />
|
<CoreButton text="Save" style={{ width: 100 }} onClick={() => store.saveNewSkill()} />
|
||||||
</div>
|
</div>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
destroyOnClose={true}
|
destroyOnClose={true}
|
||||||
afterClose={() => (store.selectParam = undefined)}
|
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[];
|
skills: SkillModel[];
|
||||||
skillsHttpRepository: SkillsHttpRepository = new SkillsHttpRepository();
|
skillsHttpRepository: SkillsHttpRepository = new SkillsHttpRepository();
|
||||||
|
formBuilderModal: boolean = false;
|
||||||
constructor() {
|
constructor() {
|
||||||
super(DrawersSkills);
|
super(DrawersSkills);
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
handleFormBuilderModalCancel = () => (this.formBuilderModal = false);
|
||||||
init = async (navigate?: NavigateFunction | undefined) => {
|
init = async (navigate?: NavigateFunction | undefined) => {
|
||||||
this.mapOk("skills", this.skillsHttpRepository.getAllSkills());
|
this.mapOk("skills", this.skillsHttpRepository.getAllSkills());
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue