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
New plugin: Survey #2265
New plugin: Survey #2265
Conversation
🦋 Changeset detectedLatest commit: dee2287 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just a couple comments to think about
Thanks very much for the feedback @chrisbrickhouse! |
…ox_columns/rows to differentiate from multi-choice columns param, clarify multi-choice type in docs
Hey @bjoluc, @jodeleeuw, @chrisbrickhouse (and anyone else!) - I could use some guidance on implementation decisions with this plugin. I got this basic version working just so I could figure out how to use SurveyJS and make sure it has the features we need. But now it needs refactoring. The question-type-specific parameters (nested in I'm also aware that I've gone for the naïve solution of putting all of the question-type-specific set-up code in functions in the main I'd appreciate any thoughts on these implementation decisions. And if you think I should set up a question class and/or separate parameter info types for each question type, please do let me know if you have any tips on how to do this! |
This seems reasonable to me for now. I still don't fully understand the black magic that @bjoluc conjured up to make all the typing work for these parameters, so I'm not sure if there's a better solution. I imagine there's something where we could define an
I like this solution! I used a lot of |
Glad it's not just me! 😆
Yes this is what I was trying to figure out, but maybe we can just focus on getting a reasonable-if-not-ideal version working for now, given the time constraints, and then come back to refactoring later. It would be cool to actually understand how to do this but I'm aware that I don't have loads of time to figure it out.
Great, thanks for the tip and link to your code! |
Right now, the magic (let's not call it black 😜) is just a shorthand to type the
Typescript-wise, that would be union types and type guards – if you're after that, I'm happy to set it up in a free moment – but it would just be for our pleasure then...
100%, I wouldn't suggest anything else :) Other than that, I think the plugin looks very good already! Let me know if there's anything I should help with! |
Wonderful, thanks @bjoluc! |
I think @bjoluc said most of what I was thinking. I spent some time today looking into type unions and...yikes... They seem like a cool feature of TS that might be useful in another context, but using them here strikes me as an anti-pattern. My main concern is that they increase the learning curve for minimal gain. More esoteric code means that there are fewer people who can integrate upstream changes or contribute downstream changes.
I think this modular solution would be more maintainable. Upstream changes may introduce new form items or users might want to add their own custom ones. I think making those changes will be more straightforward if these were implemented as methods rather than type unions since hackers are probably more familiar with objects than strict typing. |
Thanks for your thoughts @chrisbrickhouse!
I hadn't thought of it this way but now I totally see your point. I think I was too focused on finding the "right" (ES6/TS/OOP) way of setting up this plugin that I started to forget about readability and user-friendliness. |
Ok I can change this, even though I'm a fan of functional-style programming 😃 |
I tend to agree with this but am happy to be overruled. |
Totally agree, FP is great! I just wouldn't use it in this particular scenario, i.e. to write imperative code in a more complex way. Some places with great FP potential:
|
to get correct TS types for question objects and get rid of an additional level of question type mapping
Wow @bjoluc, your refactoring is SUPER helpful - thanks!! And sorry that you've had to re-write pretty much everything... 😬 |
Not at all, the code and structure before was just fine! I just like to use refactoring as a means of getting the gist of code I get to work on... |
by setting `fallbackToSortableJS`
New survey plugin that uses SurveyJS under the hood. Features:
This is a work in progress. I'm creating the PR now so that I can get some implementation feedback/guidance.