luckymarmot / Paw-Issues

The issue tracker repository for the Paw HTTP Client app.
33 stars 0 forks source link

Set InputField choices dynamic #61

Open langeland opened 6 years ago

langeland commented 6 years ago

As fare as I can see it is not possible to set the ´choices´ option on a InputField with the type Select. Is this possible, or is it something that is in a pipeline ?

I've added a little mockup of what i'am trying to do.

var SelectValue = function() {
    this.evaluate = function() {
        var posibleChoices = [];

        this.posibleValues.forEach(function(posibleValue) {
            if (posibleValue[2]) {
                posibleChoices.push(posibleValue[0]);
            }
        });

        // This is not working
        this.selectedValue.choices = posibleChoices;
        return this.selectedValue;
    }

    this.title = function(context) {
        return this.fieldName;
    }

    this.text = function(context) {
        return this.selectedValue;
    }
}

SelectValue.inputs = [
    InputField("selectedValue", "Selected value", "Select", {"choices": {"k1": "v1"}, persisted: true}),
    InputField("posibleValues", "Posible values2", "KeyValueList", {"keyName":"Display name", "valueName":"Value"}),
    InputField("fieldName", "Name", "String", {persisted: true, defaultValue: "", placeholder: "Type a name"}),
];

SelectValue.identifier = "info.langeland.SelectValue";
SelectValue.title = "Select Value";
SelectValue.help = "https://luckymarmot.com/paw/doc/";
registerDynamicValueClass(SelectValue)

Thanks /

Urbanproof commented 2 years ago

Any updates on this? 🤞 Either way, +1.