HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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(' / ')
    }
}