Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 19, 2021
1 parent 7bc4bd6 commit 4ba085a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
16 changes: 14 additions & 2 deletions packages/project-editor/core/objectAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1616,10 +1616,22 @@ export class ListAdapter implements ITreeAdapter {

const DocumentStore = getDocumentStore(this.object);

let aNewObject: IEezObject | undefined;

if (dropPosition == DropPosition.DROP_POSITION_BEFORE) {
DocumentStore.insertObjectBefore(dropItem.object, object);
aNewObject = DocumentStore.insertObjectBefore(
dropItem.object,
object
);
} else if (dropPosition == DropPosition.DROP_POSITION_AFTER) {
DocumentStore.insertObjectAfter(dropItem.object, object);
aNewObject = DocumentStore.insertObjectAfter(
dropItem.object,
object
);
}

if (aNewObject) {
this.selectObject(aNewObject);
}
}

Expand Down
26 changes: 26 additions & 0 deletions packages/project-editor/features/variable/variable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,19 @@ export class StructureField extends EezObject {
},
variableTypeProperty
],
check: (structureField: StructureField) => {
let messages: Message[] = [];

if (!structureField.name) {
messages.push(propertyNotSetMessage(structureField, "name"));
}

if (!structureField.type) {
messages.push(propertyNotSetMessage(structureField, "type"));
}

return messages;
},
beforeLoadHook: (object: Variable, objectJS: any) => {
migrateType(objectJS);
},
Expand Down Expand Up @@ -1040,6 +1053,19 @@ export class EnumMember extends EezObject {
type: PropertyType.Number
}
],
check: (enumMember: EnumMember) => {
let messages: Message[] = [];

if (!enumMember.name) {
messages.push(propertyNotSetMessage(enumMember, "name"));
}

if (enumMember.value == undefined) {
messages.push(propertyNotSetMessage(enumMember, "value"));
}

return messages;
},
defaultValue: {},
newItem: (parent: IEezObject) => {
return showGenericDialog({
Expand Down
11 changes: 7 additions & 4 deletions packages/project-editor/project/PropertiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ export class PropertiesPanel extends React.Component<{

render() {
let title;
if (this.objects.length == 0) {

const objects = this.objects.filter(object => object != undefined);

if (objects.length == 0) {
title = "Properties";
} else if (this.objects.length == 1) {
let object = this.objects[0];
} else if (objects.length == 1) {
let object = objects[0];
if (object instanceof EezValueObject) {
object = getParent(object);
}
Expand All @@ -86,7 +89,7 @@ export class PropertiesPanel extends React.Component<{
title={title}
body={
<PropertyGrid
objects={this.objects}
objects={objects}
readOnly={this.props.readOnly}
/>
}
Expand Down

0 comments on commit 4ba085a

Please sign in to comment.