mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
49 lines
1.3 KiB
JavaScript
Executable File
49 lines
1.3 KiB
JavaScript
Executable File
import Configuration from "../Configuration.js"
|
|
import Utility from "../Utility.js"
|
|
import IEntity from "./IEntity.js"
|
|
|
|
export default class ObjectReferenceEntity extends IEntity {
|
|
|
|
static attributes = {
|
|
type: {
|
|
default: "",
|
|
},
|
|
path: {
|
|
default: "",
|
|
},
|
|
}
|
|
|
|
static {
|
|
this.cleanupAttributes(this.attributes)
|
|
}
|
|
|
|
constructor(values = {}) {
|
|
if (values.constructor === String) {
|
|
values = {
|
|
path: values
|
|
}
|
|
}
|
|
super(values)
|
|
/** @type {String} */ this.type
|
|
/** @type {String} */ this.path
|
|
}
|
|
|
|
sanitize() {
|
|
if (this.type && !this.type.startsWith("/")) {
|
|
let deprecatedType = this.type + "_Deprecated"
|
|
let nodeType = Object.keys(Configuration.nodeType)
|
|
.find(type => {
|
|
const name = Utility.getNameFromPath(Configuration.nodeType[type])
|
|
return name === this.type || name === deprecatedType
|
|
})
|
|
if (nodeType) {
|
|
this.type = Configuration.nodeType[nodeType]
|
|
}
|
|
}
|
|
}
|
|
|
|
getName() {
|
|
return Utility.getNameFromPath(this.path)
|
|
}
|
|
}
|