INNER CODE UNIT · JavaScript

solveRefPropValue

ChatFAQ/ChatFAQ · admin/utils/index.js:47

export async function solveRefPropValue(item, propName, itemSchema) {
    const itemsStore = useItemsStore();
    if (!itemSchema)
        return;
    const prop = itemSchema.properties[propName];
    if (!prop) {
        return item[propName];
    }
    if (prop.$ref && itemSchema.properties[propName].choices) {
        // itemSchema.choices has the values for the $ref: [{label: "label", value: "value"}, {...}] item[propName] has the value, we want the label
        let choice;
        if (itemSchema.properties[propName].choices.results)
            choice = itemSchema.properties[propName].choices.results.find(choice => choice.value === item[propName]);
        else
            choice = itemSchema.properties[propName].choices.find(choice => choice.value === item[propName]);
        if (choice)
            return choice.label;
        else if (!choice && prop.$ref) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…