mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
57 lines
1.4 KiB
JavaScript
Executable File
57 lines
1.4 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
|
|
}
|
|
|
|
static createNoneInstance() {
|
|
return new ObjectReferenceEntity({ type: "None", path: "" })
|
|
}
|
|
|
|
sanitize() {
|
|
if (this.type && !this.type.startsWith("/")) {
|
|
let deprecatedType = this.type + "_Deprecated"
|
|
let path = Object.keys(Configuration.paths)
|
|
.find(type => {
|
|
const name = Utility.getNameFromPath(Configuration.paths[type])
|
|
return name === this.type || name === deprecatedType
|
|
})
|
|
if (path) {
|
|
this.type = Configuration.paths[path]
|
|
}
|
|
}
|
|
}
|
|
|
|
getName() {
|
|
return Utility.getNameFromPath(this.path)
|
|
}
|
|
|
|
toString() {
|
|
return `${this.type}'"${this.path}"'`
|
|
}
|
|
}
|