Various fixes

This commit is contained in:
barsdeveloper
2022-03-19 14:46:53 +01:00
parent 391a537a78
commit 42615b93f8
25 changed files with 267 additions and 131 deletions

View File

@@ -5,9 +5,6 @@ export default class FunctionReferenceEntity extends IEntity {
static attributes = {
MemberParent: ObjectReferenceEntity,
MemberName: ""
MemberName: "",
}
/** @type {ObjectReferenceEntity} */ MemberParent
/** @type {String} */ MemberName
}

View File

@@ -4,7 +4,7 @@ import IEntity from "./IEntity"
export default class GuidEntity extends IEntity {
static attributes = {
value: String
value: String,
}
static generateGuid(random = true) {
@@ -19,6 +19,10 @@ export default class GuidEntity extends IEntity {
return new GuidEntity({ value: guid })
}
valueOf() {
return this.value
}
toString() {
return this.value
}

View File

@@ -12,7 +12,7 @@ export default class IEntity {
const defineAllAttributes = (prefix, target, properties) => {
let fullKey = prefix.concat("")
const last = fullKey.length - 1
for (let property in properties) {
for (let property of Object.getOwnPropertyNames(properties)) {
fullKey[last] = property
// Not instanceof because all objects are instenceof Object, exact match needed
if (properties[property]?.constructor === Object) {
@@ -22,7 +22,7 @@ export default class IEntity {
}
/*
* The value can either be:
* - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World")
* - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World").
* - TypeInitialization: contains the maximum amount of information about the attribute.
* - A type: the default value will be default constructed object without arguments.
* - A proper value.
@@ -35,6 +35,7 @@ export default class IEntity {
let defaultValue = properties[property]
if (defaultValue instanceof TypeInitialization) {
if (!defaultValue.showDefault) {
target[property] = undefined // to preserve the order
continue
}
defaultValue = defaultValue.value

View File

@@ -3,13 +3,13 @@ import IEntity from "./IEntity"
export default class IntegerEntity extends IEntity {
static attributes = {
value: Number
value: Number,
}
constructor(options = {}) {
if (options.constructor === Number || options.constructor === String) {
if (options.constructor == Number || options.constructor == String) {
options = {
value: options
value: options,
}
}
super(options)

View File

@@ -6,6 +6,6 @@ export default class LocalizedTextEntity extends IEntity {
static attributes = {
namespace: String,
key: String,
value: String
value: String,
}
}

View File

@@ -22,11 +22,11 @@ export default class ObjectEntity extends IEntity {
NodeGuid: GuidEntity,
ErrorType: new TypeInitialization(IntegerEntity, false),
ErrorMsg: new TypeInitialization(String, false, ""),
CustomProperties: [PinEntity]
CustomProperties: [PinEntity],
}
/**
* @returns {String} The name of the node
* @returns {String}
*/
getName() {
return this.Name

View File

@@ -4,6 +4,6 @@ export default class ObjectReferenceEntity extends IEntity {
static attributes = {
type: String,
path: String
path: String,
}
}

View File

@@ -3,7 +3,7 @@ import IEntity from "./IEntity"
export default class PathSymbolEntity extends IEntity {
static attributes = {
value: String
value: String,
}
toString() {

View File

@@ -71,13 +71,13 @@ export default class PinEntity extends IEntity {
linkTo(targetObjectName, targetPinEntity) {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const linkExists = this.LinkedTo.find(
const linkFound = this.LinkedTo.find(
/** @type {PinReferenceEntity} */
pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid == targetPinEntity.PinId
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
if (!linkExists) {
if (!linkFound) {
this.LinkedTo.push(new PinReferenceEntity({
objectName: targetObjectName,
pinGuid: targetPinEntity.PinId

View File

@@ -6,6 +6,6 @@ export default class PinReferenceEntity extends IEntity {
static attributes = {
objectName: PathSymbolEntity,
pinGuid: GuidEntity
pinGuid: GuidEntity,
}
}

View File

@@ -6,6 +6,6 @@ export default class VariableReferenceEntity extends IEntity {
static attributes = {
MemberName: String,
MemberGuid: GuidEntity,
bSelfContext: false
bSelfContext: false,
}
}