Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve choice to allow jumping to queries/forms #7

Open
GochoMugo opened this issue Nov 19, 2017 · 0 comments
Open

Improve choice to allow jumping to queries/forms #7

GochoMugo opened this issue Nov 19, 2017 · 0 comments

Comments

@GochoMugo
Copy link
Member

We are having so much code looking like this:

{
    "name": "test",
    "question": {
        "text": "test query",
        "choices": [{
            id: 1,
            text: "choice 1",
        }, {
            id: 2,
            text: "choice 2",
        }],
    },
    pre(answer, done) {
        switch (answer) {
        case 1: return this.do("form1", done);
        case 2: return this.do("form2", done);
        }
    },
}

which could be shortened to:

{
    "name": "test",
    "question": {
        "text": "test query",
        "choices": [{
            id: 1,
            text: "choice 1",
            do: "form1",
        }, {
            id: 2,
            text: "choice 2",
            do: "form2",
        }],
    },
}

Adding do (and goto) props to choices should allow jumping to
a form (and query) when the choice is matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant