File: D:/HostingSpaces/SBogers10/shop.komma.nl/resources/js/components/vue/properties/resources/value.js
import BaseResource from "./baseResource";
import KeyValueTranslation from "./translation";
export default class Value extends BaseResource {
get id() {
return this._id;
}
set id(value) {
this._id = typeof value === 'number' ? value : BaseResource.newId();
}
get property_id() {
return this._id;
}
set property_id(value) {
this._id = typeof value === 'number' ? value : BaseResource.newId();
}
get translations() {
if(!Array.isArray(this._translations)) {
this._translations = [];
return;
}
return this._translations;
}
set translations(values) {
if(!Array.isArray(values)) {
this._translations = [];
return;
}
this._translations = values.map((value) => {
if(value instanceof KeyValueTranslation) return value;
return new KeyValueTranslation(value);
})
}
get names() {
return this.translations.map(
/** @param {KeyValueTranslation} translation */
(translation) => translation.name
).join(' / ')
}
}