JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Source: entity/js/api/PropertyType.js

define([], function () {

    'use strict';

    /**
     * Defines types of entity properties.
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @exports entity/js/api/PropertyType
     *
     * @constructor
     * @private
     *
     * @see {@link entity/js/api/Property Property}
     */
    var PropertyType = function() {
        AbcsLib.throwStaticClassError();
    };

    /**
     * Primary key
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.KEY = 'KEY';

    /**
     * Reference
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.REFERENCE = 'REFERENCE';

    /**
     * Boolean
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.BOOLEAN = 'BOOLEAN';

    /**
     * Number
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.NUMBER = 'NUMBER';

    /**
     * Currency, special subtype of {@link module:entity/js/api/PropertyType.NUMBER PropertyType.Number}
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.CURRENCY = 'CURRENCY';

    /**
     * Percentage, special subtype of {@link module:entity/js/api/PropertyType.NUMBER PropertyType.Number}
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.PERCENTAGE = 'PERCENTAGE';

    /**
     * Text
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.TEXT = 'TEXT';

    /**
     * Email, special subtype of {@link module:entity/js/api/PropertyType.TEXT PropertyType.Text}
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.EMAIL = 'EMAIL';

    /**
     * Phone, special subtype of {@link module:entity/js/api/PropertyType.TEXT PropertyType.Text}
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.PHONE = 'PHONE';

    /**
     * URL, special subtype of {@link module:entity/js/api/PropertyType.TEXT PropertyType.Text}
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.URL = 'URL';

    /**
     * Datetime
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.DATETIME = 'DATETIME';

    /**
     * Date
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.DATE = 'DATE';

    /**
     * Time
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.TIME = 'TIME';

    /**
     * Attachment
     *
     * @AbcsAPI stable
     * @version 15.4.5
     * @type {String}
     */
    PropertyType.ATTACHMENT = 'ATTACHMENT';

    /**
     * Lookup
     *
     * This is an ABCS internal value, not intended for public API.
     */
    PropertyType._LOOKUP = 'LOOKUP';

    /**
     * Array of all property types names.
     *
     * @type {String[]}
     */
    PropertyType.values = function() {
        return [
            PropertyType.NUMBER,
            PropertyType.CURRENCY,
            PropertyType.PERCENTAGE,
            PropertyType.BOOLEAN,
            PropertyType.KEY,
            PropertyType.REFERENCE,
            PropertyType.TEXT,
            PropertyType.EMAIL,
            PropertyType.PHONE,
            PropertyType.URL,
            PropertyType.DATETIME,
            PropertyType.DATE,
            PropertyType.TIME,
            PropertyType.ATTACHMENT
        ];
    };

    /**
     * Returns display name of the given property type translated to the current
     * locale.
     *
     * @param {entity/js/api/PropertyType} propertyType property type to translate
     * @returns {String|undefined} property type's display name or undefined when
     * the property type is unkown
     */
    PropertyType.getDisplayName = function (propertyType) {
        AbcsLib.checkDefined(propertyType, 'propertyType');
        if (PropertyType.values().concat(PropertyType._LOOKUP).indexOf(propertyType) === -1) {
            throw new Error('Unknown property type: ' + propertyType);
        }
        var key = 'entity.propertyTypes.' + propertyType;
        return AbcsLib.i18n(key);
    };

    return PropertyType;
});