sync
This commit is contained in:
parent
25e57c1a56
commit
3b8d9e4298
41 changed files with 1571 additions and 543 deletions
|
@ -37,7 +37,7 @@ export interface IDeviceDependency {
|
|||
|
||||
export interface IParam {
|
||||
type: string;
|
||||
dependency: Object;
|
||||
dependency?: Object;
|
||||
}
|
||||
export class ParamViewModel implements IParam {
|
||||
type: string;
|
||||
|
@ -190,6 +190,9 @@ export class SkillModel extends ValidationModel implements ISkill {
|
|||
super();
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
bgColor: string = `rgba(5, 26, 39, 1)`;
|
||||
borderColor: string = "rgba(25, 130, 196, 1)";
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sid?: string;
|
||||
|
@ -239,13 +242,18 @@ export class Skills {
|
|||
@IsArray()
|
||||
@Type(() => SkillModel)
|
||||
skills: SkillModel[];
|
||||
static fromSkills = (skilsModel: SkillModel[]) => {
|
||||
const skills = this.empty();
|
||||
skills.skills = skilsModel;
|
||||
return skills;
|
||||
};
|
||||
validation = (): Result<string[], void> => {
|
||||
const errors: string[] = [];
|
||||
this.skills.forEach((skill) => {
|
||||
skill.BTAction.forEach((action) => {
|
||||
if (action.param.isNotEmpty()) {
|
||||
action.param.forEach((param) => {
|
||||
if (Object.keys(param.dependency).isEmpty()) {
|
||||
if (Object.keys(param?.dependency ?? {}).isEmpty()) {
|
||||
errors.push(param.type);
|
||||
}
|
||||
});
|
||||
|
@ -257,6 +265,16 @@ export class Skills {
|
|||
}
|
||||
return Result.ok(undefined);
|
||||
};
|
||||
getCssAtLabel = (label: string): React.CSSProperties =>
|
||||
this.skills.reduce<React.CSSProperties>((acc, el) => {
|
||||
el.BTAction.rFind<BtActionViewModel>((el) => el.name.isEqual(label)).map(() => {
|
||||
acc = {
|
||||
backgroundColor: el.bgColor,
|
||||
border: `1px solid ${el.borderColor}`,
|
||||
};
|
||||
});
|
||||
return acc;
|
||||
}, {});
|
||||
skillBySid = (sid: string) =>
|
||||
SkillModel.isEmpty(
|
||||
this.skills.reduce<SkillModel>((acc, el) => {
|
||||
|
@ -270,7 +288,7 @@ export class Skills {
|
|||
toSkillView = (): ISkillView[] =>
|
||||
this.skills.map((el) => {
|
||||
return {
|
||||
name: el.Module.name,
|
||||
name: el.SkillPackage.name,
|
||||
children: el.BTAction.map((act) => {
|
||||
return { name: act.name, uuid: v4() };
|
||||
}),
|
||||
|
@ -346,7 +364,7 @@ export class Skills {
|
|||
skill.BTAction.map((action) => {
|
||||
action.param.map((param) => {
|
||||
if (param.type.isEqualR(skillType)) {
|
||||
acc.push(param.dependency);
|
||||
acc.push(param?.dependency ?? {});
|
||||
}
|
||||
return param;
|
||||
});
|
||||
|
@ -375,7 +393,7 @@ export class Skills {
|
|||
skill.BTAction.forEach((action) => {
|
||||
action.param.forEach((param) => {
|
||||
if (param.type.isEqual(skillType)) {
|
||||
acc = Object.keys(param.dependency).isNotEmpty();
|
||||
acc = Object.keys(param?.dependency ?? {}).isNotEmpty();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -399,7 +417,6 @@ export class Skills {
|
|||
return this.skills.filter((skill) => !skill.sid?.isEqual(sid));
|
||||
}
|
||||
updateSkill = (skill: SkillModel) => {
|
||||
console.log(skill);
|
||||
this.skills = this.skills.map((el) => {
|
||||
if (el.sid?.isEqual(skill.sid ?? "")) {
|
||||
el = skill;
|
||||
|
@ -408,7 +425,13 @@ export class Skills {
|
|||
});
|
||||
};
|
||||
skillHasForm = (label: string): boolean => {
|
||||
// TODO:NEED IMPLEMENTS
|
||||
return true;
|
||||
};
|
||||
getSkillWidthAtLabel = (label: string): number =>
|
||||
this.getSkillParams(label).reduce((acc, element) => {
|
||||
if (element.type.length > acc) {
|
||||
acc = element.type.length;
|
||||
}
|
||||
return acc;
|
||||
}, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue