Refactoring, various fixes

This commit is contained in:
barsdeveloper
2022-03-24 22:54:41 +01:00
parent 4dd2929a9f
commit 8a4e60c9ae
43 changed files with 937 additions and 589 deletions

View File

@@ -28,7 +28,7 @@ export default class IEntity {
* - A proper value.
*/
const value = Utility.objectGet(options, fullKey)
if (value !== null) {
if (value !== undefined) {
target[property] = value
continue
}

View File

@@ -1,7 +1,7 @@
import IEntity from "./IEntity"
export default class Identifier extends IEntity {
export default class IdentifierEntity extends IEntity {
static attributes = {
value: String,
@@ -15,11 +15,6 @@ export default class Identifier extends IEntity {
}
}
super(options)
/** @type {String} */
this.value
if (!this.value.match(/\w+/)) {
throw new Error("The value must be an identifier (/\w+/).")
}
}
valueOf() {

View File

@@ -1,12 +1,17 @@
import IdentifierEntity from "./IdentifierEntity"
import IEntity from "./IEntity"
export default class KeyBindingEntity extends IEntity {
static attributes = {
bCtrlDown: false,
bAltDown: false,
bShiftDown: false,
Key: String,
CommandName: String,
ActionName: "",
bShift: false,
bCtrl: false,
bAlt: false,
bCmd: false,
Key: IdentifierEntity,
}
constructor(options = {}) {
super(options)
}
}

View File

@@ -1,6 +1,6 @@
import FunctionReferenceEntity from "./FunctionReferenceEntity"
import GuidEntity from "./GuidEntity"
import Identifier from "./Identifier"
import IdentifierEntity from "./IdentifierEntity"
import IEntity from "./IEntity"
import IntegerEntity from "./IntegerEntity"
import ObjectReferenceEntity from "./ObjectReferenceEntity"
@@ -20,7 +20,7 @@ export default class ObjectEntity extends IEntity {
TargetType: new TypeInitialization(ObjectReferenceEntity, false, null),
NodePosX: IntegerEntity,
NodePosY: IntegerEntity,
AdvancedPinDisplay: new TypeInitialization(Identifier, false, null),
AdvancedPinDisplay: new TypeInitialization(IdentifierEntity, false, null),
NodeGuid: GuidEntity,
ErrorType: new TypeInitialization(IntegerEntity, false),
ErrorMsg: new TypeInitialization(String, false, ""),

View File

@@ -72,16 +72,14 @@ export default class PinEntity extends IEntity {
linkTo(targetObjectName, targetPinEntity) {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const linkFound = this.LinkedTo.find(
/** @type {PinReferenceEntity} */
pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
const linkFound = this.LinkedTo?.find(pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
if (!linkFound) {
this.LinkedTo.push(new PinReferenceEntity({
(this.LinkedTo ?? (this.LinkedTo = [])).push(new PinReferenceEntity({
objectName: targetObjectName,
pinGuid: targetPinEntity.PinId
pinGuid: targetPinEntity.PinId,
}))
return true
}
@@ -95,14 +93,16 @@ export default class PinEntity extends IEntity {
unlinkFrom(targetObjectName, targetPinEntity) {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const indexElement = this.LinkedTo.findIndex(
/** @type {PinReferenceEntity} */
pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid == targetPinEntity.PinId
})
const indexElement = this.LinkedTo.findIndex(pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid == targetPinEntity.PinId
})
if (indexElement >= 0) {
this.LinkedTo.splice(indexElement, 1)
if (this.LinkedTo.length == 1) {
this.LinkedTo = undefined
} else {
this.LinkedTo.splice(indexElement, 1)
}
return true
}
return false